Skip to main content
Send every credential as a bearer token:
Each endpoint page has a Who can call line: the credentials it takes, the least role it needs in the organization, and the permission a managing key needs. The OpenAPI spec has the same in each endpoint’s x-onecli-access field.

The four credentials

A few endpoints take no credential at all, such as GET /v2/skill and the first two agent sign-up calls. An agent never needs a managing key. Keep managing keys with people and their own scripts, and give each agent its own credential.

Managing keys

A managing key is the credential for your own scripts. Make one in the dashboard at Settings > API keys. The key is shown once. A managing key:
  • Acts as you. It reaches the vaults you can use and stops working when you leave the organization.
  • Belongs to one organization. You do not send an organization header with it.
  • Carries one or both of two permissions. manage covers every call that takes a key, except listing and answering approvals. approve covers listing and answering approvals, and nothing else. A key without the permission a call needs gets 403 with the detail key_permission. A new key has manage unless you choose otherwise.
  • Expires after 90 days unless you set another expiry.
  • Cannot make another key. Making a key takes a signed-in session.
An older API key, which starts with oc_ and has none of the three prefixes above, still works as a managing key.

Agent credentials

An agent credential belongs to one agent on one vault. The agent uses it to reach the gateway. On this API it opens the Agent self-service endpoints and nothing else. On an endpoint for a person, an agent credential answers 403 with the detail person_required. The credential is valid, so signing in again does not help. Use a managing key or a session for that call.
The reverse is a 401: an agent self-service endpoint answers unauthenticated to a managing key, a connect token or a session.

Session-only endpoints

Some endpoints take a signed-in session and refuse every key. Examples are making a key, renaming or deleting the organization, reading the audit log, approving an agent sign-up, and the organization’s shared items. A managing key there answers 403 with the detail session_required. The Who can call line on each of these pages says so. A few changes need a session on an endpoint that otherwise takes a key: leaving an organization, making someone an owner or changing an owner’s role, and letting a member sign in without single sign-on. With a key, they answer the same 403 with session_required.

When a credential is missing or wrong

Every 401 carries the same headers, whatever was sent:
On /v2, the error body adds docUrl, the page that says how an agent gets a credential:
resource_metadata is RFC 9728 protected resource metadata. It names auth.md as resource_documentation, and no authorization server yet. On a self-host, these addresses use your own API address. See Sign up as an agent. A 401 with a credential that worked before means it stopped: it expired, or it was revoked or disconnected. Don’t retry with it.

Idempotency-Key

A POST that takes a managing key or a session accepts an optional Idempotency-Key header, 1 to 255 visible characters:
A retry with the same key, path and body returns the first answer for 24 hours, with Idempotent-Replayed: true. The same key with another path or body is 422 idempotency_conflict. The same key while the first call runs is 409. A POST whose answer shows a secret once, and every POST that takes an agent credential, a connect token or no credential, refuses the header with 400.

Next steps