Admin Rate Limit — TypeScript SDK
Read and set a per-customer request rate cap.
Overview
The admin Rate Limit resource reads and sets a customer's request rate cap (requests-per-minute). An unset cap means unlimited.
Accessed via admin.rateLimit.
Available Operations
| Method | Description |
|---|---|
getRateLimit() | Read a customer's rate cap |
setRateLimit() | Set or clear a customer's rate cap |
getRateLimit
Read a customer's rate cap. Returns the cap as-is; null means unlimited.
Example Usage
const cap = await admin.rateLimit.getRateLimit(42);
console.log(cap); // e.g. 60000, or null for unlimited
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| userId | number | Yes | -- | Target customer id (positional argument) |
Response
Returns the cap value (number) or null when no cap is configured (unlimited).
Errors
| Code | Exception | When |
|---|---|---|
2007 | PermissionError | Admin lacks Rate Limit Management permission |
3001 | AuthenticationError | Session expired and refresh failed |
setRateLimit
Set or clear a customer's rate cap. Pass null to remove the cap (unlimited); the field is always sent with an explicit null rather than being omitted.
Example Usage
// Set a cap
const ok = await admin.rateLimit.setRateLimit(42, 60000);
console.log(ok); // true
// Clear the cap (unlimited)
await admin.rateLimit.setRateLimit(42, null);
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| userId | number | Yes | -- | Target customer id (positional argument) |
| tpmCap | number | null | Yes | -- | Requests-per-minute cap; null clears it (positional argument) |
Response
Returns boolean — true on success. The value is sent on the wire under the adminTpmCap field.
Errors
| Code | Exception | When |
|---|---|---|
1001 | ValidationError | Invalid userId |
2007 | PermissionError | Admin lacks Rate Limit Management permission |
3001 | AuthenticationError | Session expired and refresh failed |