Skip to main content
POST
Create an API key

Authorizations

x-api-key
string
header
required

Your platform key for user management, or a user key for everything else.

Headers

Idempotency-Key
string

For a versioned key. At most 255 characters. If a create times out, send the same request again with the same value. If the first request created a key, Sapiom returns 409 api_key_already_created with its apiKeyId, not a second key.

Sapiom-Scope
string

tenant: and a user's ID. A versioned platform key uses it to act for that user.

Body

application/json
name
string
required

Name of the API key

Required string length: 1 - 255
Example:

"My Production API Key"

accessType
enum<string>

Required with authorizationVersion: 1. platform creates a platform key. tenant creates a key for one user.

Available options:
platform,
tenant
authorizationVersion
enum<number>

Send 1 to create a versioned key. A versioned key must send 1.

Available options:
1
description
string

Optional description of the API key

Maximum string length: 1000
Example:

"Used for production integrations"

permissions
string[]

Only with authorizationVersion: 1 and accessType: "tenant". Omit it for the fixed-key defaults, or send the exact permissions to grant. Omit it for a platform key.

Minimum array length: 1
type
enum<string>

Optional. Your key's environment decides the type: live for a live key, test for a sandbox key. Omit it or send that value. Another value returns 400.

Available options:
live,
test

Response

API key created successfully

apiKey
object
required

Nonsecret metadata of the created API key

plainKey
string
required

The plain text API key (only shown once)

Example:

"sk_live_<43-char-base62-string>"