Skip to main content
All API requests require authentication. ShortKit uses two types of API keys — publishable keys for client-side access and secret keys for server-side operations.

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.
Secret keys grant full API access. Never expose them in client-side code, mobile apps, public repositories, or browser environments.

Key formats

Publishable keys follow the pattern pk_{env}_{random}:
Secret keys follow the pattern 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:
The SDK attaches the key to every request automatically via the 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 the Authorization header as a Bearer token:
Secret keys are bcrypt-hashed before storage. The plaintext is shown exactly once at creation time and cannot be retrieved afterward. If you lose it, rotate to get a new one.

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 — either live 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 returns 401 (invalid_api_key) or 403 (forbidden). See Errors for details and response format.

Best practices

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.
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):
  • Mobile apps and browsers: Publishable key (pk_live_ / pk_test_) via X-API-Key header
  • Backend servers and scripts: Secret key (sk_live_ / sk_test_) via Authorization: Bearer header
Mixing these up either exposes your secret key or blocks legitimate requests with a 403.
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.
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.