API Tokens
Scoped, expiring tokens for scripts, CLIs and CI pipelines, so integrations never use a personal login. A token acts as its owner, but only on the endpoints its scopes open.
Why API Tokens
A JWT belongs to a person: it needs a password login (and MFA), it expires after 1 hour and it carries every permission of that user. API tokens are made for machines: an admin creates one per integration, gives it only the scopes it needs, an expiry of up to one year, and can revoke it at any time without touching any user account.
Creating a Token
Admins open API Tokens (/dashboard/admin/api-tokens) in the Platform section of the navigation, right after Audit Log, and click Create token. Managers and viewers do not see the page, and the token API itself answers 403 to them.
- Name: what the token is for (e.g. gitlab-sbom).
- Owner: an existing active user, or a new service account created together with the token. A service account is a non-human user (username of your choice, email <username>@service-accounts.invalid) created with an unusable password, so it cannot sign in with a password; it gets the manager role when the token has at least one write:* scope, viewer otherwise (never admin at creation). It appears in User Management like any user: changing its role there changes what every token it owns can do.
- Scopes: one or more of read:inventory, read:security, write:security, write:sbom.
- Validity: 1 to 365 days (API_TOKEN_MAX_DAYS), 90 by default. Every token expires.
Warning: The token value (idpt_...) is shown once, in the dialog right after creation, with a copy button. AsPeekIt stores only its SHA-256 hash and the first 8 characters (the prefix shown in the table), so a lost token cannot be shown again: revoke it and create a new one.
# Same thing through the API (admin JWT)
curl -X POST https://idp.example.com/api/v1/auth/api-tokens/ \
-H "Authorization: Bearer {admin_access_token}" \
-H "Content-Type: application/json" \
-d '{"name": "gitlab-sbom", "scopes": ["write:sbom"], "service_account": "ci-gitlab", "expires_in_days": 180}'
# For an existing user, send "owner": <user id> instead of "service_account".
# 201 response: the token metadata plus "token": "idpt_..." (only here)
Using a Token
Send the token in the Authorization header with the Token scheme. The request runs as the token owner, so the role checks still apply: the effective permission is the token scope intersected with the owner role (a write:security token owned by a viewer cannot triage findings).
curl https://idp.example.com/api/v1/security/findings/?severity=critical \
-H "Authorization: Token $IDP_API_TOKEN"Scopes and Endpoints
read covers GET, HEAD and OPTIONS; write covers the other methods. Only the endpoints below accept a token; every other endpoint (users, admin, the token API itself, profile, MFA, preferences, discovery, agents, relays, WebSocket...) answers 403 to any token, whatever its scopes. The OpenAPI schema (/api/schema/) lists the ApiToken security scheme with the scope of each endpoint, next to jwtAuth.
- read:inventory: GET /api/v1/assets/ (and /api/v1/assets/<uid>/ with its read actions), GET /api/v1/software/components/, /api/v1/software/components/export/, /api/v1/software/images/, /api/v1/software/images/summary/, /api/v1/software/webapps/, /api/v1/software/webapps/summary/. Writing assets is never possible with a token.
- read:security: GET /api/v1/security/findings/ (list, detail, export, events), /api/v1/security/cves/, /api/v1/security/dashboard/, /api/v1/security/assets/<uid>/findings/, /api/v1/security/servers/<uid>/remediation/ and its export.
- write:security: POST actions on /api/v1/security/findings/ (acknowledge/, resolve/, false-positive/, reopen/, assign/, accept-risk/, comments/ on /api/v1/security/findings/<id>/, and bulk/); the triage actions need a manager or admin owner.
- write:sbom: POST /api/v1/software/sbom/ (see SBOM Import API); needs a manager or admin owner.
Errors
Token failures use the usual status codes:
- 401: unknown, revoked or expired token, owner deactivated, or a malformed header (Token without a value, or with extra parts).
- 403: the endpoint does not accept tokens, the token lacks the scope of the method, or the owner role does not allow the action.
Revoking and Auditing
Revoke a token from the table (with confirmation) or with DELETE /api/v1/auth/api-tokens/<id>/ (204, idempotent). A revoked token is refused immediately; there is no way to re-enable or reveal a token, create a new one instead. The table shows name, prefix, owner, scopes, expiry, last use (updated at most once a minute) and state (active, expired, revoked).
- api_token.created and api_token.revoked are written to the audit log with the prefix, scopes, owner and expiry, never the token value. Revoking an already revoked token records nothing.
- Creating a service account also records user.created with service_account: true.
- Deactivating the owner in User Management disables all its tokens at once; reactivating it re-enables the ones not revoked or expired, so revoke them first if they must stay off.
Note: One token per integration, with the fewest scopes and the shortest validity that works, makes leaks cheap: revoke the single token and nothing else stops.