---
title: "Authentication"
description: "Authenticate every request with a bearer token: an organization API key or a session JWT."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.cloudraker.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Authentication

Every authenticated request to the CloudRaker API carries a single header:

```
Authorization: Bearer <token>
```

The gateway accepts two kinds of token under that header and tells them apart automatically:

1. **Organization API keys** — a machine credential scoped to one organization. This is the developer path.
2. **Session JWTs** — the token the web app uses for a signed-in human. They carry that person's role and per-resource grants.

Both resolve to the same tenant-scoped identity, so both can call the same routes. One exception is covered under [Capability differences](#api-keys-vs-session-jwts) below.

## Organization API keys

An org API key is a long-lived credential that belongs to your organization, not to a person. Its actions are recorded under the key's name. Use it for server-to-server automation.

### Create a key

Create keys in the app under **Admin → API keys** (admin-only). The [API keys guide](https://docs.cloudraker.com/workspace/admin/api-keys) has the full UI walkthrough. The plaintext value is shown **once** at creation. You cannot retrieve it again.

You can also manage keys over the API (admin-gated):


```bash
curl -X GET https://api.cloudraker.com/api-keys \
  -H "Authorization: Bearer $CLOUDRAKER_API_KEY"
```

```bash
curl -X POST https://api.cloudraker.com/api-keys \
  -H "Authorization: Bearer $CLOUDRAKER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "CI pipeline"
}'
```

```bash
curl -X DELETE https://api.cloudraker.com/api-keys/id \
  -H "Authorization: Bearer $CLOUDRAKER_API_KEY"
```

> **Warning**
>
> `POST /api-keys` returns the plaintext key value **once**, in the `201` response body. Store it immediately. List and get calls never return it again.

### Use a key

Send it as the bearer token on any request:


```bash
curl -X GET https://api.cloudraker.com/me \
  -H "Authorization: Bearer $CLOUDRAKER_API_KEY"
```

> **Note**
>
> Each gateway instance caches validated key identity for about 60 seconds. A revoked key can keep working for up to one minute before the cache clears. Include this delay in your rotation plan.

## Tenant scoping

One organization is one tenant. After authentication, the gateway derives your tenant from the token's org and scopes **every** call to it. You never send a tenant id, org id, or slug. A token whose identity has no organization gets `404 {"error":"org not found"}`.

## API keys vs. session JWTs

Both token kinds resolve to the same tenant, but they differ on one class of route:

| | Organization API key | Session JWT |
|---|---|---|
| Identity | The org (a machine credential) | A specific human |
| Admin / org-level routes | ✅ Satisfies admin gates | ✅ (if the user is an admin) |
| Per-user resource permissions | ❌ No membership; cannot satisfy per-user grants | ✅ Carries the user's per-resource grants |
| Best for | Server-to-server, org-wide automation | The interactive web app |

The gateway treats an org key as an org-level machine credential. The key passes admin and API-key gates, but it has no user membership. Routes gated on a specific human's fine-grained resource permission reject a key. Org admins bypass per-resource space checks in all cases.

## Session JWTs

The web app's auth flow mints session JWTs for a signed-in user. They are three-segment JWTs. The platform verifies them against its signing keys. They carry the user's role, permission claims, and membership id. Do not mint these for server-to-server work. Use an API key instead. This section exists so you recognize them when the web app or an SDK forwards one.

## WebSocket tickets

A browser must never hold an API key. For the [realtime transcription](https://docs.cloudraker.com/paperwork/capabilities/realtime-transcription) socket, your backend creates the session with its API key. The response carries a `wss://` URL with a `ticket` query parameter.

- The ticket is the only credential on the socket. The socket takes no `Authorization` header.
- Each ticket works once and expires after 60 seconds.
- Get a new ticket with `POST /v1/realtime/transcriptions/{id}/tickets`.
- Each `ready` message carries a single-use `resumeTicket` for a reconnect.
- A newer ticket evicts the client that holds an older one.

## Failure codes

| Status | Body | Meaning |
|---|---|---|
| `401` | `{"error":"unauthorized"}` | Missing or malformed `Authorization` header |
| `401` | `{"error":"invalid_token"}` | Token failed validation |
| `404` | `{"error":"org not found"}` | Token has no associated organization |
| `503` | `{"error":"auth_unavailable"}` | Transient auth-service outage during key validation. **Not** a revoked key. Retry |

> **Info**
>
> A `503 auth_unavailable` is deliberately distinct from `401`. During an auth-service outage, a valid key must not look revoked. Treat it as transient and retry with backoff.

## Where to go next

[**Quickstart**](https://docs.cloudraker.com/paperwork/developers/quickstart)

Make your first authenticated call end to end.


[**SDKs**](https://docs.cloudraker.com/paperwork/developers/sdks)

Let a typed client set the header for you.

Source: https://docs.cloudraker.com/paperwork/developers/authentication/index.mdx
