Create Agent Auth Token

POST /v1/auth/token

Mint a fresh API key for the calling user. The returned token value is shown once — store it immediately. Equivalent to POST /v1/keys/api but without a description body (the server hardcodes "Regenerated via /auth/token"); intended for the dashboard's "regenerate token" button.

For programmatic use prefer /keys/api — it accepts a description field, IP allowlist, and expiry, all of which this endpoint silently ignores. Note: despite the name, this endpoint mints account-level API keys, not the per-tunnel agent auth tokens — those go through POST /v1/keys/auth.

Account scope: the minted key belongs to your active account. JWT sessions (from /auth/login) instead carry an active_account_id claim and are scoped to a single account — call POST /v1/user/switch-account to receive a new token scoped to a different account.

Request body

None. Any body is ignored. The owner of the new key is the authenticated user.

Response (200 OK)

token string
The new API key: ngk_ + 40 characters (letters, digits, _ and -). Use this for X-API-KEY headers on subsequent requests. Cannot be retrieved later — store immediately.

Errors

401 Unauthorized
No valid auth header.
500
Database error generating the key. Safe to retry; you may end up with two valid keys (delete one with /keys/api/{uuid}).
Request
curl -X POST "https://api.ngris.com/v1/auth/token" \ -H "X-API-KEY: <your_api_key>" \ -H "Content-Type: application/json"
Python
from ngris import Ngris client = Ngris(api_key="<your_api_key>") tok = client.auth.generate_token() print(tok.token) # store this — only shown once
Response — 200 OK
{ "token": "ngk_Q7rT2mXk9HpA4vN8cZ1bW6yH3sJ5dF0gE2tK7nVq" }
Was this helpful?
Was this helpful?