Skip to main content
POST
Go (SDK)

Authorizations

Authorization
string
header
required

Unkey uses bearer tokens for authentication. Public integrations use root keys, while the dashboard proxy uses short-lived JWTs. To authenticate, include the token in the Authorization header of each request:

Root keys have specific permissions attached to them, controlling what operations they can perform. Resource permissions use Unkey Resource Names plus actions, like unkey:v1:ws_123:projects/*/keyspaces/*/keys/*#write. Security best practices:

  • Keep root keys secure and never expose them in client-side code
  • Use different root keys for different environments
  • Rotate keys periodically, especially after team member departures
  • Create keys with minimal necessary permissions following least privilege principle
  • Monitor key usage with audit logs.

Body

application/json
namespace
string
required

The id or name of the namespace.

Required string length: 1 - 512
Example:

"sms.sign_up"

duration
integer<int64>
required

Sets the rate limit duration in milliseconds. It must be at least 10000 (10 seconds) and at most 86400000 (24 hours). Common values include 10000 (10 seconds), 60000 (1 minute), 3600000 (1 hour), and 86400000 (24 hours).

Required range: 10000 <= x <= 86400000
Example:

60000

identifier
string
required

Defines the scope of rate limiting by identifying the entity being limited. Use user IDs for per-user limits, IP addresses for anonymous limiting, or API key IDs for per-key limits. The same identifier can be used across different namespaces to apply multiple rate limit types. Choose identifiers that provide appropriate granularity for your rate limiting strategy.

Required string length: 1 - 512
Example:

"user_12345"

limit
integer<int64>
required

Sets the maximum cost allowed per duration before requests are rejected. Balance user experience with resource protection when setting limits for different user tiers.

Required range: 1 <= x <= 9007199254740991
Example:

1000

cost
integer<int64>
default:1

Sets how much of the rate limit quota this request consumes, enabling weighted rate limiting. Use higher values for resource-intensive operations and 0 for tracking without limiting. A cost greater than the limit that applies, including the limit of a matching override, never fits: the check is denied and retryAfter is one duration.

Required range: 0 <= x <= 9007199254740991
Example:

5

record
enum<string>
default:IF_ALLOWED

Configure when this check persists its cost.

  • IF_ALLOWED: counts the cost only if it fits.
  • ALWAYS: counts the cost even if it does not fit, such as for usage that already happened.
  • NEVER: counts nothing and only reports whether the cost fits. This is the same behavior as setting a cost of 0.
Available options:
IF_ALLOWED,
ALWAYS,
NEVER
Example:

"IF_ALLOWED"

Response

Rate limit check completed successfully. Check the allowed field to determine if the request may proceed.

meta
object
required

Metadata object included in every API response. This provides context about the request and is essential for debugging, audit trails, and support inquiries. The requestId is particularly important when troubleshooting issues with the Unkey support team.

data
object
required