Documentation · API reference
POST
/api/v1/tokensMake a token
This page as Markdown, or in an AI chatMore ways to read this page
Make a token: what it may do, and on which sites. It is in this answer once; only its hash is kept.
# Make a token
> tidekeeper's API reference: https://tidekeeper.eu/docs/api/post-tokens
`POST /api/v1/tokens`
Make a token: what it may do, and on which sites. It is in this answer once; only its hash is kept.
## What to send
`TokenCreate`
- `expires_days` (integer or null): Days until it stops working. Left out, it does not.
- `name` (string, needed)
- `scopes` (list of string): `read`, `events`, `manage`, `visitors`.
- `sites` (list of string): Site ids or names it is held to. Empty is every site its maker may open.
## The answer
201, `TokenCreated`: The only time a token's secret is shown.
- `secret` (string, needed)
- `token` (TokenView, needed)
## Asking
```sh
curl -X POST https://tidekeeper.eu/api/v1/tokens \
-H "Authorization: Bearer $TIDEKEEPER_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "…"}'
```
What to send
TokenCreate
- expires_days
- integer or nullDays until it stops working. Left out, it does not.
- name
- stringneeded
- scopes
- list of string`read`, `events`, `manage`, `visitors`.
- sites
- list of stringSite ids or names it is held to. Empty is every site its maker may open.
The answer
Status 201
TokenCreated The only time a token's secret is shown.
- secret
- stringneeded
- token
- TokenViewneeded
Asking
curl -X POST https://tidekeeper.eu/api/v1/tokens \ -H "Authorization: Bearer $TIDEKEEPER_TOKEN" \ -H "Content-Type: application/json" \ -d '{"name": "…"}'
const answer = await fetch("https://tidekeeper.eu/api/v1/tokens", { method: "POST", headers: { Authorization: `Bearer ${process.env.TIDEKEEPER_TOKEN}`, "Content-Type": "application/json", }, body: JSON.stringify({"name": "…"}), }).then((r) => r.json());