Accounts and workspaces
Create API key
Create a personal access key with chosen capabilities (agent:operate, agent:publish, agent:engage), an optional workspace_ids limit and a lifetime of up to 365 days; the secret is returned once and cannot be read again. An agent can grant only what its own authorization holds, for at most 30 days, and the key stops working when that grant ends. Needs the Manage API keys grant; a PAT cannot use it.
POST /identity-api/api-keys/createContract reviewed: · sha256:563d2d581da0ad29
Overview
Create a personal access key with chosen capabilities (agent:operate, agent:publish, agent:engage), an optional workspace_ids limit and a lifetime of up to 365 days; the secret is returned once and cannot be read again. An agent can grant only what its own authorization holds, for at most 30 days, and the key stops working when that grant ends. Needs the Manage API keys grant; a PAT cannot use it.
Each delegated authorization can have up to 25 active keys. Requests above that limit return API_KEY_GRANT_KEY_LIMIT.
A successful HTTP response can mean that a request was accepted rather than completed. For background work, save the returned ID and check the same operation until it finishes. A scheduled or accepted post is published only when the platform confirms it; a client timeout does not establish the result.
Authentication and permissions
A token can use only the rights held by its owner. Each request checks workspace membership, resource ownership, selected workspaces and granted capabilities. Core and full profiles change which tools are displayed; they do not grant access.
Request fields
Required means required inside its parent object and selected branch. A required child does not make an optional parent required. Rules and field names below are copied from the contract.
| Field / branch | Type / required | Constraints |
|---|---|---|
$ | objectRequired in parent |
|
name | stringRequired in parent |
|
lifetime_days | integerOptional / item | Days until the key expires (1-365, default 365). A key created by a delegated agent never lives longer than 30 days.
|
capabilities | arrayOptional / item | What the key may do. Defaults to operate, publish and engage for a signed-in user. A delegated agent can only grant what its own authorization holds (never key management).
|
capabilities[] | stringOptional / item |
|
workspace_ids | arrayOptional / item | Limit the key to these Workspaces. Omit it for every Workspace the user can access. A limited key must name its Workspace (workspace_id) on routes that would otherwise use the active Workspace, and cannot call organization-wide reads.
|
workspace_ids[] | stringOptional / item |
|
scopes | arrayOptional / item | Deprecated alias of capabilities. It is honoured exactly; an empty list is ignored.
|
scopes[] | stringOptional / item |
|
idempotency_key | stringOptional / item | Optional. Reuse the same key to retry safely. The secret is shown once: a retry that finds the key already created answers 409 IDEMPOTENT_REPLAY (details.existing_key names it) instead of showing it again. Revoke that key and create a new one with a new idempotency_key.
|
Complete JSON Schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"name": {
"type": "string",
"minLength": 1,
"maxLength": 80
},
"lifetime_days": {
"default": 365,
"description": "Days until the key expires (1-365, default 365). A key created by a delegated agent never lives longer than 30 days.",
"type": "integer",
"minimum": 1,
"maximum": 365
},
"capabilities": {
"description": "What the key may do. Defaults to operate, publish and engage for a signed-in user. A delegated agent can only grant what its own authorization holds (never key management).",
"minItems": 1,
"maxItems": 3,
"type": "array",
"items": {
"type": "string",
"enum": [
"agent:operate",
"agent:publish",
"agent:engage"
]
}
},
"workspace_ids": {
"description": "Limit the key to these Workspaces. Omit it for every Workspace the user can access. A limited key must name its Workspace (workspace_id) on routes that would otherwise use the active Workspace, and cannot call organization-wide reads.",
"minItems": 1,
"maxItems": 100,
"type": "array",
"items": {
"type": "string",
"format": "uuid",
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
}
},
"scopes": {
"description": "Deprecated alias of capabilities. It is honoured exactly; an empty list is ignored.",
"maxItems": 3,
"type": "array",
"items": {
"type": "string",
"enum": [
"agent:operate",
"agent:publish",
"agent:engage"
]
}
},
"idempotency_key": {
"description": "Optional. Reuse the same key to retry safely. The secret is shown once: a retry that finds the key already created answers 409 IDEMPOTENT_REPLAY (details.existing_key names it) instead of showing it again. Revoke that key and create a new one with a new idempotency_key.",
"type": "string",
"minLength": 8,
"maxLength": 160,
"pattern": "^[!-~]+$"
}
},
"required": [
"name"
],
"additionalProperties": false
}Response and completion
Success HTTP statuses: 200. When the operation is complete: synchronous_http_response.
A successful HTTP response can mean that a request was accepted rather than completed. For background work, save the returned ID and check the same operation until it finishes. A scheduled or accepted post is published only when the platform confirms it; a client timeout does not establish the result.
Required means required inside its parent object and selected branch. A required child does not make an optional parent required. Rules and field names below are copied from the contract.
| Field / branch | Type / required | Constraints |
|---|---|---|
$ | objectRequired in parent | — |
apiKey | objectRequired in parent | — |
apiKey.id | stringRequired in parent |
|
apiKey.name | stringRequired in parent | — |
apiKey.last_4 | stringRequired in parent | — |
apiKey.scopes | arrayRequired in parent | — |
apiKey.scopes[] | stringOptional / item | — |
apiKey.created_at | stringRequired in parent |
|
apiKey.expires_at | string | nullRequired in parent | — |
apiKey.expires_atanyOf 1 | stringRequired in parent |
|
apiKey.expires_atanyOf 2 | nullRequired in parent | — |
apiKey.last_used_at | string | nullRequired in parent | — |
apiKey.last_used_atanyOf 1 | stringRequired in parent |
|
apiKey.last_used_atanyOf 2 | nullRequired in parent | — |
apiKey.revoked_at | string | nullRequired in parent | — |
apiKey.revoked_atanyOf 1 | stringRequired in parent |
|
apiKey.revoked_atanyOf 2 | nullRequired in parent | — |
apiKey.status | stringRequired in parent |
|
apiKey.replaces | object | nullRequired in parent | — |
apiKey.replacesanyOf 1 | objectRequired in parent | — |
apiKey.replaces.idanyOf 1 | stringRequired in parent |
|
apiKey.replaces.nameanyOf 1 | stringRequired in parent | — |
apiKey.replaces.last_4anyOf 1 | stringRequired in parent | — |
apiKey.replaces.statusanyOf 1 | stringRequired in parent |
|
apiKey.replacesanyOf 2 | nullRequired in parent | — |
apiKey.replaced_by | arrayRequired in parent | — |
apiKey.replaced_by[] | objectOptional / item | — |
apiKey.replaced_by[].id | stringRequired in parent |
|
apiKey.replaced_by[].name | stringRequired in parent | — |
apiKey.replaced_by[].last_4 | stringRequired in parent | — |
apiKey.replaced_by[].status | stringRequired in parent |
|
apiKey.capabilities | arrayOptional / item | — |
apiKey.capabilities[] | stringOptional / item |
|
apiKey.workspace_ids | array | nullOptional / item | — |
apiKey.workspace_idsanyOf 1 | arrayOptional / item | — |
apiKey.workspace_ids[]anyOf 1 | stringOptional / item |
|
apiKey.workspace_idsanyOf 2 | nullOptional / item | — |
apiKey.created_by_delegated_grant_id | string | nullOptional / item | — |
apiKey.created_by_delegated_grant_idanyOf 1 | stringOptional / item |
|
apiKey.created_by_delegated_grant_idanyOf 2 | nullOptional / item | — |
secret | stringRequired in parent |
|
Complete JSON Schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"apiKey": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
},
"name": {
"type": "string"
},
"last_4": {
"type": "string"
},
"scopes": {
"type": "array",
"items": {
"type": "string"
}
},
"created_at": {
"type": "string",
"format": "date-time",
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
},
"expires_at": {
"anyOf": [
{
"type": "string",
"format": "date-time",
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
},
{
"type": "null"
}
]
},
"last_used_at": {
"anyOf": [
{
"type": "string",
"format": "date-time",
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
},
{
"type": "null"
}
]
},
"revoked_at": {
"anyOf": [
{
"type": "string",
"format": "date-time",
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
},
{
"type": "null"
}
]
},
"status": {
"type": "string",
"enum": [
"active",
"expired",
"revoked"
]
},
"replaces": {
"anyOf": [
{
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
},
"name": {
"type": "string"
},
"last_4": {
"type": "string"
},
"status": {
"type": "string",
"enum": [
"active",
"expired",
"revoked"
]
}
},
"required": [
"id",
"name",
"last_4",
"status"
]
},
{
"type": "null"
}
]
},
"replaced_by": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
},
"name": {
"type": "string"
},
"last_4": {
"type": "string"
},
"status": {
"type": "string",
"enum": [
"active",
"expired",
"revoked"
]
}
},
"required": [
"id",
"name",
"last_4",
"status"
]
}
},
"capabilities": {
"type": "array",
"items": {
"type": "string",
"enum": [
"agent:operate",
"agent:publish",
"agent:engage"
]
}
},
"workspace_ids": {
"anyOf": [
{
"type": "array",
"items": {
"type": "string",
"format": "uuid",
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
}
},
{
"type": "null"
}
]
},
"created_by_delegated_grant_id": {
"anyOf": [
{
"type": "string",
"format": "uuid",
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
},
{
"type": "null"
}
]
}
},
"required": [
"id",
"name",
"last_4",
"scopes",
"created_at",
"expires_at",
"last_used_at",
"revoked_at",
"status",
"replaces",
"replaced_by"
]
},
"secret": {
"type": "string",
"minLength": 1
}
},
"required": [
"apiKey",
"secret"
]
}Errors and safe retries
Check the HTTP status and response body. A 400 validation error may contain a ZodError; handler errors use error, message and code fields. Keep request_id or x-request-id for diagnosis, without credentials. Fix 401/403 access errors before retrying, and follow Retry-After for 429. If a write is uncertain or returns 5xx, read the existing result first. Reuse an idempotency key only where supported; retry behaviour varies by operation and does not guarantee exactly-once delivery.
Troubleshooting guideExamples
These examples use fictional values checked against the schemas. Replace the IDs with ones you are authorized to use, the media with ready assets and the dates with your confirmed publishing time. Check the account’s eligibility before submitting a write. This page sends no API requests.
Set SOSOAPI_ACCESS_TOKEN on your server to a credential accepted by this operation, and keep it out of browser code. For an agent, use sosoapi auth login to sign in through the browser and let the CLI refresh its credentials.
request.json
{
"name": "example"
}cURL
curl --request POST \
"https://gqeshlawtcexsapabaui.supabase.co/functions/v1/identity-api/api-keys/create" \
-H "Authorization: Bearer $SOSOAPI_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
--data-binary @request.jsonJavaScript
// Server-side JavaScript. Do not print tokens or credential-bearing responses.
const token = process.env.SOSOAPI_ACCESS_TOKEN;
if (!token) throw new Error("Set an accepted credential for this operation");
const response = await fetch("https://gqeshlawtcexsapabaui.supabase.co/functions/v1/identity-api/api-keys/create", {
method: "POST",
headers: { "Content-Type": "application/json", Authorization: "Bearer " + token },
body: JSON.stringify({
"name": "example"
})
});
const result = await response.json();
// Check response.ok, the operation-specific body and completion state before continuing.CLI
npx sosoapi api post /identity-api/api-keys/create < request.jsonSynthetic response example
{
"apiKey": {
"id": "11111111-1111-4111-8111-111111111111",
"name": "example",
"last_4": "example",
"scopes": [],
"created_at": "2099-01-15T09:00:00Z",
"expires_at": null,
"last_used_at": null,
"revoked_at": null,
"status": "active",
"replaces": null,
"replaced_by": []
},
"secret": "example"
}