Access tokens — K8 HQ Sign-in API
Access tokens operations for K8 HQ Sign-in API. Requests, permissions and responses.
Version 1OpenAPI description (JSON)
Before making requests, read the authentication and request requirements.
Create and revoke your own access tokens for scripts, AI agents and integrations. Owners and admins can also list and revoke any token in the organization.
Base URL
| Base URL | For |
https://api.k8hq.com/auth | The K8 HQ web app, and programs acting with a person's session |
Endpoints
Access tokens
List my tokens
GET/v1/account/tokens
The person's access tokens in every organization (never their secrets), and per organization what they may give a new one. Bounded HTTP descendants are returned in pages of at most 8 evaluated index rows. Follow nextCursor even when a page has no matching tokens. Send it as cursor on the same listing; each agent page rechecks current authority. Legacy token metadata appears on the first page.
For a person's own session (x-k8hq-token) only: assistants' delegated tokens and API tokens are refused.
Parameters
| Name | Type | Description |
cursor (query) | string | Continuation for this exact user, organization, app and listing action; grants no authority. |
orgId (query) | string | Agent requests select one organization. Required when the issuer covers multiple organizations; humans retain their account-wide listing. |
Response body (JSON)
| Field | Type | Description |
orgs required | object[] | |
tokens required | Token[] | |
nextCursor | string | Omitted only when descendant enumeration is complete. |
Responses
| Status | Body | Meaning |
| 200 | JSON | Their tokens and organizations. |
| 400 | application/problem+json | The request is malformed or a field is invalid (invalid). |
| 401 | application/problem+json | No session, or it expired or was revoked (unauthenticated): refresh, or sign in again. |
| 403 | application/problem+json | Not allowed (forbidden): an assistant's delegated token, or a browser origin other than the web app's. |
| 405 | application/problem+json | Method not allowed. The Allow header lists supported methods. |
| 500 | application/problem+json | A temporary problem (unavailable); retry. |
Create a token
POST/v1/account/tokens
Makes an access token for the person in one organization, for the content API (api), mail apps (imap, smtp) or both. A token acts for its member with the member's current access, never more: every scope must be one they may give (see issuable in List my tokens), and every container one they're in. A person may have 20 tokens.
preset: "email": a mail app on one inbox (inboxId): scopes imap, smtp, messages:read, messages:write, messages:send; no expiry unless expiresInDays says otherwise.preset: "custom": the scopes given, narrowed to containerIds, expiring in 90 days unless expiresInDays says otherwise.
The secret (k8hq_<token ID>_<secret>) is in this answer only; K8 HQ keeps just a hash.
When personal app admission is enabled, an app bearer credential may create only a bounded personal HTTP descendant with Idempotency-Key, preset: "custom", orgId, and either an explicit permission/capability ceiling or supported named-container HTTP scopes. Expiry defaults to 30 days, accepts 1–90 days, and cannot exceed the original human authorization deadline. The complete requested-resource capture supports at most 20 distinct named resources and may refuse a unit that cannot fit the single 100-item capture. Browser issuers need no manual_copy flow. The first confirmed acceptance returns a copy-once k8m1_ secret; replay/status return only safe token metadata. Legacy mail protocols, unbounded expiry and legacy presets are unsupported for app issuers.
Needs a passkey confirmation of this change (x-k8hq-confirm: token.create). Until confirmations are enforced, a passkey sign-in in the last five minutes also works. The API-token scope tags:create is an explicit choice, never part of a preset. Only a current owner or admin who holds tags.create can grant it. It always needs a passkey confirmation naming the new token. Each create checks the member’s current role and permission again and the token can create up to 50 tags. To give this scope to an existing token, create a new token.
For a person's own session (x-k8hq-token) only: assistants' delegated tokens and API tokens are refused. The session needs a recent passkey: if its last passkey confirmation is more than 5 minutes old, the answer is 401 step_up_required.
Parameters
| Name | Type | Description |
x-amz-content-sha256 (header) required | string | The body's SHA-256, lowercase hex. CloudFront signs requests to this service and refuses a POST without it (403, not a problem detail). For {}: 44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a. |
Request body (JSON)
| Field | Type | Description |
preset required | email | custom | |
containerIds | string[] | For custom: containers to narrow it to, all in the organization. |
expiresInDays | integer | 1 to 3650; -1 for never; 0 or absent for the preset's default. |
inboxId | string | For email: the inbox the mail app signs in to. |
label | string | Up to 100 characters; defaults to mail app or token. |
orgId | string | The organization; may be left out when containerIds or inboxId name it. |
scopes | string[] | For custom. |
{"containerIds":["ibx_01J..."],"expiresInDays":30,"label":"Backup script","orgId":"org_01J...","preset":"custom","scopes":["api","messages:read"]}
Response body (JSON)
| Field | Type | Description |
secret required | string | The full token to send as Authorization: Bearer. Pattern: ^k8hq_tok_. |
token required | Token | |
Responses
| Status | Body | Meaning |
| 200 | JSON | The token and, this once, its secret. |
| 400 | application/problem+json | The request is malformed or a field is invalid (invalid). |
| 401 | application/problem+json | No session or it expired (unauthenticated), or confirm this change with your passkey (confirmation_required; until confirmations are enforced, step_up_required with action, which a passkey use in the last 5 minutes also satisfies): the answer carries the action to confirm and a short summary. |
| 403 | application/problem+json | They can't make tokens in the organization, or give one of the scopes (forbidden); or a delegated token or foreign origin. |
| 404 | application/problem+json | They have no access to a container, or aren't a member (not_found). |
| 405 | application/problem+json | Method not allowed. The Allow header lists supported methods. |
| 409 | application/problem+json | They have 20 tokens already, their access to the inbox needs updating, or who can do what in the organization changed meanwhile (conflict). |
| 500 | application/problem+json | A temporary problem (unavailable); retry. |
Revoke my token
DELETE/v1/account/tokens/{id}
Revokes one of the person's own tokens; it stops working at once.
For a person's own session (x-k8hq-token) only: assistants' delegated tokens and API tokens are refused.
Parameters
| Name | Type | Description |
x-amz-content-sha256 (header) required | string | The body's SHA-256, lowercase hex. CloudFront signs requests to this service and refuses a POST without it (403, not a problem detail). For {}: 44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a. |
id (path) required | string | Resource ID. |
Response body (JSON)
| Field | Type | Description |
ok required | true | |
Responses
| Status | Body | Meaning |
| 200 | Ok | Revoked. |
| 400 | application/problem+json | The request is malformed or a field is invalid (invalid). |
| 401 | application/problem+json | No session, or it expired or was revoked (unauthenticated): refresh, or sign in again. |
| 403 | application/problem+json | Not allowed (forbidden): an assistant's delegated token, or a browser origin other than the web app's. |
| 404 | application/problem+json | Not one of their tokens (not_found). |
| 405 | application/problem+json | Method not allowed. The Allow header lists supported methods. |
| 409 | application/problem+json | Who can do what in the organization changed meanwhile (conflict): nothing was revoked; try again. |
| 500 | application/problem+json | A temporary problem (unavailable); retry. |
List an organization's tokens
GET/v1/organizations/{orgId}/tokens
Every token in the organization, for its owners and admins (tokens.manage_all). Bounded HTTP descendants are returned in pages of at most 8 evaluated index rows. Follow nextCursor even when a page has no matching tokens. Send it as cursor on the same listing; each agent page rechecks current authority. Legacy token metadata appears on the first page.
For a person's own session (x-k8hq-token) only: assistants' delegated tokens and API tokens are refused.
Parameters
| Name | Type | Description |
orgId (path) required | string | Organization ID. |
cursor (query) | string | Continuation for this exact user, organization, app and listing action; grants no authority. |
Response body (JSON)
| Field | Type | Description |
tokens required | OrgToken[] | |
nextCursor | string | Omitted only when descendant enumeration is complete. |
Responses
| Status | Body | Meaning |
| 200 | JSON | The tokens. |
| 400 | application/problem+json | The request is malformed or a field is invalid (invalid). |
| 401 | application/problem+json | No session, or it expired or was revoked (unauthenticated): refresh, or sign in again. |
| 403 | application/problem+json | They can't see the organization's tokens (forbidden). |
| 405 | application/problem+json | Method not allowed. The Allow header lists supported methods. |
| 500 | application/problem+json | A temporary problem (unavailable); retry. |
Revoke an organization's token
DELETE/v1/organizations/{orgId}/tokens/{id}
Revokes any token in the organization, for its owners and admins. Only owners revoke an owner's tokens.
For a person's own session (x-k8hq-token) only: assistants' delegated tokens and API tokens are refused.
Parameters
| Name | Type | Description |
x-amz-content-sha256 (header) required | string | The body's SHA-256, lowercase hex. CloudFront signs requests to this service and refuses a POST without it (403, not a problem detail). For {}: 44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a. |
orgId (path) required | string | Organization ID. |
id (path) required | string | Resource ID. |
Response body (JSON)
| Field | Type | Description |
ok required | true | |
Responses
| Status | Body | Meaning |
| 200 | Ok | Revoked. |
| 400 | application/problem+json | The request is malformed or a field is invalid (invalid). |
| 401 | application/problem+json | No session, or it expired or was revoked (unauthenticated): refresh, or sign in again. |
| 403 | application/problem+json | They can't revoke it (forbidden). |
| 404 | application/problem+json | No such token in the organization (not_found). |
| 405 | application/problem+json | Method not allowed. The Allow header lists supported methods. |
| 409 | application/problem+json | Who can do what in the organization changed meanwhile (conflict): nothing was revoked; try again. |
| 500 | application/problem+json | A temporary problem (unavailable); retry. |