Skip to content

API: API keys

Start linking a program to an account

For a program that cannot show a login form, such as a chat bot. Returns a secret device_code to poll with and a short user_code to show the person, who opens verification_url in a browser, checks the code and approves. What the key may do is fixed by the client kind, not asked for. Rate limited per IP.

POST/api/v1/device-links

Authentication#

No key is needed: the codes in the exchange are the credential. This route is limited per address. See Authentication.

Request body#

Content type application/json.

NameTypeRequiredDescription
clientstringyesThe kind of program asking. It decides what the key may do: the server fixes the abilities, the program cannot choose them. one of telegram; min length 1
device_namestringnoA label for the key in the account's key list, such as the Telegram name of the person. Optional. max length 64

Responses#

201 Created#

Content type application/json. Schema: LinkStarted.

NameTypeRequiredDescription
device_codestring-Secret to poll with. Never show it to the person
expires_ininteger-Seconds until the link can no longer be approved
intervalinteger-Seconds to wait between polls
user_codestring-The short code to show the person, formatted XXXX-XXXX
verification_urlstring-Where the person approves. It already contains the user code

422 Unprocessable Content#

Content type application/problem+json. Validation failed; errors maps each field to its messages and issues lists each problem with its code, key and params. Schema: Problem.

The error follows RFC 9457. See Errors.

Any other status#

Content type application/problem+json. Error (RFC 9457 problem details). Schema: Problem.

The error follows RFC 9457. See Errors.

curl -X POST "http://localhost:3000/api/v1/device-links" \
  -H "Content-Type: application/json" \
  -d '{
  "client": "telegram",
  "device_name": "Telegram: ana"
}'

Response examples

{
  "device_code": "kV3x0Zp8mQ1sT9nL2aR7wYc4HbU6eGdJ5oFiNtX-AqE",
  "expires_in": 600,
  "interval": 3,
  "user_code": "BCDF-2346",
  "verification_url": "http://localhost:3000/account/link?code=BCDF-2346"
}

The examples are built from the schemas, so every value is a placeholder of its type. The tables above hold the fields that carry the real values.