Warteliste offen: Hol dir früh Zugang

API-Referenz: API-Keys

4 Endpunkte der Gruppe «API-Keys». Die Referenz stammt aus der englischen OpenAPI-Spezifikation und ist nicht übersetzt.

List API keys

GET/v1/keys

Prefix, environment and scope; the key itself is shown once, when it is created.

Parameter

NameOrtTypBeschreibung
limitqueryintegerPage size. The default and the maximum depend on the endpoint (emails 50 up to 500, received mail 50 up to 200, audit up to 200, the others 100 up to 500 or 1000). Default: 100
cursorquerystringThe next_cursor of the previous page. Opaque; pass it unchanged to the same endpoint with the same filters.

Beispiel

curl "https://api.sendtide.ch/v1/keys" \
  -H "Authorization: Bearer sk_test_…"

Antworten

StatusBeschreibung
200 Keys
Felder der Antwort
dataarray<ApiKey>
data[].idstring
data[].namestring
data[].prefixstring
data[].envenum: live | test
data[].scopeenum: admin | full | send | read
data[].allowed_ipsarray<string>CIDRs, IPv4 or IPv6; empty: from anywhere
data[].allowed_domainsarray<string>From domain must be one of these or a subdomain; empty: any verified domain
data[].allowed_streamsarray<string>Streams the key may send through; empty: all
data[].api_versionstringAPI version the key was created with Example: 2026-11-29
data[].keystringOnly in the answer to POST
data[].expires_atstring | null (date-time)The key is refused from then on; null: never
data[].rotated_fromstring | nullId of the key this one replaced
data[].last_used_atstring | null (date-time)
data[].created_atstring (date-time)
next_cursorstring | null

Create an API key

POST/v1/keys

Needs scope full or admin (or a dashboard role of developer or higher). The new key gets the requested scope at most as high as the caller's own; the admin scope is only created by owners and admins in the dashboard (403 otherwise). Default scope: full. With expires_at (at most a year ahead) the key stops working at that time.

Request-Body application/json

FeldTypBeschreibung
namestring
env *enum: live | test
scopeenum: admin | full | send | readDefault: "full"
allowed_ipsarray<string>
allowed_domainsarray<string>
allowed_streamsarray<string>
expires_atstring (date-time)

Beispiel

curl -X POST "https://api.sendtide.ch/v1/keys" \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{"name":"Server","env":"live","scope":"send","allowed_ips":["203.0.113.0/24"]}'

Antworten

StatusBeschreibung
201 Created; the key is in the answer ApiKey
Felder der Antwort
idstring
namestring
prefixstring
envenum: live | test
scopeenum: admin | full | send | read
allowed_ipsarray<string>CIDRs, IPv4 or IPv6; empty: from anywhere
allowed_domainsarray<string>From domain must be one of these or a subdomain; empty: any verified domain
allowed_streamsarray<string>Streams the key may send through; empty: all
api_versionstringAPI version the key was created with Example: 2026-11-29
keystringOnly in the answer to POST
expires_atstring | null (date-time)The key is refused from then on; null: never
rotated_fromstring | nullId of the key this one replaced
last_used_atstring | null (date-time)
created_atstring (date-time)
403 Fehler im üblichen Format, Fehler und Limits

Revoke an API key

DELETE/v1/keys/{id}

Revoking an admin key needs an admin.

Parameter

NameOrtTypBeschreibung
id *pathstring

Beispiel

curl -X DELETE "https://api.sendtide.ch/v1/keys/key_3f9a" \
  -H "Authorization: Bearer sk_test_…"

Antworten

StatusBeschreibung
204 Revoked

Rotate an API key

POST/v1/keys/{id}/rotate

Creates a new key with the name, environment, scope, restrictions and API version of the old one; the new key is in the answer, only this once. The old key keeps working for the chosen time (expires_in, or expires_at at most 90 days ahead) and is refused afterwards; now revokes it at once. Rotating a key that already expires only ever moves its expiry earlier. The same rules as for creating and revoking keys apply: rotating an admin key needs an owner or admin in the dashboard. Owners and admins get a reminder 7 days and 1 day before a key expires.

Parameter

NameOrtTypBeschreibung
id *pathstring

Request-Body application/json

FeldTypBeschreibung
expires_inenum: now | 1h | 24h | 7d | 30dHow long the old key keeps working
expires_atstring (date-time)Instead of expires_in; at most 90 days ahead

Beispiel

curl -X POST "https://api.sendtide.ch/v1/keys/key_3f9a/rotate" \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{}'

Antworten

StatusBeschreibung
201 Rotated; the new key is in the answer, only this once
403 Fehler im üblichen Format, Fehler und Limits
404 Fehler im üblichen Format, Fehler und Limits
422 Fehler im üblichen Format, Fehler und Limits