Managing API keys

These endpoints let your code look after API keys the way the console's API Keys page does. Use them to give each deploy its own short-lived key, or to rotate a key on a schedule.

Permissions

They need a key with the keys:write permission, the API keys write box in the console. It's off by default, and keys made before permissions existed don't have it. For a key that can only list keys, tick the API keys read box, or pass keys:read. A key without it gets a 403 naming the permission. See Key permissions.

  • A key can't give out more than it has. A key it creates can't have a permission it lacks, or expire later than it does.
  • A key it creates gets the same content filtering as itself.
  • A key belongs to the person who created it, and so do the keys it creates.
  • An organisation owner's key can manage every key in the organisation. Anyone else's key can manage only their own keys.
  • Once the person who created a key leaves your organisation, it can't manage keys any more.

List your keys

GET /api/v1/api-keys lists every key in your organisation, newest first.

curl
curl https://api.pendra.ai/api/v1/api-keys \
  -H "Authorization: Bearer pdr_sk_..."
[
  {
    "id": "5b1f8c1e-7a2d-4c39-9f0e-2d4b8a6c1e77",
    "name": "deploy-2026-11-30",
    "key_prefix": "pdr_sk_Xk3v9Qa",
    "created_at": "2026-11-30T09:12:44Z",
    "last_used_at": "2026-11-30T09:15:02Z",
    "expires_at": "2026-12-07T00:00:00Z",
    "scopes": ["inference:write", "models:read"],
    "owner_email": "ops@example.com",
    "is_own": true,
    "owner_is_member": true,
    "created_by_api_key_id": "0c7e2a91-3b5d-4f60-8e1a-9d2c4b6f8a03",
    …
  }
]
FieldWhat it means
key_prefixThe start of the key, to tell keys apart. Never the whole key.
scopesWhat the key can do. See Key permissions.
is_owntrue when the key belongs to the same person as the key making the request.
owner_is_memberfalse once the person who created the key has left your organisation. The key still works for inference.
created_by_api_key_idThe key that created this one, when a key did. Kept after that key is revoked.
rotated_by_api_key_idThe key that last rotated this one, when a key did. That key was given this key's current secret.

Create a key

POST /api/v1/api-keys with a name, and optionally expires_at and scopes. Leave out scopes for a key that can call and list models, which the key making the request needs to hold itself. Leave out expires_at and the new key expires when the key making the request does.

curl
curl https://api.pendra.ai/api/v1/api-keys \
  -H "Authorization: Bearer pdr_sk_..." \
  -H "Content-Type: application/json" \
  -d '{"name":"deploy-2026-11-30","expires_at":"2026-12-07T00:00:00Z","scopes":["inference:write","models:read"]}'

You get 201 and the key's details, with the whole key in key. It's shown only this once, so store it straight away.

Rotate a key

POST /api/v1/api-keys/{key_id}/rotate gives a key a new secret, in key. The old secret stops working at once. The key's name, permissions, expiry and settings stay the same, and so does its usage history.

curl
curl -X POST https://api.pendra.ai/api/v1/api-keys/5b1f8c1e-7a2d-4c39-9f0e-2d4b8a6c1e77/rotate \
  -H "Authorization: Bearer pdr_sk_..."

A key can rotate itself. It can rotate another key only if it could have created that key, so it can never get hold of a key that can do more than it can.

Rotating or revoking a key doesn't undo what it did. If a key that can manage keys leaks, also deal with the keys it touched:

  • Revoke the keys whose created_by_api_key_id is its id. The console marks them "Made by" that key.
  • Rotate the keys whose rotated_by_api_key_id is its id, since it holds their secrets. The console marks them "Rotated by" that key.

Revoke a key

DELETE /api/v1/api-keys/{key_id} revokes a key at once and returns 204. Its usage history stays. A key can revoke another key only if it has every permission that key has, so a leaked narrow key can't take a wider one offline.

curl
curl -X DELETE https://api.pendra.ai/api/v1/api-keys/5b1f8c1e-7a2d-4c39-9f0e-2d4b8a6c1e77 \
  -H "Authorization: Bearer pdr_sk_..."

Errors

  • 400: an unknown permission name, or an empty scopes list.
  • 403: the key lacks keys:write, its creator has left your organisation, or the key you asked to create, rotate or revoke has a permission this one doesn't. Creating and rotating also refuse a later expiry or different content filtering.
  • 409: a key rotating itself lost to another rotation of the same key. Use the secret that request got.
  • 422: a missing name, or an expires_at in the past.
  • 404: no key with that id in your organisation, or one this key can't manage.
Renaming a key and changing its content filtering stay in the console. See Authentication.