Admin Rate Limit — Python 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.rate_limit.
Available Operations
| Method | Description |
|---|---|
get_rate_limit() | Read a customer's rate cap |
set_rate_limit() | Set or clear a customer's rate cap |
get_rate_limit
Read a customer's rate cap. Returns the cap as-is; None means unlimited.
Example Usage
cap = admin.rate_limit.get_rate_limit(user_id=42)
print(cap) # e.g. 60000, or None for unlimited
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| user_id | int | Yes | -- | Target customer id (positional argument) |
Response
Returns the cap value (int) or None 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 |
set_rate_limit
Set or clear a customer's rate cap. Pass tpm_cap=None to remove the cap (unlimited); the field is always sent with an explicit null rather than being omitted.
Example Usage
# Set a cap
ok = admin.rate_limit.set_rate_limit(user_id=42, tpm_cap=60000)
print(ok) # True
# Clear the cap (unlimited)
admin.rate_limit.set_rate_limit(user_id=42, tpm_cap=None)
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| user_id | int | Yes | -- | Target customer id (positional argument) |
| tpm_cap | int | None | Yes | -- | Requests-per-minute cap; None clears it (positional argument) |
Response
Returns bool — True on success. The value is sent on the wire under the adminTpmCap field.
Errors
| Code | Exception | When |
|---|---|---|
1001 | ValidationError | Invalid user_id |
2007 | PermissionError | Admin lacks Rate Limit Management permission |
3001 | AuthenticationError | Session expired and refresh failed |