Unkey Deploy is currently in private beta. To get access, reach out on
Discord or email
support@unkey.com.
X-Unkey-Principal header after a request passes authentication. It contains a stable set of top-level fields that are the same across all authentication methods, plus a source object with method-specific detail.
When no authentication policy is configured or the request has no credentials, the header is absent. Check for header presence to distinguish authenticated from anonymous requests.
Top-level fields
The schema version of the Principal payload. Currently
1. Check this field if you need to handle different payload shapes during migrations. Unkey bumps the version when fields are removed or renamed, but adding new optional fields does not change the version.The primary identifier of the authenticated entity. This is the field you use for database lookups, audit logging, and as the key for per-user logic in your application.How the subject is determined depends on the authentication method:
For API keys linked to an identity, the subject is the identity’s external ID rather than the key ID. This means all keys belonging to the same identity share the same subject, which is what you want for rate limiting and usage tracking at the user level rather than the key level. The specific key ID is always available at
| Type | Subject value |
|---|---|
key (with identity) | The identity’s external ID |
key (without identity) | The key ID |
jwt | The sub claim from the token |
source.key.keyId when you need it.The authentication method that produced this Principal. One of
"key" or "jwt". This value always matches the field name inside source, so you can use it to determine which source object to read. For example, when type is "key", the method-specific data is at source.key.The identity behind the credential. Present only when the credential is linked to an Unkey identity. When no identity is linked, this field is absent from the JSON entirely (not
null, not an empty object).Identities let you group multiple credentials under a single entity. For example, a customer might have separate API keys for staging and production, but both keys are linked to the same identity. Use identity.externalId to correlate requests across credentials.Method-specific data from the authentication source. Contains exactly one field whose name matches the
type field. Most applications only need subject and identity, but source provides the full detail when you need it: key permissions, JWT claims, expiration times, and other method-specific attributes.Each source type has its own reference page:Versioning
Theversion field starts at 1. Unkey follows these rules for changes:
- Additive changes (new optional fields, new source types) don’t bump the version. Applications that don’t know about new fields ignore them.
- Breaking changes (removing fields, changing field types, renaming fields) bump the version. Unkey supports both versions during a migration period so you have time to update your application code.

