# Authentication and API keys

Every request carries your API key, and a web page uses a single-use token instead.

Every request carries an API key of your workspace in the `Authorization` header, the WebSocket handshake included. Only `/ping` needs no key. A web page never holds a key: it uses a [single-use token](https://platform.vatis.tech/docs/authentication#tokens-for-web-pages).

## Send your key

Send it as a bearer token. The examples read it from `VATIS_KEY` ([Quickstart](https://platform.vatis.tech/docs/quickstart) shows how to set it).

```bash
curl -sS -H "Authorization: Bearer $VATIS_KEY" https://api.eu.vatis.tech/v1/models
```

```javascript
const headers = { Authorization: `Bearer ${process.env.VATIS_KEY}` };
const response = await fetch("https://api.eu.vatis.tech/v1/models", { headers });
```

```go
request, _ := http.NewRequest("GET", "https://api.eu.vatis.tech/v1/models", nil)
request.Header.Set("Authorization", "Bearer "+os.Getenv("VATIS_KEY"))
response, err := http.DefaultClient.Do(request)
```

```python
headers = {"Authorization": f"Bearer {os.environ['VATIS_KEY']}"}
response = httpx.get("https://api.eu.vatis.tech/v1/models", headers=headers)
```

```java
URI address = URI.create("https://api.eu.vatis.tech/v1/models");
HttpRequest request = HttpRequest.newBuilder(address)
    .header("Authorization", "Bearer " + System.getenv("VATIS_KEY"))
    .build();
HttpResponse<String> response = HttpClient.newHttpClient()
    .send(request, HttpResponse.BodyHandlers.ofString());
```

```csharp
using var http = new HttpClient();
var apiKey = Environment.GetEnvironmentVariable("VATIS_KEY");
http.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Bearer", apiKey);
using var response = await http.GetAsync("https://api.eu.vatis.tech/v1/models");
```

## API keys

Make one key per application, on the console's [API keys](https://platform.vatis.tech/keys) page (the workspace's owners and admins can) or [from code](https://platform.vatis.tech/docs/authentication#manage-keys-from-code) with an Admin key. A new workspace has no keys: verify your email, then create the first one.

- **Shown once.** A key starts with `vatis_sk_` and is shown only when it is made. The API keeps only its hash and a readable prefix, so keys can be told apart in the list. A lost key cannot be shown again: make a new one and revoke the old one.
- **Name.** 1 to 64 letters, digits, dots, dashes or underscores. No two active keys of a workspace share a name.
- **Expiry.** A key can stop on a day you choose (the last UTC day it works). Without one, it has no end.
- **Revoked or expired.** A revoked key, and every token made with it, is refused from the next request on. So is a key whose last day has passed. What the key already started goes on: a live session already open runs until it ends, and a file already accepted is still transcribed. Nothing is deleted: Usage and Activity still name the key.

### Roles

A key is a Member key unless it was made an Admin key. The API enforces the difference, whoever holds the key:

|  | Admin key | Member key |
|---|---|---|
| Transcribe files, live sessions | yes | yes |
| Usage and Activity ([Usage](https://platform.vatis.tech/docs/usage)) | the whole workspace | its own work |
| Transcripts: list, read, export, delete | every key's | those its own key made |
| Webhooks | manage them | no, but its files can be delivered to one by its id |
| Vocabularies ([Vocabularies](https://platform.vatis.tech/docs/realtime/vocabularies)) | manage them | list and read them, and its live sessions and files can use one by its id |
| `/v1/keys` | yes | no |

A request a Member key may not make is `403` `admin_only`. A transcript of another key answers as one that does not exist: `404` `not_found`. An Admin key sees only its own workspace.

### Refused keys

No key, a wrong key, a revoked or an expired one is `401` `unauthorized`, with the header `WWW-Authenticate: Bearer`; a live session gets an `error` `unauthorized` and close code 1008. After more than 10 refused keys or tokens from one address within a minute, the API answers that address's further refusals 2 seconds late. A valid key is never delayed.

## Keep your key safe

- **Keep keys on servers.** Read them from the environment or a secret store. Never put a key in a web page, a URL, your source code or a command line. A web page uses a [single-use token](https://platform.vatis.tech/docs/authentication#tokens-for-web-pages) instead.
- **Keep it out of your shell history.** `export VATIS_KEY=...` with the key on the line stays in the history. `read -rs` does not: paste the key, then press Enter (it is not shown).

```bash
read -rs VATIS_KEY && export VATIS_KEY
```

- **On a shared machine, keep it off the command line.** Other users of the machine can see command lines (with `ps`), and `-H "Authorization: Bearer $VATIS_KEY"` puts the key on curl's. Give curl the header on its standard input instead:

```bash
printf 'Authorization: Bearer %s\n' "$VATIS_KEY" | curl -sS -H @- https://api.eu.vatis.tech/v1/models
```

> **A key got out?.** Revoke it on the [API keys](https://platform.vatis.tech/keys) page at once, then make a new one for that application. Its Activity shows what it was used for.

## Tokens for web pages

A browser cannot set headers on a WebSocket, and an API key must never reach a browser. So your server makes a single-use token with its key and hands it to the page, which puts it in the address as `token`. A program on a server needs no token: it uses its key.

`POST /v1/tokens`

Body `{"type": "realtime"}` for one live session, or `{"type": "batch"}` for one file.

```bash
curl -sS -H "Authorization: Bearer $VATIS_KEY" -H "Content-Type: application/json" \
  -d '{"type": "realtime"}' https://api.eu.vatis.tech/v1/tokens
```

```javascript
// On your server: a token for the page, for one live session.
const response = await fetch("https://api.eu.vatis.tech/v1/tokens", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.VATIS_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({ type: "realtime" }),
});
const { token } = await response.json();
```

```go
// On your server: a token for the page, for one live session.
func liveToken() (string, error) {
	body := strings.NewReader(`{"type": "realtime"}`)
	request, _ := http.NewRequest("POST", "https://api.eu.vatis.tech/v1/tokens", body)
	request.Header.Set("Authorization", "Bearer "+os.Getenv("VATIS_KEY"))
	request.Header.Set("Content-Type", "application/json")
	response, err := http.DefaultClient.Do(request)
	if err != nil {
		return "", err
	}
	defer response.Body.Close()
	var answer struct{ Token string }
	err = json.NewDecoder(response.Body).Decode(&answer)
	return answer.Token, err
}
```

```python
# On your server: a token for the page, for one live session.
response = httpx.post(
    "https://api.eu.vatis.tech/v1/tokens",
    headers={"Authorization": f"Bearer {os.environ['VATIS_KEY']}"},
    json={"type": "realtime"},
)
token = response.json()["token"]
```

```java
// On your server: a token for the page, for one live session.
URI address = URI.create("https://api.eu.vatis.tech/v1/tokens");
HttpRequest request = HttpRequest.newBuilder(address)
    .header("Authorization", "Bearer " + System.getenv("VATIS_KEY"))
    .header("Content-Type", "application/json")
    .POST(HttpRequest.BodyPublishers.ofString("{\"type\": \"realtime\"}"))
    .build();
HttpResponse<String> response = HttpClient.newHttpClient()
    .send(request, HttpResponse.BodyHandlers.ofString());
// Java has no JSON parser built in: a real program would use a library.
Matcher match = Pattern.compile("\"token\":\\s*\"([^\"]+)\"").matcher(response.body());
String token = match.find() ? match.group(1) : null;
```

```csharp
// On your server: a token for the page, for one live session.
using var http = new HttpClient();
var apiKey = Environment.GetEnvironmentVariable("VATIS_KEY");
http.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Bearer", apiKey);
var json = """{"type": "realtime"}""";
var body = new StringContent(json, Encoding.UTF8, "application/json");
using var response = await http.PostAsync("https://api.eu.vatis.tech/v1/tokens", body);
using var answer = JsonDocument.Parse(await response.Content.ReadAsStringAsync());
var token = answer.RootElement.GetProperty("token").GetString();
```

**Expected result:** `200` and the token (shortened here).

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

The page then uses it instead of the key, once, within 15 minutes:

| For | The address |
|---|---|
| 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>` |

- **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.
- **It acts for its key**, with the role the key has when the token is used. Revoking the key cancels its tokens. A token cannot make a token, and it 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.
- **Refused requests:** `400` `missing_parameter` without `type`, `400` `invalid_parameter` for another `type` or another field, `400` `invalid_request` for a body that is not a JSON object, `413` `request_too_large` over 64 KB.

Call the REST endpoints from your server, never from a web page, which would need your key. Browsers give the microphone only to secure pages: HTTPS, or `http://localhost`. A whole page with live text: [Real-time transcription](https://platform.vatis.tech/docs/realtime).

## Which key is this

`GET /v1/me`

The key this request carries: its id, name and role. Any key.

```bash
curl -sS -H "Authorization: Bearer $VATIS_KEY" https://api.eu.vatis.tech/v1/me
```

```javascript
const headers = { Authorization: `Bearer ${process.env.VATIS_KEY}` };
const response = await fetch("https://api.eu.vatis.tech/v1/me", { headers });
console.log(await response.text());
```

```go
request, _ := http.NewRequest("GET", "https://api.eu.vatis.tech/v1/me", nil)
request.Header.Set("Authorization", "Bearer "+os.Getenv("VATIS_KEY"))
response, err := http.DefaultClient.Do(request)
if err != nil {
	log.Fatal(err)
}
defer response.Body.Close()
io.Copy(os.Stdout, response.Body)
```

```python
headers = {"Authorization": f"Bearer {os.environ['VATIS_KEY']}"}
response = httpx.get("https://api.eu.vatis.tech/v1/me", headers=headers)
print(response.text)
```

```java
URI address = URI.create("https://api.eu.vatis.tech/v1/me");
HttpRequest request = HttpRequest.newBuilder(address)
    .header("Authorization", "Bearer " + System.getenv("VATIS_KEY"))
    .build();
HttpResponse<String> response = HttpClient.newHttpClient()
    .send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```

```csharp
using var http = new HttpClient();
var apiKey = Environment.GetEnvironmentVariable("VATIS_KEY");
http.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Bearer", apiKey);
using var response = await http.GetAsync("https://api.eu.vatis.tech/v1/me");
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

```json
{"id": "key_3f9c1a2b7d4e", "name": "crm-backend", "role": "member"}
```

## Manage keys from code

An Admin key lists, makes, changes and revokes the keys of its workspace. These are the same keys as on the console's API keys page: a key made in one place shows in the other.

A key, as every answer below gives it (never the key itself, except once when it is made):

```json
{"id": "key_3f9c1a2b7d4e", "name": "crm-backend", "prefix": "vatis_sk_AbCdEf", "role": "member", "state": "active",
 "created_at": "2026-11-12T09:14:03Z", "last_used_at": "2026-11-12T10:01:44Z", "expires_at": null, "revoked_at": null}
```

| Field | Is |
|---|---|
| `id` | The key's id: `key_` and 12 hex digits. |
| `name` | Its name. |
| `prefix` | The key's first characters, to tell it apart. |
| `role` | `admin` or `member` ([Roles](https://platform.vatis.tech/docs/authentication#roles)). |
| `state` | `active`, `expired` or `revoked`. |
| `created_at` | When it was made; `last_used_at` when it last made a request (`null`: never). |
| `expires_at` | When it stops: the start of the day after its last day, in UTC. `null`: no end. |
| `revoked_at` | When it was revoked, or `null`. |

### List the keys

`GET /v1/keys`

`{"keys": [<key>, ...]}`, oldest first. Revoked keys only with `?include_revoked=true`.

```bash
curl -sS -H "Authorization: Bearer $VATIS_KEY" https://api.eu.vatis.tech/v1/keys
```

```javascript
const headers = { Authorization: `Bearer ${process.env.VATIS_KEY}` };
const response = await fetch("https://api.eu.vatis.tech/v1/keys", { headers });
console.log(await response.text());
```

```go
request, _ := http.NewRequest("GET", "https://api.eu.vatis.tech/v1/keys", nil)
request.Header.Set("Authorization", "Bearer "+os.Getenv("VATIS_KEY"))
response, err := http.DefaultClient.Do(request)
if err != nil {
	log.Fatal(err)
}
defer response.Body.Close()
io.Copy(os.Stdout, response.Body)
```

```python
headers = {"Authorization": f"Bearer {os.environ['VATIS_KEY']}"}
response = httpx.get("https://api.eu.vatis.tech/v1/keys", headers=headers)
print(response.text)
```

```java
URI address = URI.create("https://api.eu.vatis.tech/v1/keys");
HttpRequest request = HttpRequest.newBuilder(address)
    .header("Authorization", "Bearer " + System.getenv("VATIS_KEY"))
    .build();
HttpResponse<String> response = HttpClient.newHttpClient()
    .send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```

```csharp
using var http = new HttpClient();
var apiKey = Environment.GetEnvironmentVariable("VATIS_KEY");
http.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Bearer", apiKey);
using var response = await http.GetAsync("https://api.eu.vatis.tech/v1/keys");
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

### Make a key

`POST /v1/keys`

Body `name` (required), `role` (`admin` or `member`, default `member`), `expires_on` (`YYYY-MM-DD`, the last UTC day it works; default none).

```bash
curl -sS -H "Authorization: Bearer $VATIS_KEY" -H "Content-Type: application/json" \
  -d '{"name": "crm-backend", "expires_on": "2027-01-31"}' https://api.eu.vatis.tech/v1/keys
```

```javascript
const response = await fetch("https://api.eu.vatis.tech/v1/keys", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.VATIS_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({ name: "crm-backend", expires_on: "2027-01-31" }),
});
const created = await response.json(); // created.key is shown only in this answer
```

```go
body := strings.NewReader(`{"name": "crm-backend", "expires_on": "2027-01-31"}`)
request, _ := http.NewRequest("POST", "https://api.eu.vatis.tech/v1/keys", body)
request.Header.Set("Authorization", "Bearer "+os.Getenv("VATIS_KEY"))
request.Header.Set("Content-Type", "application/json")
response, err := http.DefaultClient.Do(request)
if err != nil {
	log.Fatal(err)
}
defer response.Body.Close()
var created map[string]any // created["key"] is shown only in this answer
if err := json.NewDecoder(response.Body).Decode(&created); err != nil {
	log.Fatal(err)
}
```

```python
response = httpx.post(
    "https://api.eu.vatis.tech/v1/keys",
    headers={"Authorization": f"Bearer {os.environ['VATIS_KEY']}"},
    json={"name": "crm-backend", "expires_on": "2027-01-31"},
)
created = response.json()  # created["key"] is shown only in this answer
```

```java
URI address = URI.create("https://api.eu.vatis.tech/v1/keys");
String body = "{\"name\": \"crm-backend\", \"expires_on\": \"2027-01-31\"}";
HttpRequest request = HttpRequest.newBuilder(address)
    .header("Authorization", "Bearer " + System.getenv("VATIS_KEY"))
    .header("Content-Type", "application/json")
    .POST(HttpRequest.BodyPublishers.ofString(body))
    .build();
HttpResponse<String> response = HttpClient.newHttpClient()
    .send(request, HttpResponse.BodyHandlers.ofString());
String created = response.body(); // its "key" is shown only in this answer
```

```csharp
using var http = new HttpClient();
var apiKey = Environment.GetEnvironmentVariable("VATIS_KEY");
http.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Bearer", apiKey);
var json = """{"name": "crm-backend", "expires_on": "2027-01-31"}""";
var body = new StringContent(json, Encoding.UTF8, "application/json");
using var response = await http.PostAsync("https://api.eu.vatis.tech/v1/keys", body);
var answer = await response.Content.ReadAsStringAsync();
// created.GetProperty("key") is shown only in this answer
var created = JsonDocument.Parse(answer).RootElement;
```

`201`: the key object plus `key`, the key itself (`vatis_sk_...`), the only time it is shown. The answer has `Cache-Control: no-store`. Hand the key to its application through a channel you trust.

### Change a key's role

`PATCH /v1/keys/{id}`

Body `{"role": "admin"}` or `{"role": "member"}`. It applies at once, to the key's open tokens too. `200`: the key as it is now.

### Revoke a key

`DELETE /v1/keys/{id}`

Revokes the key and its open tokens: `204`, also when it was revoked already. New requests with it are refused at once; what it started goes on.

### When a change is refused

| Status | Code | Why |
|---|---|---|
| 400 | `missing_parameter` | No `name` (make), no `role` (change). |
| 400 | `invalid_parameter` | A field that is unknown or not valid, a day that has passed: `param` names it. |
| 400 | `invalid_request` | A body that is not a JSON object. |
| 403 | `admin_only` | A Member key. |
| 404 | `not_found` | No key of this workspace has that id. |
| 409 | `name_taken` | An active key has that name: revoke it first, or pick another name. |
| 409 | `key_revoked` | A change to a revoked key. |
| 409 | `last_admin` | The workspace's last active Admin key cannot be revoked or made a Member from code: make another key Admin first. |
| 413 | `request_too_large` | A JSON body over 64 KB. |

The console's API keys page can revoke any key, the last Admin key too: the console is the way back when no Admin key is left. Every code: [Errors](https://platform.vatis.tech/docs/errors).
