Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,8 @@
"qstash/sdks/ts/examples/logs",
"qstash/sdks/ts/examples/messages",
"qstash/sdks/ts/examples/receiver",
"qstash/sdks/ts/examples/queues"
"qstash/sdks/ts/examples/queues",
"qstash/sdks/ts/examples/flow-control"
]
}
]
Expand All @@ -1119,7 +1120,8 @@
"qstash/sdks/py/examples/messages",
"qstash/sdks/py/examples/keys",
"qstash/sdks/py/examples/receiver",
"qstash/sdks/py/examples/queues"
"qstash/sdks/py/examples/queues",
"qstash/sdks/py/examples/flow-control"
]
}
]
Expand Down Expand Up @@ -1346,7 +1348,8 @@
"group": "Flow Control",
"pages": [
"workflow/rest/flow-control/get",
"workflow/rest/flow-control/list"
"workflow/rest/flow-control/list",
"workflow/rest/flow-control/global-parallelism"
]
},
{
Expand Down
113 changes: 111 additions & 2 deletions qstash/features/flowcontrol.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,123 @@ curl -XPOST -H 'Authorization: Bearer XXX' \
```
</CodeGroup>

## Monitor
## Management API

You can inspect flow control keys programmatically using the `flowControl` namespace on the client.

### Get a single flow control key

Returns the current state and metrics for one flow control key.

<CodeGroup>
```typescript TypeScript
import { Client } from "@upstash/qstash";

const client = new Client({ token: "<QSTASH_TOKEN>" });

const info = await client.flowControl.get("USER_GIVEN_KEY");
console.log(info);
// {
// flowControlKey: "USER_GIVEN_KEY",
// waitListSize: 5,
// parallelismMax: 10,
// parallelismCount: 3,
// rateMax: 100,
// rateCount: 42,
// ratePeriod: 60,
// ratePeriodStart: 1708000000
// }
```

```python Python
from qstash import QStash

client = QStash("<QSTASH-TOKEN>")

info = client.flow_control.get("USER_GIVEN_KEY")
print(info)
# FlowControlInfo(
# key="USER_GIVEN_KEY",
# wait_list_size=5,
# parallelism_max=10,
# parallelism_count=3,
# rate_max=100,
# rate_count=42,
# rate_period=60,
# rate_period_start=1708000000
# )
```

```bash cURL
curl -X GET https://qstash.upstash.io/v2/flowControl/USER_GIVEN_KEY \
-H "Authorization: Bearer <token>"
```
</CodeGroup>

The response fields are:

| Field | Description |
|---|---|
| `flowControlKey` | The flow control key name |
| `waitListSize` | Number of messages currently waiting in the queue |
| `parallelismMax` | Configured maximum concurrent messages (if set) |
| `parallelismCount` | Number of messages currently running in parallel |
| `rateMax` | Configured maximum messages per rate period (if set) |
| `rateCount` | Number of messages dispatched in the current rate period |
| `ratePeriod` | Rate period length in seconds |
| `ratePeriodStart` | Unix timestamp when the current rate period started |

### Get global parallelism

Returns the global parallelism usage across all flow control keys.

<CodeGroup>
```typescript TypeScript
import { Client } from "@upstash/qstash";

const client = new Client({ token: "<QSTASH_TOKEN>" });

const info = await client.flowControl.getGlobalParallelism();
console.log(info);
// {
// parallelismMax: 500,
// parallelismCount: 42
// }
```

```python Python
from qstash import QStash

client = QStash("<QSTASH-TOKEN>")

info = client.flow_control.get_global_parallelism()
print(info)
# GlobalParallelismInfo(
# parallelism_max=500,
# parallelism_count=42
# )
```

```bash cURL
curl -X GET https://qstash.upstash.io/v2/globalParallelism \
-H "Authorization: Bearer <token>"
```
</CodeGroup>

| Field | Description |
|---|---|
| `parallelismMax` | The maximum global parallelism |
| `parallelismCount` | The current number of active requests globally |

## Monitor

You can monitor wait list size of your flow control key's from the console `FlowControl` tab.

<Frame>
<img src="/img/qstash/flowcontrol.png" />
</Frame>

Also you can get the same info using the REST API.
Also you can get the same info using the REST API.
- [List All Flow Control Keys](/qstash/api/flow-control/list).
- [Single Flow Control Key](/qstash/api/flow-control/get).
- [Global Parallelism](/qstash/api/flow-control/global-parallelism).
47 changes: 44 additions & 3 deletions qstash/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,27 @@ components:
flowControlKey:
type: string
description: The flow control key name
waitlistSize:
waitListSize:
type: integer
description: The number of messages waiting due to flow control configuration.
parallelismMax:
type: integer
description: The configured maximum number of messages allowed to run concurrently, if parallelism is set.
parallelismCount:
type: integer
description: The current number of messages running in parallel.
rateMax:
type: integer
description: The configured maximum number of messages allowed per rate period, if rate limiting is set.
rateCount:
type: integer
description: The number of messages dispatched in the current rate period.
ratePeriod:
type: integer
description: The length of the rate period in seconds.
ratePeriodStart:
type: integer
description: Unix timestamp (seconds) when the current rate period started.

DLQMessage:
type: object
Expand Down Expand Up @@ -2398,8 +2416,10 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/FlowControlKey'

type: array
items:
$ref: '#/components/schemas/FlowControlKey'

/v2/flowControl/{flowControlKey}:
get:
summary: Get Flow Control Key
Expand All @@ -2426,6 +2446,27 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Error'

/v2/globalParallelism:
get:
summary: Get Global Parallelism
description: Returns the current global parallelism usage across all flow control keys
tags:
- Flow Control
responses:
'200':
description: Global parallelism info retrieved successfully
content:
application/json:
schema:
type: object
properties:
parallelismMax:
type: integer
description: The configured maximum global parallelism
parallelismCount:
type: integer
description: The current number of messages running globally in parallel

/v2/keys:
get:
Expand Down
11 changes: 11 additions & 0 deletions qstash/overall/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ title: Changelog
We have moved the roadmap and the changelog to [Github Discussions](https://github.com/orgs/upstash/discussions) starting from October 2025.Now you can follow `In Progress` features. You can see that your `Feature Requests` are recorded. You can vote for them and comment your specific use-cases to shape the feature to your needs.
</Note>

<Update label="February 2026">
- **TypeScript SDK (`qstash-js`)** and **Python SDK (`qstash-py`):**
- Added flow control management API: `list()`, `get(key)`, and `reset(key)` methods on `client.flowControl` (TypeScript) and `client.flow_control` (Python).
- The `get` and `list` responses now include rich metrics: `waitListSize`, `parallelismMax`, `parallelismCount`, `rateMax`, `rateCount`, `ratePeriod`, and `ratePeriodStart`.
- See the [Flow Control](/qstash/features/flowcontrol#management-api) docs for code examples.
- **QStash Server:**
- `GET /v2/flowControl` now supports an optional `search` query parameter to filter keys by name.
- New `POST /v2/flowControl/:flowControlKey/reset` endpoint resets parallelism and rate counters for a key.
- `GET /v2/globalParallelism` now returns `{ parallelismMax, parallelismCount }` instead of the old `{ waitListSize }` shape.
</Update>

<Update label="September 2025">
- **TypeScript SDK (`qstash-js`):**
- `Label` feature is added. This will enable our users to label their publishes so that
Expand Down
33 changes: 33 additions & 0 deletions qstash/sdks/py/examples/flow-control.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: Flow Control
---

#### Get a single flow control key

```python
from qstash import QStash

client = QStash("<QSTASH-TOKEN>")

info = client.flow_control.get("USER_GIVEN_KEY")
print(info.key)
print(info.wait_list_size)
print(info.parallelism_max)
print(info.parallelism_count)
print(info.rate_max)
print(info.rate_count)
print(info.rate_period)
print(info.rate_period_start)
```

#### Get global parallelism

```python
from qstash import QStash

client = QStash("<QSTASH-TOKEN>")

info = client.flow_control.get_global_parallelism()
print(info.parallelism_max)
print(info.parallelism_count)
```
33 changes: 33 additions & 0 deletions qstash/sdks/ts/examples/flow-control.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: Flow Control
---

#### Get a single flow control key

```typescript
import { Client } from "@upstash/qstash";

const client = new Client({ token: "<QSTASH_TOKEN>" });

const info = await client.flowControl.get("USER_GIVEN_KEY");
console.log(info.flowControlKey);
console.log(info.waitListSize);
console.log(info.parallelismMax);
console.log(info.parallelismCount);
console.log(info.rateMax);
console.log(info.rateCount);
console.log(info.ratePeriod);
console.log(info.ratePeriodStart);
```

#### Get global parallelism

```typescript
import { Client } from "@upstash/qstash";

const client = new Client({ token: "<QSTASH_TOKEN>" });

const info = await client.flowControl.getGlobalParallelism();
console.log(info.parallelismMax);
console.log(info.parallelismCount);
```
4 changes: 2 additions & 2 deletions workflow/features/flow-control/monitor.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ You can monitor wait list size of your flow control key's from the console `Flow
<img src="/img/qstash/flowcontrol.png" />
</Frame>

Also you can get the same info using the REST API.
Also you can get the same info using the REST API.
- [List All Flow Control Keys](/workflow/rest/flow-control/list).
- [Single Flow Control Key](/workflow/rest/flow-control/get).

- [Global Parallelism](/workflow/rest/flow-control/global-parallelism).
41 changes: 40 additions & 1 deletion workflow/rest/flow-control/get.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,54 @@ authMethod: "bearer"
## Response

<ResponseField name="flowControlKey" type="string">
The key of of the flow control.
The key of the flow control.
</ResponseField>

<ResponseField name="waitListSize" type="integer">
The number of messages in the wait list that waits for `parallelism`/`rate` set in the flow control.
</ResponseField>

<ResponseField name="parallelismMax" type="integer">
The configured maximum number of messages allowed to run concurrently, if parallelism is set.
</ResponseField>

<ResponseField name="parallelismCount" type="integer">
The current number of messages running in parallel.
</ResponseField>

<ResponseField name="rateMax" type="integer">
The configured maximum number of messages allowed per rate period, if rate limiting is set.
</ResponseField>

<ResponseField name="rateCount" type="integer">
The number of messages dispatched in the current rate period.
</ResponseField>

<ResponseField name="ratePeriod" type="integer">
The length of the rate period in seconds.
</ResponseField>

<ResponseField name="ratePeriodStart" type="integer">
Unix timestamp (seconds) when the current rate period started.
</ResponseField>

<RequestExample>
```sh
curl -X GET https://qstash.upstash.io/v2/flowControl/YOUR_FLOW_CONTROL_KEY -H "Authorization: Bearer <token>"
```
</RequestExample>

<ResponseExample>
```json
{
"flowControlKey": "YOUR_FLOW_CONTROL_KEY",
"waitListSize": 5,
"parallelismMax": 10,
"parallelismCount": 3,
"rateMax": 100,
"rateCount": 42,
"ratePeriod": 60,
"ratePeriodStart": 1708000000
}
```
</ResponseExample>
Loading