API key types
Both key types encode the environment (
live or test) directly in the prefix, so a single key always maps to exactly one environment.
Key formats
Publishable keys follow the patternpk_{env}_{random}:
sk_{env}_{id}_{random}:
Publishable keys
Publishable keys are designed to be embedded in client applications. They provide read-only access to public-facing endpoints. Publishable keys are used by the ShortKit SDK. Pass your publishable key when initializing the SDK:X-API-Key header. You never use a secret key in the SDK, and you don’t need to call any publishable-key endpoints directly — the SDK handles all communication with the ShortKit API.
Secret keys
Secret keys are used for server-to-server communication. They provide full access to all management endpoints. Send the key in theAuthorization header as a Bearer token:
Endpoints by key type
Publishable key (X-API-Key header)
Secret key (Authorization: Bearer header)
Environment isolation
Every API key encodes its environment in the prefix — eitherlive or test. These environments are completely isolated:
A
live key cannot access test data, and a test key cannot access live data. The server extracts the environment from the key prefix and enforces this boundary on every request.
Secret key rotation
If you need to rotate a compromised or aging secret key, use the ShortKit portal. The old key is immediately invalidated when a new one is generated.Key expiration
API keys do not expire automatically. Both publishable and secret keys remain valid until the secret key is manually rotated. There is no time-based expiration policy — you control the key lifecycle through rotation.Authentication errors
If authentication fails, the API returns401 (invalid_api_key) or 403 (forbidden). See Errors for details and response format.
Best practices
Publishable keys are safe for client bundles
Publishable keys are safe for client bundles
Publishable keys grant read-only access to published content and event ingestion. They are designed to be shipped in mobile apps, web embeds, and client-side JavaScript. Treat them like a public identifier, not a secret.
Store secret keys in environment variables only
Store secret keys in environment variables only
Never hard-code secret keys in source files or commit them to version control. Use environment variables or a secrets manager (AWS Secrets Manager, HashiCorp Vault,
.env files excluded from git):Use the correct key type for each context
Use the correct key type for each context
- Mobile apps and browsers: Publishable key (
pk_live_/pk_test_) viaX-API-Keyheader - Backend servers and scripts: Secret key (
sk_live_/sk_test_) viaAuthorization: Bearerheader
403.Rotate on team changes
Rotate on team changes
When a team member with access to the secret key leaves the organization, rotate the key immediately via
POST /v1/org/rotate-secret-key. The old key is invalidated instantly.Monitor for exposed keys
Monitor for exposed keys
If a secret key is accidentally committed to a public repository or included in client-side code, rotate it immediately. The old key stops working as soon as rotation completes.