Keys
A project’s keys. A secret key, sk_test_… for dev or sk_live_… for prd, is for your server: it is shown once and stored as a hash. A publishable key, pk_test_… or pk_live_…, is for a browser or a native app: it is public, works only from the origins it lists or, when it allows native apps, with no origin, and reaches only a service’s sign-in operations. The workspace’s owners get an email whenever a key is issued or rotated, or its origins or native allowance change. A workspace key, wk_test_… or wk_live_…, belongs to a workspace rather than a project: it reads every project of the workspace in its environment, within the permissions it was issued with, and is shown once, stored as a hash, and rotated like a secret key.
Paths are from https://api.agentpost.tools, and every route follows the API basics. The examples send the first credential the route takes; Credentials explains each one.
List keys
GET /v1/projects/{id}/keys
Every key of the project, oldest first, revoked ones included. Never a secret key’s secret.
- Who may call: A member of the workspace, with its API key; a member of the workspace, with its session; or a delegate, with its delegated token.
- Access: The caller holds
apoa.key:viewin the project’s workspace. - Credential: the examples send your API key,
agp_ak_apoa_…, asAuthorization: Bearer <token>.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id |
string |
Yes | A project ID, prj_…. The id of a Project. |
Response
200 OK, with:
| Name | Type | Present | Description |
|---|---|---|---|
keys |
Key array |
Always |
Errors
Any operation can also answer with the codes Conventions lists.
Issue a key
POST /v1/projects/{id}/keys
Issues a secret key, or a publishable key with the origins it works from and whether native apps may use it.
- Who may call: A member of the workspace, with its API key; a member of the workspace, with its session; or a delegate, with its delegated token.
- Access: The caller holds
apoa.key:issuein the project’s workspace. - Credential: the examples send your API key,
agp_ak_apoa_…, asAuthorization: Bearer <token>.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id |
string |
Yes | A project ID, prj_…. The id of a Project. |
Body
| Name | Type | Required | Description |
|---|---|---|---|
name |
string |
Yes | What it is for, such as render. |
environment |
"dev" or "prd" |
Yes | dev for development and tests, prd for production. |
kind |
string |
No | Default "secret". One of "secret" or "publishable". |
allowedOrigins |
string[] |
No | A publishable key only: each origin as a browser sends it, such as https://app.example.com. No path or wildcard. http works only on localhost, 127.0.0.1, or [::1], for a dev key. Required, with 1 to 20 origins, unless the key allows native apps, when it may be left out or empty; up to 20 items. |
allowNativeApps |
boolean |
No | A publishable key only: true lets a native app, such as an iOS, Android, or Expo app, use the key with no Origin header. A request that sends an Origin is still held to allowedOrigins; default false. |
Response
201 Created, with:
| Name | Type | Present | Description |
|---|---|---|---|
key |
string |
Always | The key itself. A secret key is shown once. |
record |
Key |
Always |
Errors
Any operation can also answer with the codes Conventions lists.
Rotate a key
POST /v1/projects/{id}/keys/{keyId}/rotate
Replaces a secret key with a new one of the same name and environment. Set grace to say how long the old key keeps working. The answer gives its graceEndsAt in previous. A grace of 0s stops the old key at once and needs the key’s name as confirmation. To replace a publishable key, issue a new one and revoke the old one.
- Who may call: A member of the workspace, with its API key; a member of the workspace, with its session; or a delegate, with its delegated token.
- Access: The caller holds
apoa.key:rotatein the project’s workspace. - Credential: the examples send your API key,
agp_ak_apoa_…, asAuthorization: Bearer <token>.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id |
string |
Yes | A project ID, prj_…. The id of a Project. |
keyId |
string |
Yes | A key ID, key_…. The id of a Key. |
Body
| Name | Type | Required | Description |
|---|---|---|---|
grace |
string |
Yes | A duration from 0s to 7d. |
confirm |
string |
No | The key’s name, required when grace is 0s. |
Response
201 Created, with:
| Name | Type | Present | Description |
|---|---|---|---|
key |
string |
Always | The new key. Shown once. |
record |
Key |
Always | |
previous |
Key |
Always |
Errors
confirmation_required(400)conflict(409)forbidden(403)not_found(404)
Any operation can also answer with the codes Conventions lists.
Update a publishable key
PATCH /v1/projects/{id}/keys/{keyId}
Changes who may use a publishable key: its allowed origins, whether native apps may use it, or both. A field left out keeps its value, and the key must still allow an origin or native apps. The change takes effect on the next request, so the site or app the key is built into needs no new release.
- Who may call: A member of the workspace, with its API key; a member of the workspace, with its session; or a delegate, with its delegated token.
- Access: The caller holds
apoa.key:issuein the project’s workspace. - Credential: the examples send your API key,
agp_ak_apoa_…, asAuthorization: Bearer <token>.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id |
string |
Yes | A project ID, prj_…. The id of a Project. |
keyId |
string |
Yes | A key ID, key_…. The id of a Key. |
Body
| Name | Type | Required | Description |
|---|---|---|---|
allowedOrigins |
string[] |
No | The whole new list. Empty only for a key that allows native apps; up to 20 items. |
allowNativeApps |
boolean |
No | Whether a native app, which sends no Origin, may use the key. |
Response
200 OK, with:
| Name | Type | Present | Description |
|---|---|---|---|
record |
Key |
Always |
Errors
Any operation can also answer with the codes Conventions lists.
Revoke a key
DELETE /v1/projects/{id}/keys/{keyId}
Revokes a key at once. Every request with it fails from then on, and so do user tokens it minted.
- Who may call: A member of the workspace, with its API key; a member of the workspace, with its session; or a delegate, with its delegated token.
- Access: The caller holds
apoa.key:revokein the project’s workspace. - Credential: the examples send your API key,
agp_ak_apoa_…, asAuthorization: Bearer <token>.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id |
string |
Yes | A project ID, prj_…. The id of a Project. |
keyId |
string |
Yes | A key ID, key_…. The id of a Key. |
Response
200 OK, with:
| Name | Type | Present | Description |
|---|---|---|---|
record |
Key |
Always |
Errors
Any operation can also answer with the codes Conventions lists.
List workspace keys
GET /v1/workspaces/{workspaceId}/keys
Every key of the workspace, in both environments, oldest first, revoked ones included. Never a secret.
- Who may call: A member of the workspace, with its API key; a member of the workspace, with its session; or a delegate, with its delegated token.
- Access: The caller holds
apoa.workspace_key:viewin the workspace. A workspace the caller has no part in is not found. - Credential: the examples send your API key,
agp_ak_apoa_…, asAuthorization: Bearer <token>.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
workspaceId |
string |
Yes | A workspace ID, wsp_…. It is workspace.id in the answer to Sign up. |
Response
200 OK, with:
| Name | Type | Present | Description |
|---|---|---|---|
keys |
WorkspaceKey array |
Always |
Errors
Any operation can also answer with the codes Conventions lists.
Issue a workspace key
POST /v1/workspaces/{workspaceId}/keys
Issues a workspace key, which reads every project of the workspace in one environment, those added later included, within its permissions. Its permissions are fixed when it is issued; to change them, issue another key. The workspace’s owners get an email.
- Who may call: A member of the workspace, with its API key; a member of the workspace, with its session; or a delegate, with its delegated token.
- Access: The caller holds
apoa.workspace_key:issuein the workspace. A workspace the caller has no part in is not found. - Credential: the examples send your API key,
agp_ak_apoa_…, asAuthorization: Bearer <token>.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
workspaceId |
string |
Yes | A workspace ID, wsp_…. It is workspace.id in the answer to Sign up. |
Body
| Name | Type | Required | Description |
|---|---|---|---|
name |
string |
Yes | What it is for, such as analytics. |
environment |
"dev" or "prd" |
Yes | dev for development and tests, prd for production. |
permissions |
"events:read"[] |
Yes | What the key may do, one or more; at least 1. |
expiresAt |
string |
No | When the key stops working, after now. Left out, it works until it is revoked. |
Response
201 Created, with:
| Name | Type | Present | Description |
|---|---|---|---|
key |
string |
Always | The key itself. Shown once. |
record |
WorkspaceKey |
Always |
Errors
Any operation can also answer with the codes Conventions lists.
Rotate a workspace key
POST /v1/workspaces/{workspaceId}/keys/{workspaceKeyId}/rotate
Replaces a workspace key with a new one of the same name, environment, permissions, and expiresAt. Set grace to say how long the old key keeps working. The answer gives its graceEndsAt in previous. A grace of 0s stops the old key at once and needs the key’s name as confirmation.
- Who may call: A member of the workspace, with its API key; a member of the workspace, with its session; or a delegate, with its delegated token.
- Access: The caller holds
apoa.workspace_key:rotatein the workspace. A workspace the caller has no part in is not found. - Credential: the examples send your API key,
agp_ak_apoa_…, asAuthorization: Bearer <token>.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
workspaceId |
string |
Yes | A workspace ID, wsp_…. It is workspace.id in the answer to Sign up. |
workspaceKeyId |
string |
Yes | A workspace key ID, wkey_…. The id of a WorkspaceKey. |
Body
| Name | Type | Required | Description |
|---|---|---|---|
grace |
string |
Yes | A duration from 0s to 7d. |
confirm |
string |
No | The key’s name, required when grace is 0s. |
Response
201 Created, with:
| Name | Type | Present | Description |
|---|---|---|---|
key |
string |
Always | The new key. Shown once. |
record |
WorkspaceKey |
Always | |
previous |
WorkspaceKey |
Always |
Errors
confirmation_required(400)conflict(409)forbidden(403)not_found(404)
Any operation can also answer with the codes Conventions lists.
Revoke a workspace key
DELETE /v1/workspaces/{workspaceId}/keys/{workspaceKeyId}
Revokes a workspace key at once. Every new request with it fails from then on, and a live tail it opened stops within two heartbeats, 30 seconds by default. A revoked key can’t be restored.
- Who may call: A member of the workspace, with its API key; a member of the workspace, with its session; or a delegate, with its delegated token.
- Access: The caller holds
apoa.workspace_key:revokein the workspace. A workspace the caller has no part in is not found. - Credential: the examples send your API key,
agp_ak_apoa_…, asAuthorization: Bearer <token>.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
workspaceId |
string |
Yes | A workspace ID, wsp_…. It is workspace.id in the answer to Sign up. |
workspaceKeyId |
string |
Yes | A workspace key ID, wkey_…. The id of a WorkspaceKey. |
Response
200 OK, with:
| Name | Type | Present | Description |
|---|---|---|---|
record |
WorkspaceKey |
Always |
Errors
Any operation can also answer with the codes Conventions lists.
Get the current workspace key
GET /v1/workspace-keys/current
What a workspace key reaches now: the key, and its workspace’s projects that it can read, those added after it was issued included. Name one of them in the x-agentpost-project header of each request the key makes to a service, such as GET /v1/events/events.
- Who may call: A workspace key.
- Access: The workspace key itself,
wk_test_…orwk_live_…. Any other credential is refused. - Credential: the examples send a
devworkspace key,wk_test_…, asAuthorization: Bearer <token>.
Response
200 OK, with:
| Name | Type | Present | Description |
|---|---|---|---|
key |
object |
Always | |
key. |
string |
Always | A workspace key ID, wkey_…. |
key. |
string |
Always | |
key. |
string |
Always | |
key. |
"dev" or "prd" |
Always | dev for development and tests, prd for production. |
key. |
"events:read"[] |
Always | |
key. |
string |
Always | Only keys with an active or grace status work. After rotation, the old key has grace until graceEndsAt, or until expiresAt if it comes first. A key becomes expired at either deadline. One of "active", "grace", "expired", or "revoked". |
key. |
string |
When set | After a rotation: when this key stops working. |
key. |
string |
When set | When it stops working, if it was issued to expire. |
projects |
object[] |
Always | The workspace’s projects, oldest first, that aren’t deleted and adopted a service the key’s permissions read, as of this call. |
projects[]. |
string |
Always | A project ID, prj_…. |
projects[]. |
string |
Always |
Errors
forbidden(403)
Any operation can also answer with the codes Conventions lists.
The Key object
A key as a list shows it: never a secret key’s secret.
| Name | Type | Present | Description |
|---|---|---|---|
id |
string |
Always | A key ID, key_…. |
projectId |
string |
Always | |
environment |
"dev" or "prd" |
Always | dev for development and tests, prd for production. |
kind |
string |
Always | One of "secret" or "publishable". |
name |
string |
Always | What the key is for, such as render. |
prefix |
string |
Always | The key without its secret, to tell keys apart. A publishable key’s prefix is the whole key. |
key |
string |
When set | A publishable key in full, since it is public. |
allowedOrigins |
string[] |
When set | Where a publishable key works from in a browser. Empty only for a key that allows native apps. |
allowNativeApps |
boolean |
When set | A publishable key only: true when a native app, which sends no Origin, may use it. |
status |
string |
Always | Only keys with an active or grace status work. After rotation, the old key has grace until graceEndsAt, then expired. One of "active", "grace", "expired", or "revoked". |
createdAt |
string |
Always | An ISO 8601 date and time. |
revokedAt |
string |
When set | An ISO 8601 date and time. |
graceEndsAt |
string |
When set | After a rotation: when this key stops working. |
rotatedFrom |
string |
When set | The key this one replaced. |
replacedBy |
string |
When set | The key that replaced this one. |
The WorkspaceKey object
A workspace key as a list shows it: never its secret. It reads every project of its workspace in its environment, within its permissions.
| Name | Type | Present | Description |
|---|---|---|---|
id |
string |
Always | A workspace key ID, wkey_…. |
workspaceId |
string |
Always | |
environment |
"dev" or "prd" |
Always | dev for development and tests, prd for production. |
name |
string |
Always | What the key is for, such as analytics. |
permissions |
"events:read"[] |
Always | What the key may do, fixed when it is issued. events:read: Reads each project’s events and event types: query, lookup, one event, the live tail, and the type registry; at least 1. |
prefix |
string |
Always | The key without its secret, wk_test_… or wk_live_…, to tell keys apart. |
status |
string |
Always | Only keys with an active or grace status work. After rotation, the old key has grace until graceEndsAt, or until expiresAt if it comes first. A key becomes expired at either deadline. One of "active", "grace", "expired", or "revoked". |
createdAt |
string |
Always | An ISO 8601 date and time. |
expiresAt |
string |
When set | When it stops working, if it was issued to expire. |
lastUsedAt |
string |
When set | When it last made a request. Written at most once an hour, so it can be up to an hour behind. Absent until its first request. |
revokedAt |
string |
When set | An ISO 8601 date and time. |
graceEndsAt |
string |
When set | After a rotation: when this key stops working. |
rotatedFrom |
string |
When set | The key this one replaced. |
replacedBy |
string |
When set | The key that replaced this one. |