---
url: https://rustrak.dev/reference/api
---

# API Reference

Every endpoint, with its parameters, request and response schemas and the authentication it takes, is in the [interactive API reference](https://rustrak.dev/api-reference). It is generated from the server's OpenAPI spec, and you can send requests from it with your token.

## Authentication

Management endpoints take an [API token](https://rustrak.dev/usage/tokens) as a bearer token. Set `RUSTRAK_URL` to your server's address and `RUSTRAK_TOKEN` to the token:

```bash
curl -H "Authorization: Bearer $RUSTRAK_TOKEN" "$RUSTRAK_URL/api/projects"
```

Create one under **Settings → API Tokens**. SDKs authenticate ingestion with the key in their DSN instead.

For TypeScript, [`@rustrak/client`](https://rustrak.dev/sdks/client) wraps every endpoint with typed methods.

## The spec from your own server

The published images are built without the `openapi` feature, so they do not serve the spec: use the reference above. A server you build with it serves two more public endpoints:

| Endpoint | What it is |
|---|---|
| `GET /api-docs/openapi.json` | The OpenAPI 3 spec |
| `GET /docs` | The same interactive reference, served by the server |

```bash
cargo build --release --features openapi
```

To write the spec to `apps/server/openapi.json` without running the server:

```bash
cargo run --bin gen_openapi --features openapi
```
