Skip to content
OAOpenAppPhysical Security as a Service
Login

API Keys

Endpoints under the API Keys tag manage long-lived bearer tokens for automation (scoped service accounts). The active org is implied by the calling principal’s session or API key — there is no separate X-Org selector on these routes. Shapes follow ApiKeyListItem, CreateApiKeyRequest, CreateApiKeyResponse, and UpdateApiKeyRequest in the API reference.

For how credentials are sent on the wire, see Authentication. POST /api-keys returns CreateApiKeyResponse including the full secret token once — store it immediately; later GET /api-keys only returns token_suffix and metadata.

ConcernHTTPoperationIdNotes
ListGET /api-keyslist_api_keysArray of ApiKeyListItem.
MintPOST /api-keyscreate_api_keyBody CreateApiKeyRequest: required name, optional expires_at (RFC3339) or expires_in (duration string), scoped_roles, scoped_entity_ids. 201 + CreateApiKeyResponse.
Rename / expiryPATCH /api-keys/{id}update_api_keyBody UpdateApiKeyRequest. 204 empty body on success.
RevokeDELETE /api-keys/{id}revoke_api_keySoft revoke — 204.
RestorePOST /api-keys/{id}/restorerestore_api_key204 when un-revoking.
PurgeDELETE /api-keys/{id}/purgepurge_api_keyHard delete — 409 if the key is not revoked first.
CapabilityPythonRust (openapp_sdk)GoTypeScript (AsyncClient)
Full lifecycleclient.api_keyslist, create, update, revoke, restore, purgeclient.api_keys() — same method namesAPIKeysAPI (generated)Not on façade — use transport / another SDK

Python create accepts convenience kwargs (label, scopes) plus any CreateApiKeyRequest fields via extra keywords — e.g. name, expires_in, scoped_roles — merged into the JSON body.

401 when not authenticated.403 on create without api_keys:create (see server roles).404 on unknown key ids.409 when purge runs on an active key.400 on invalid expiry / scope payloads — see Errors & retries.

keys = await client.api_keys.list()
created = await client.api_keys.create(
name="Automation key",
expires_in="90d",
scoped_roles=["devices:list"],
)
token = created["token"]

Persist token immediately; it is not returned again on later list calls.

Rename or extend expiry (PATCH /api-keys/{id})

Section titled “Rename or extend expiry (PATCH /api-keys/{id})”

Body UpdateApiKeyRequest — required name, optional expires_at (RFC3339) xor expires_in (duration string). Server returns 204 with an empty body.

await client.api_keys.update(
key_id,
name="Automation key (rotated)",
expires_in="180d",
)

Revoke, restore, purge (DELETE / POST lifecycle)

Section titled “Revoke, restore, purge (DELETE / POST lifecycle)”

revoke_api_key soft-revokes (the row stays for audit/restore); restore_api_key un-revokes; purge_api_key hard-deletes and returns 409 if the key has not been revoked first. All return 204 on success.

await client.api_keys.revoke(key_id)
restored = await client.api_keys.restore(key_id)
await client.api_keys.purge(key_id)