ratelimit.limit to rate limit a public API by user id, customer id, or IP address. Unkey keeps the counters, so you don’t run Redis. You send the limit and the window on each call, and you return HTTP 429 when data.success is false.
ratelimit.multiLimit runs up to 100 checks in one call, and counts them only if they all pass. The rules live in your code. To change the rule for particular identifiers without a deploy, use overrides. A monthly total on an API key is credits, not this window. See Key and identity rate limits.
data.reset is Unix milliseconds. Retry-After is in seconds, which is what RFC 6585 allows on a 429. Unkey doesn’t set Retry-After or X-RateLimit-* on this endpoint. The full header list, including what the Compute gateway sends, is on Rate limiting.
Create a root key with the permissions listed on this page under Root Keys in the dashboard sidebar. CLI commands can instead use a session from unkey login with the required permissions. See Permission reference for every permission.
unkey:v1:<workspace_id>:projects/<project_id>/ratelimits/namespaces/<namespace_id>#limit for every namespace checked. Use * for the namespace ID to cover all namespaces in a project. The first call with a new namespace name creates it in the workspace’s default project. This also needs unkey:v1:<workspace_id>:projects/<project_id>/ratelimits/namespaces/*#write for that project and #limit permission for each created namespace.
Namespaces
A namespace names what you’re limiting, such asemail.send or api.requests. Identifiers are counted separately in each namespace. Refer to a namespace by name (1 to 512 characters, case-sensitive) or ID (rlns_...). A new name is created on first use. Rename or delete namespaces in the dashboard under Ratelimit. A check against a deleted namespace fails with HTTP 410 err:unkey:data:ratelimit_namespace_gone.
ratelimit.limit
Who or what you’re counting, 1 to 512 characters: a user ID, IP address, tenant, or any stable string.
Window length in milliseconds, 1000 (one second) to 2592000000 (30 days). A matching override replaces it.
Response
Whether the request fit within the limit. The endpoint returns HTTP 200 either way, so read this field.
ratelimit.limit audit event. To keep a ratelimit.limit call out of analytics and your API request logs, send the header X-Unkey-Metrics: disabled. ratelimit.multiLimit ignores this header.
ratelimit.multiLimit
Send an array of 1 to 100 objects with the same fields asratelimit.limit. Use it when one action must pass several limits, for example a per-user and a per-organization limit, or a request count and a token budget.
Each check must have a different combination of namespace, identifier and duration. A repeated combination returns a 400 error with invalid_input before any namespace is created.
err:unkey:data:ratelimit_namespace_gone.
Response
One result per check, in request order, each with
namespace, identifier, passed, limit, remaining, reset, and overrideId.remaining on the passing checks doesn’t include this request.
Choosing limits
- Pick the window for the job. Short windows, such as 20 per 10 seconds, stop bursts. Longer windows, such as 1,000 per hour, work as quotas. Windows of a minute or more are more accurate across regions.
- Use
costfor expensive operations instead of a second namespace. - Keep identifiers stable. An identifier with a timestamp or request ID in it is never seen twice, so it limits nothing.
- Send plan limits per call. To raise limits when a user upgrades, send the new
limitwith the same identifier andduration. Usage already counted in the window carries over. See Change a limit mid-window. - Use an override when one customer needs a different number, instead of a code path.