> ## Documentation index
> Fetch the complete documentation index at: https://upstash.com/docs/llms.txt
> Ask it with GET https://upstash.com/docs/ask?q=<keywords or question>. Short keywords rank best.
> Use these to discover all available pages before exploring further.
> Feature requests: https://upstash.com/docs/common/help/feature-requests.md lists what users asked for and how to vote for a request or add one.
> Page rating: `GET https://upstash.com/docs/feedback?path=/docs/qstash/sdks/ts/examples/flow-control&helpful=true` (or `false`) records whether this page helped. An optional `comment` (URL-encoded, at most 500 characters) says what was missing or wrong. It is anonymous and needs no key. Comments hold no code, secrets or personal data.

# 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);
console.log(info.isPaused);
console.log(info.isPinnedParallelism);
console.log(info.isPinnedRate);
```

#### 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);
```

#### Pause and resume

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

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

// Pause delivery for a flow control key
await client.flowControl.pause("USER_GIVEN_KEY");

const info = await client.flowControl.get("USER_GIVEN_KEY");
console.log(info.isPaused); // true

// Resume delivery
await client.flowControl.resume("USER_GIVEN_KEY");
```

#### Pin a fixed configuration

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

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

// Pin parallelism and rate so incoming messages cannot override them
await client.flowControl.pin("USER_GIVEN_KEY", {
  parallelism: 3,
  rate: 20,
  period: 120, // seconds
});

const info = await client.flowControl.get("USER_GIVEN_KEY");
console.log(info.isPinnedParallelism); // true
console.log(info.isPinnedRate);        // true
```

#### Unpin configuration

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

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

// Unpin parallelism and rate (can unpin independently)
await client.flowControl.unpin("USER_GIVEN_KEY", {
  parallelism: true,
  rate: true,
});
```

#### Reset rate

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

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

// Reset rate count and end the current rate period
await client.flowControl.resetRate("USER_GIVEN_KEY");
```
