Apply rate limiting
Changed onCheck and enforce rate limits for any identifier (user ID, IP address, API client, etc.).
Use this for rate limiting beyond API keys - limit users by ID, IPs by address, or any custom identifier. Supports namespace organization, variable costs, and custom overrides.
Response Codes: Rate limit checks return HTTP 200 regardless of whether the limit is exceeded — check the success field in the response to determine if the request should be allowed. A 429 may be returned if the workspace exceeds its API rate limit. Other 4xx responses indicate auth, namespace existence/deletion, or validation errors (e.g., 410 Gone for deleted namespaces). 5xx responses indicate server errors.
Required Permissions
Your root key must have one of the following permissions:
- ratelimit.*.limit (to check limits in any namespace)
- ratelimit.<namespace_id>.limit (to check limits in a specific namespace)
Request
- Base URLhttps://api.unkey.com
- URLhttps://api.unkey.com/v2/ratelimit.limit
- AuthHTTP bearer
Request body
Example request
{
"namespace": "sms.sign_up",
"cost": 5,
"duration": 60000,
"identifier": "user_12345",
"limit": 1000
}Response
Rate limit check completed successfully. Check the success field to determine if the request is allowed.
Example response
{
"meta": {
"requestId": "req_123"
}
}Changes
- info
the
request property's maxLength was increased from255to512 - info
the
request property's maxLength was increased from255to512
- info
- info
the endpoint scheme security
bearerwas added to the API - info
the endpoint scheme security
rootKeywas removed from the API
- info