Create an API key
POST
/keys
const url = 'https://localhost:3000/api/v1/keys';const options = { method: 'POST', headers: {Authorization: '<Authorization>', 'Content-Type': 'application/json'}, body: '{"name":"Production Key","scopes":["trigger:hit:*","trigger:read:*"]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://localhost:3000/api/v1/keys \ --header 'Authorization: <Authorization>' \ --header 'Content-Type: application/json' \ --data '{ "name": "Production Key", "scopes": [ "trigger:hit:*", "trigger:read:*" ] }'Creates a new API key with the specified scopes. Trigger scopes include trigger:create:* (create triggers only, wildcard target only; implied by trigger:manage:*). The full key is shown only once.
Authorizations
Section titled “Authorizations”Request Body
Section titled “Request Body”Key details
Media typeapplication/json
object
name
required
string
Example
Production Keyscopes
required
Array<string>
Example
[ "trigger:hit:*", "trigger:read:*"]Responses
Section titled “Responses”Key created (contains the full key)
Media typeapplication/json
object
created_at
required
string format: date-time
id
required
string
key
required
Full key, only shown once
string
name
required
string
scopes
required
Array<string>
Example
{ "created_at": "2024-01-15T10:30:00Z", "id": "sk_abc123", "key": "sk_live_abc123xyz789def456...", "name": "Production Key", "scopes": [ "trigger:hit:*", "trigger:read:*" ]}Invalid request or scopes
Media typeapplication/json
object
error
required
string
message
string
Example
{ "error": "invalid_request", "message": "Invalid request body"}Unauthorized
Media typeapplication/json
object
error
required
string
message
string
Example
{ "error": "invalid_request", "message": "Invalid request body"}Erreur interne
Media typeapplication/json
object
error
required
string
message
string
Example
{ "error": "invalid_request", "message": "Invalid request body"}