# Create a token

Makes a single-use token, so that a web page can open one live session or send one file without your API key.

`POST /v1/tokens` on `https://api.eu.vatis.tech`

## Headers

| header | values | default | meaning |
|---|---|---|---|
| `Authorization` | `Bearer <api key>` | required | Your API key ([Authentication and API keys](https://platform.vatis.tech/docs/authentication)). A token cannot make a token. |

## Body fields (`application/json`)

| field | values | default | meaning |
|---|---|---|---|
| `type` | `realtime`, `batch` | required | What the token opens: a live session, or one [Create a transcript](https://platform.vatis.tech/docs/endpoints/create-a-transcript). |

## Response fields

| field | when | meaning |
|---|---|---|
| `token` |  | `vatis_tk_...`: hand it to the page. |
| `type` |  | `realtime` or `batch`, as you asked. |
| `expires_at` |  | When it stops working: ISO 8601, UTC. |

## Responses

`200`: The token, valid 15 minutes, for one use.

```json
{
  "token": "vatis_tk_...",
  "type": "realtime",
  "expires_at": "2026-11-12T09:29:03Z"
}
```

`400` `missing_parameter`: No `type`.

`400` `invalid_parameter`: Another `type` or another field, or a query parameter. The `param` names it.

```json
{
  "error": {
    "code": "invalid_parameter",
    "message": "'type' must be one of: realtime, batch.",
    "param": "type",
    "request_id": "req_bf2fed760ba5437ba0933a57"
  }
}
```

`400` `invalid_request`: A body that is not a JSON object.

`401` `unauthorized`: No key, or a wrong, revoked or expired one.

```json
{
  "error": {
    "code": "unauthorized",
    "message": "Invalid, revoked or expired key.",
    "param": null,
    "request_id": "req_bf2fed760ba5437ba0933a57"
  }
}
```

`413` `request_too_large`: A JSON body over 64 KB.

`503` `unavailable`: The service is busy for a moment. Send the request again after the seconds of the `Retry-After` header.

## Notes

- **One use, 15 minutes.** Make a new token for every session. A used, expired or wrong-type token is refused as `unauthorized`; a wrong-type token is not used up.
- **A live session:** `wss://api.eu.vatis.tech/v1/speech-to-text/realtime?model_id=vatis_ro_v9_realtime&token=<token>`
- **One file (a `batch` token):** `POST https://api.eu.vatis.tech/v1/speech-to-text?token=<token>`
- **It acts for its key**, with the role the key has when the token is used. Revoking the key cancels its tokens. A token never opens `/v1/keys`.
- **With both a key and a token,** the key is used and the token is kept. On the WebSocket, a wrong key in the header is refused even with a good token.
- Call this from your server, never from a web page, which would need your key ([Tokens for web pages](https://platform.vatis.tech/docs/authentication#tokens-for-web-pages)).
