Skip to content
Agentpost robot in sunglasses on a red circleAgentpost

Workspace keys

A workspace key is one read-only server credential for a tool that spans a workspace’s projects, such as a dashboard of every product’s activity: wk_test_… in dev and wk_live_… in prd. A project’s secret key does everything in one project; a workspace key reads in every project of its workspace, one project per request, and changes nothing. Credentials compares it with every other credential.

What it reaches

A workspace key reaches every project of its workspace that adopted a service its permissions read, in the key’s one environment. A project created after the key was issued, or one that adopts the service later, is reached with no change to the key. A deleted project, a project of another workspace, and the other environment are out of reach.

Permissions

A key holds one or more permissions, fixed when it is issued and kept by every rotation. To change them, issue another key. A key may hold:

Permission Service Reads in each project
events:read eventwolf Events by query, lookup, or sequence, the live tail, and the event type registry

events:read allows exactly these routes:

  • GET /v1/events/events, to query the history
  • GET /v1/events/events/lookup, to look up one event by source and id
  • GET /v1/events/events/{sequence}, to get one event
  • GET /v1/events/events/stream, the live tail
  • GET /v1/events/event-types and GET /v1/events/event-types/{type}, the event type registry

Apart from listing what it reaches, every other route answers forbidden. A service’s route adds what the key holds in details.permissions and the routes those allow in details.operations.

Issuing and managing

The workspace’s own routes, under /v1/workspaces/{workspaceId}/keys, issue, list, rotate, and revoke its keys. Each takes a member’s API key or session, or a delegated token:

  • Owners and admins issue, rotate, and revoke. Members only list. Roles has the rest of each role.
  • A delegate acts within its delegation when the delegation lists the apoa.workspace_key permissions it needs, such as apoa.workspace_key:issue.

A caller with no part in the workspace gets not_found. A key is issued with a name of 1 to 120 characters, such as analytics, an environment, dev or prd, its permissions, and an optional expiresAt. Agentpost shows the key once, in the answer’s key, and keeps only its hash, so a list tells keys apart by prefix. Issuing or rotating a key emails the workspace’s owners which key and who acted, never the key itself; the email is one delivery of a workspace event. A workspace key doesn’t read the workspace’s events.

Naming the project

Each request names the one project it reads in the x-agentpost-project header, by its ID, on the service’s usual paths. The answer holds that project’s records alone, as it would for the project’s own secret key, so reading several projects takes a request for each.

The SDK’s client takes the project once, as project, and sends the header on every request, including reconnects from client.events.tail(input, handlers). Its live tail and type registry pages show the calls.

A request the key can’t make answers:

Request Answer
A route its permissions don’t allow forbidden, before the header is read
No x-agentpost-project header invalid_request, with details.header
A header that isn’t a project ID invalid_request, with details.header
A project it can’t reach not_found, the same answer whether the project doesn’t exist, is deleted, or is in another workspace, so it reveals nothing about other workspaces
A project without the service not_found

Any other credential that sends x-agentpost-project answers invalid_request, unless the header names that credential’s own project.

Listing what it reaches

Get the current workspace key, GET /v1/workspace-keys/current sent with the key itself, answers with the key’s name, workspaceId, environment, permissions, and status, and, in projects, the ID and name of every project it reaches at that moment, oldest first, with no pages. The request needs no project header. A tool calls it to find the projects to read, and again to find projects added since. Another valid credential answers forbidden.

Rotation

Rotating gives you a new key with the same name, environment, permissions, and expiresAt. The request must send grace, a duration string from "0s" to "7d". A grace of "0s" stops the old key at once and requires confirm set to the key’s name. The old key becomes expired at its graceEndsAt, or earlier if it reaches its expiresAt. Rotating a key that already has a replacement, was revoked, or has expired answers conflict. The old key’s replacedBy names its replacement in the key list.

Expiry and last use

  • expiresAt is when the key stops working, if it was issued with one: a date and time with its zone, after now. A rotation keeps it, so rotating never extends a key’s life; issue a new key for that. A key issued without one works until it is revoked.
  • lastUsedAt is when the key last made a request, a refused one included, to the hour: Agentpost writes it at most once an hour, so it can be up to an hour behind. It is absent until the key’s first request. A key with an old lastUsedAt is a key to revoke.

What ends its access

A key’s status is active, grace, expired, or revoked. Only active and grace work.

  • Revoking stops it at once and can’t be undone.
  • Its expiresAt or the end of a rotation’s grace stops it at that moment.
  • Archiving its workspace stops it for good, since nobody can revoke the key after that, even while its record still says active or grace.
  • Deleting a project ends the key’s access to that project alone.

A request with a stopped key answers unauthenticated, as an unknown key does. A live tail already open stops within 30 seconds of the key stopping. It ends with an error message whose code is forbidden. A client that isn’t reading has 15 more seconds to take the error before the connection drops. Deleting the project ends its open tails at once, with no error message.

If it leaks

Until it stops, a leaked key reads every event and event type, with whatever personal data they hold, in every project of its workspace and environment that adopted the service, projects added later included. It can’t publish, change, or delete anything, and reaches no other service and no Platform route. So keep it on a server, as you would a secret key: never in a browser, an app, or a repository. Use a wk_test_ key while you build, and issue a key with expiresAt when the tool has a known end.

To stop a leaked key, revoke it. If it is still active, you can also rotate it with a grace of "0s" to replace it in one call. Use lastUsedAt to see when the API last recorded its use.

Where to act on it