> ## Documentation Index
> Fetch the complete documentation index at: https://upstash.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Flow Control

#### Get a single flow control key

```typescript theme={"system"}
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 theme={"system"}
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 theme={"system"}
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 theme={"system"}
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 theme={"system"}
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 theme={"system"}
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");
```
