Skip to main content
A keyspace is a container for related API keys. It doesn’t represent a running service or HTTP endpoint. Instead, it provides a boundary for organizing keys by product, environment, or tier. In the dashboard, keyspaces appear under Keyspaces (APIs). Every key belongs to exactly one keyspace. When you create a key, you specify which keyspace it belongs to by passing its apiId.

When to create separate keyspaces

Use multiple keyspaces when you need independent key prefixes, permissions, or analytics boundaries.
StrategyExample namesWhy
By productpayments-api, search-apiDifferent key prefixes and permission sets per product
By environmentproduction, stagingSeparate keys and usage tracking per stage
By tierfree-tier, enterpriseDifferent default rate limits per plan
A single keyspace works fine if all your keys share the same configuration and you filter by metadata or tags instead.

Create a keyspace

  1. Navigate to Keyspaces (APIs) in the sidebar.
  2. Click Create new keyspace.
  3. Enter a name for your keyspace.
Unkey generates a unique API ID (api_xxx) for the keyspace. This is the identifier you pass when creating keys and querying analytics, so keep it handy.

Keyspace settings

Each keyspace exposes configuration through its settings page.
SettingDescription
NameHuman-readable label shown in the dashboard
Default prefixPrefix prepended to every key created in this keyspace (for example, sk_live)
Default bytesNumber of random bytes used to generate new keys (default: 16)
Store encrypted keysWhen enabled, Unkey stores an encrypted copy of each key so it can be recovered later. See Recovering keys.
IP whitelistRestrict key verification to specific IP addresses. See IP whitelist.

Identifiers

Each keyspace has two identifiers:
IdentifierFormatUsed for
API IDapi_xxxCreating keys and most API calls — the identifier you’ll use most often
KeySpace IDks_xxxAnalytics queries (as key_space_id) and Sentinel configuration

Storage and validation

A keyspace is the storage and validation boundary for all of its keys (internally, it’s backed by a key_auth record). When Sentinel or the verification endpoint receives a key, it resolves the keyspace by key prefix and validates the key against that keyspace’s configuration. The keyspace stores:
PropertyDescription
idUnique identifier (ks_xxx), used in Sentinel policies and analytics queries
default_prefixPrefix for new keys (for example, sk_live). The prefix appears before the random portion of the key.
default_bytesNumber of random bytes per key (default: 16, producing a 24-character base58 string)
store_encrypted_keysWhether to store a recoverable encrypted copy of each key
size_approxApproximate number of live keys in this keyspace
KeySpace IDs appear in analytics queries as key_space_id and in Sentinel configuration when connecting a keyspace to a deployment.

Key format

Each key is composed of a prefix and a random portion:
sk_live_abc123def456ghi789
└─────┘ └──────────────────┘
 prefix   random (base58-encoded)
The prefix is optional but recommended. It makes keys visually identifiable and lets Unkey route verification requests to the correct keyspace without a database lookup.

Delete a keyspace

Deleting a keyspace permanently removes it and all of its keys. This action cannot be undone.
Delete protection prevents accidental deletion. Disable it in the keyspace settings before deleting.

Constraints

LimitValue
Keyspaces per workspaceVaries by plan
Key prefix max length8 characters
Default bytes range16 to 32
PageDescription
API keysIssue, verify, and manage keys
Rate limitingPer-key rate limits
AuthorizationRoles and permissions
AnalyticsQuery verification data by keyspace
Sentinel authenticationConnect keyspaces to Sentinel policies
Last modified on June 2, 2026