This is the multi-page printable view of this section.
Tokens & Auth
API tokens authenticate clients that do not connect from the loopback address. They are shown once at creation; only a SHA-256 hash is stored.
The token object
| Field | Description |
|---|---|
id |
Opaque string used to revoke the token |
name |
Label of 1–64 characters drawn from letters, digits, - and _, such as agent or ci |
createdAt |
Unix seconds |
lastUsedAt |
Unix seconds of the last successful authentication, 0 if never used |
Tokens themselves always start with pigeon_ and are only returned by the
creation call.
Create a token
pigeon serve also creates an initial token on first start and prints it in
the log exactly once. This only happens while the tokens table is empty —
later starts never re-create it. If every token is deleted, the next start
generates a fresh initial token.
The REST API is equivalent — POST /api/tokens:
Store the token value now — it cannot be retrieved again. If it is lost,
revoke the token and create a new one.
List tokens
The plaintext token is never shown: the database stores only its SHA-256
hash, so the secret cannot be recovered after creation. Use the id column
to revoke a token; if a secret is lost, delete the token and create a new
one.
GET /api/tokens returns the same metadata as an array of token objects
(never the secrets):
Revoke a token
The argument is matched against ids first; when no id matches it is treated as a name and every token with that name is revoked.
DELETE /api/tokens/{id} returns 204. Revocation is immediate; clients
using that token start receiving 401.
Using a token
Send it as a bearer token on every request:
The MCP HTTP endpoint uses the same header:
Authentication rules
| Source | Requirement |
|---|---|
Loopback (127.0.0.1, ::1) |
No token needed |
| Any other address | Valid Authorization: Bearer pigeon_… header |
/api/health |
Always public |
The loopback exemption is based on the TCP remote address, not on
X-Forwarded-For. When Pigeon runs behind a reverse proxy on the same host,
the proxy’s loopback connection is trusted — protect the site at the proxy
layer or run Pigeon in a network namespace/container where remote addresses
are not loopback. See Security & Deployment.