Create an API token

POST /tokens

Auth Console session Role Owner or Manager

Create a token with the given scopes. The response carries tokenValue, the secret, exactly once: store it in a secret manager, it cannot be shown again. Scopes are explicit catalogue names (GET /tokens/scopes lists them, with who may grant each and whether an expiry is required); a wildcard, a bundle name or an unknown scope is refused with SCOPE_INVALID. Some scopes are limited to an Owner (OWNER_REQUIRED), need an active membership (MEMBERSHIP_REQUIRED) or a sufficient role (INSUFFICIENT_ROLE), and some require an expiry within a maximum lifetime (EXPIRY_REQUIRED, EXPIRY_TOO_LONG): pii:read needs an Owner and expires within 90 days; jml:read expires within 365 days; supplier_template:write needs an expiry. A token cannot be created or revoked from a support session (SUPPORT_SESSION_NO_MINT). At most 20 tokens per organization. Requires a console session of an Owner or Manager.

Example

curl -X POST "https://api.autociso.io/api/v1/tokens" \
  -H "Authorization: Bearer <console-session-token>" \
  -H "Content-Type: application/json" \
  -d '{"name":"GitHub Actions SBOM upload","scopes":["sbom:write"]}'

Response 201

{
  "data": {
    "tokenId": "tok_1hgz7c0aw2mf",
    "name": "GitHub Actions SBOM upload",
    "prefix": "aci_XXXX",
    "scopes": [
      "sbom:write"
    ],
    "createdBy": "usr_1hgyq2mw7c3k",
    "createdAt": "2026-10-09T09:00:00Z",
    "updatedAt": "2026-10-09T09:00:00Z",
    "tokenValue": "aci_<redacted>"
  }
}

Request body

  • name string required
    A name that says where the token is used. minLength 1, maxLength 100
  • scopes array of string required
    Explicit scope names from GET /tokens/scopes. Unknown names, wildcards and bundle names are refused with SCOPE_INVALID. minItems 1, maxItems 40
  • expiresAt string (date-time) or null
    Future expiry. Required, within the scope maximum, for scopes whose catalogue entry has requiresExpiry (for example pii:read within 90 days, jml:read within 365 days, supplier_template:write).
  • No other fields.

Returns

The data field of the standard { data, error, meta } envelope:

  • tokenId string required
  • name string required
  • prefix string required
  • scopes array of string required
    18 values
    "sbom:read" | "sbom:write" | "mcp:read" | "mcp:write" | "supplier_template:read" | "supplier_template:write" | "pii:read" | "jml:read" | "asset:read" | "risk:read" | "supplier:read" | "iso:read" | "compliance:read" | "evidence:read" | "access_review:read" | "employee:read" | "audit_log:read" | "audit_log:verify"
  • expiresAt string (date-time)
  • revokedAt string (date-time)
  • revokedBy string
  • lastUsedAt string (date-time)
  • suspendedAt string (date-time)
    Set when the token was suspended because its creator no longer holds the role its scopes require. A suspended token is refused like a revoked one and is not resumed.
  • suspendedReason string
    Why the token was suspended.
  • activity object
    Usage of the token on the current UTC day. Absent until the token has been used.
    • day string required
      UTC date, YYYY-MM-DD.
    • requests integer required
      Requests made that day.
    • rows integer required
      Data rows returned that day.
    • distinctRoutes integer required
      Number of distinct routes called that day (capped at 50).
    • lastIp string required
      Client address of the last request.
    • lastRouteId string required
      Route template of the last request.
    • No other fields.
  • createdBy string required
  • createdAt string (date-time) required
  • updatedAt string (date-time) required
  • tokenValue string required
    The secret. Returned only in this response; send it as Authorization: Bearer <token>.
  • No other fields.

Errors

Status Code Retry Meaning
400 VALIDATION_FAILED no The body does not match the request schema (VALIDATION_FAILED), cannot be read (INVALID_BODY) or names an unknown scope (SCOPE_INVALID).
401 UNAUTHORIZED no No signed-in session. code UNAUTHORIZED.
403 OWNER_REQUIRED no Not allowed to create this token. FORBIDDEN (not an Owner or Manager, or an API token), SUPPORT_SESSION_NO_MINT (support session), OWNER_REQUIRED (the scope needs an Owner, for example pii:read), MEMBERSHIP_REQUIRED (an active membership of this organization is required) or INSUFFICIENT_ROLE (the caller role cannot grant the scope).
422 EXPIRY_REQUIRED no The request is well-formed but cannot be granted. SCOPE_UNAVAILABLE (pii:read not enabled yet), INVALID_EXPIRY (expiresAt not in the future), EXPIRY_REQUIRED, EXPIRY_TOO_LONG or TOKEN_LIMIT_EXCEEDED (20 tokens per organization).
422 TOKEN_LIMIT_EXCEEDED no The request is well-formed but cannot be granted. SCOPE_UNAVAILABLE (pii:read not enabled yet), INVALID_EXPIRY (expiresAt not in the future), EXPIRY_REQUIRED, EXPIRY_TOO_LONG or TOKEN_LIMIT_EXCEEDED (20 tokens per organization).
500 DB_ERROR no Unexpected server error. code DB_ERROR or TOKEN_GENERATION_FAILED; retry later and quote error.id if it persists.
Last reviewed: 2026-10-13

Was this page helpful?

Esc