Create Auth Token

POST /v1/keys/auth

Mint an agent auth token. The agent reads this value from the API_TOKEN environment variable and presents it during handshake with the tunnel-server. The full token is returned only once — store it on the agent's host immediately.

Account scope: the token belongs to your active account and may carry traffic for that account's endpoints per your role's permissions. Use switch account to mint a token in a different account.

Bind the token to a specific endpoint (or tunnel) for least-privilege: a per-tunnel token can only carry traffic for that tunnel, so a leak from one machine doesn't expose your other endpoints. Unbound tokens (no endpoint_uuid) are convenient for development and one-shot tunnels but are powerful — keep them ephemeral.

The Python SDK calls this endpoint internally on every ngris.connect(), mints a new token, runs the agent with it, and revokes the token via DELETE /v1/keys/auth/{uuid} on shutdown.

Request body

description string
Free-form label. The Python SDK uses the form "ngris-python sdk (http localhost:8080)" so administrators can see "where did this token come from".
endpoint_uuid string (uuid)
Optional. The uuid of the endpoint this token may carry traffic for, in your active account. Without this the token is "unbound" and works for any endpoint of the account.
tunnel_uuid string (uuid)
Rare. Bind the token to a single tunnel (its uuid from /tunnels). Mostly used internally by the platform.

Deprecated: endpoint_id and tunnel_id (integers) are still accepted until the sunset. Send endpoint_uuid / tunnel_uuid; sending both forms for different objects is a 400 id_uuid_mismatch.

Response (200 OK)

uuid string (uuid)
The token's public id. Use it to revoke the token via DELETE /v1/keys/auth/{uuid}.
token string
The full secret. Format: nga_ + 40 characters (letters, digits, _ and -). Set on the agent's host as the API_TOKEN environment variable.

Deprecated: until the sunset this response also carries the legacy integer id field. Don't use it; read uuid.

Errors

400 Bad Request
Unknown body fields (handler uses strict decoding) — mostly a typo in a field name; endpoint_uuid / tunnel_uuid is not a uuid; id_uuid_mismatch; an integer id after the sunset (integer_id_unsupported).
404 Not Found
The endpoint or tunnel isn't in your active account (endpoint_uuid not found / tunnel_uuid not found). Another account's id is refused, never bound.
401 Unauthorized
Missing auth.
500
Crypto / database error. Safe to retry.
Request
curl -X POST "https://api.ngris.com/v1/keys/auth" \ -H "X-API-KEY: <your_api_key>" \ -H "Content-Type: application/json" \ -d '{ "description": "ci-bot agent", "endpoint_uuid": "019bb1e4-e785-77d2-9966-c3cff31d0a0e" }'
Python
from ngris import Ngris client = Ngris(api_key="<your_api_key>") tok = client.api_keys.create_auth_token( description="ci-bot agent", endpoint_uuid="019bb1e4-e785-77d2-9966-c3cff31d0a0e", ) print(tok["token"]) # store; only shown once
Response — 200 OK
{ "uuid": "019ae915-a554-7fc4-aea3-9c9ce2dd2976", "token": "nga_JT9c7eKdynB6fejCQ6dq4e3hDZncVvMXfXQKFwBp" }
Was this helpful?
On this page
Create Auth Token
Was this helpful?