# Authentication

How tiktornado API keys work. The key format, the Bearer header, the six scopes and what each allows, revoking, and the 25 live key limit.

Every request to the API and the MCP server carries one of your API keys. There is no other way to sign in: no OAuth, no username and password.

## Send the key [#send-the-key]

Put the key in the `Authorization` header as a bearer token, with `Bearer` written exactly so, then one space:

```bash
curl https://api.tiktornado.com/api/v1/key \
  -H "Authorization: Bearer $TIKTORNADO_API_KEY"
```

The `Authorization` header is the only place the key is read. An `X-API-Key` header, a query parameter or a cookie is ignored, and the request answers `401` with reason `api_key_invalid` and the header `WWW-Authenticate: Bearer realm="tiktornado"`.

## The key format [#the-key-format]

A key is `tt_` followed by 43 characters: letters, digits, `-` and `_`. Anything else is refused with `api_key_invalid` before it is looked up.

tiktornado keeps only a hash of the key, so nobody can show it to you again. The app lists each key by its first 11 characters (`tt_` and 8 more), so you can tell your keys apart.

## Create a key [#create-a-key]

1. Open the [API and MCP page](https://app.tiktornado.com/api) in the tiktornado app.
2. Click **New key**, give it a name and tick what it may do. Every access is ticked at first.
3. Copy the key. It is shown once, when you create it. If you lose it, revoke it and create a new one.

You can have at most 25 live keys at once. Past that the app asks you to revoke one first. You can create at most 10 keys an hour.

Store the key in an environment variable or a secrets manager, never in code or a repository. The examples on this site read it from `TIKTORNADO_API_KEY`.

## Scopes [#scopes]

Each key has one or more scopes. A route outside the key's scopes answers `403` with reason `api_scope_missing`, and an MCP tool outside them isn't listed at all.

| Scope | In the app | Allows |
| --- | --- | --- |
| `accounts:read` | Read accounts | List accounts, and read each account's post options, music, places, posting times and next free posting time |
| `posts:read` | Read posts | List posts |
| `posts:write` | Schedule posts | Upload links, schedule, edit, move and cancel posts, set posting times |
| `stats:read` | Read stats | Post stats and daily stats |
| `comments:read` | Read comments | Read a post's comments |
| `comments:write` | Reply to comments | Reply to comments |

`GET /key` needs no scope: any working key can call it, and it answers the key's scopes.

A key that posts needs `accounts:read` too, to find the ids of the accounts it posts to.

You can't change a key's scopes. To give a script more or less access, create a new key and revoke the old one. Keys made before 21 November 2026 don't have the two comment scopes: create a new key to read comments or reply.

## Revoke a key [#revoke-a-key]

Click **Revoke** next to the key on the API and MCP page. The key stops working at once: the very next request with it answers `401` `api_key_invalid`, on the API and the MCP server alike.

## When the key works but the request is refused [#when-the-key-works-but-the-request-is-refused]

- `403` `access_locked`: the subscription that bills the account isn't active. Requests about that account are refused, and your other accounts keep working. When your whole tiktornado account is locked, every request is refused, `GET /key` included. Fix it under Billing in the app.
- `404` `not_found`: the account, post or comment doesn't exist or isn't yours. The two look the same on purpose.

See [Errors](/getting-started/errors) for the rest.