---
title: "Create a key for a server"
method: POST
path: "/v1/servers/{id}/tokens"
tags: ["Servers"]
---

# Create a key for a server

`POST /v1/servers/{id}/tokens`

## Request

- Base URL: `https://api.sendora.se`
- URL: `https://api.sendora.se/v1/servers/{id}/tokens`
- Auth: HTTP bearer

Creates another live key for the server and answers its value once; it is never shown again. Every key of a server has the same rights. A server holds at most two live keys: the one in use and the one being rotated in.

## Path parameters

- `id` string, uuid, required

## Request body

- object
  - `name` string, required: 1 to 100 characters.

## Response `201`

The new key, its value shown this once.

- object: The new key, its value shown this once.
  - `tokenId` string, uuid, required
  - `name` string, required: The name given at creation, for people to tell keys apart.
  - `prefix` string, required: The first characters of the key, to match it with a value in hand.
  - `createdAt` string, date-time, required
  - `revokedAt` string, date-time, nullable, required
  - `token` string, required: The key itself, shown this once.

## Other responses

- `400`: The body, the query or a header does not match what the route takes.
- `401`: The key is missing, malformed or revoked.
- `403`: The key is of the other kind, or a connected app may not do this here: it is not for connections, the connection may only read here, or it is for test servers only.
- `404`: No such server of this account.
- `409`: The server or the account already holds two live keys: one in use and one to rotate to. Revoke one before creating another.

---

[API](https://skmtc.dev/sendora/apis/sendora-api.md) · [All operations](https://skmtc.dev/sendora/apis/sendora-api/llms.txt) · [OpenAPI document](https://skmtc.dev/sendora/apis/sendora-api/revisions/72efbbb34b64?raw)
