App keys
Make keys that reach only one app or service, read-only if you like, with a spending limit.
App keys (ocps_…) are for agents, scripts and servers that should only touch one app. Only a workspace key can make, change or revoke them. See Keys and spending limits for how limits work.
The key object
{
"id": "key_…",
"object": "scoped_key",
"name": "Report agent",
"app_id": "app_…",
"service_id": "svc_…",
"access": "read",
"start": "ocps_3fQ1x",
"created_at": "…",
"last_used_at": null,
"spend_limit": "5.000000",
"spent": "0.000000"
}Make a key
POST /api/v1/apps/{id}/keys
Prop
Type
Returns 201 with the key object plus key: the secret itself, shown only this once.
Keys made by keys
An app key can make keys too, for the sub-agents it hands work to, but never broader than itself:
- only for its own app (a workspace key can make keys for any app);
- read-only if it's read-only itself;
- within its spending limit, if it has one (see below).
Anything else is 403 key_out_of_scope, with the reason. A key that made other keys can change their limits or revoke them, and revoke itself, but no other keys.
Keys with a spending limit only make things safer
Any key with a spending limit of its own, workspace key or app key, can only tighten things. Otherwise an agent could give itself room you never gave it. Such a key:
- can add a spending limit or lower one (on an app, an end user, the end-user default or another key), but not raise or remove one;
- can make read-only keys freely, but a key that can change things only with a spending limit of its own, no higher than what it has left;
- can pause an app, but not resume it;
- can list, test, rename and turn off webhooks, but not add one or change where one sends or what it sends.
A key's limit covers everything spent by the keys it made, and by the keys they made, revoked ones included. So handing a sub-agent a key never gets round a limit: when the family reaches it, every key in it is stopped. A key below with its own, smaller limit stops at that one first.
Anything else gets 403 limited_key, saying what the key may still do. You can always do these yourself in the dashboard, or with a key that has no limit. Over MCP, the tools that give an agent more room (create_app_key, set_app_spend_limit, set_end_user_spend_limit, pause_app, resume_app, create_webhook) are marked to ask you first.
List, limit or revoke
| Endpoint | What it does |
|---|---|
GET /api/v1/apps/{id}/keys | The app's keys, newest first, with what each has spent. Secrets are never shown. |
PATCH /api/v1/apps/{id}/keys/{keyId} | Set spend_limit (dollars), or null to remove it. |
DELETE /api/v1/apps/{id}/keys/{keyId} | Revoke it, at once. |
What a key can reach
| Key | Can call |
|---|---|
| Workspace key | Everything. |
| App key | /api/v1/apps/{its app} and everything under it. |
| App key for one service | /api/v1/apps/{app}/services/{its service} and everything under it. Look the service up by id, not by name. |
| Read-only | Only GET, and SQL that only reads (Data), within the above. |
Workspace-wide calls (/workspace, /balance, /usage, /prices, and listing or creating apps) need a workspace key. An app key sees its own app's usage at GET /api/v1/apps/{id}/usage.
opencloudport