> For the complete documentation index, see [llms.txt](https://docs.trezalabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.trezalabs.com/api/api-keys.md).

# API Keys

Treza API keys authenticate programmatic access to the platform: calling a published [pipeline](https://docs.trezalabs.com/pipelines/pipelines.md) and connecting AI assistants over the [MCP server](https://docs.trezalabs.com/api/mcp-server.md). A key looks like `treza_live_...`, is scoped to your account, and is sent as a bearer token.

***

## Create a key

In the dashboard, open the **API keys** page and create a key.

{% hint style="warning" %}
The key (`treza_live_...`) is shown **once**, at creation. Store it in a secrets manager immediately. If you lose it, revoke it and create a new one.
{% endhint %}

***

## Use a key

Send the key in the `Authorization` header as a bearer token on every request:

```
Authorization: Bearer treza_live_...
```

For example, invoking a published pipeline:

```bash
curl https://trezalabs.com/api/pipelines/<id>/invoke \
  -H "Authorization: Bearer treza_live_..." \
  -H "Content-Type: application/json" \
  -d '{ "inputs": { "brief": "A 6-second product demo" } }'
```

The same key works with the OpenAI-compatible endpoint. Point any OpenAI SDK at your pipeline and pass the key as the `api_key`. See the [Pipeline API](https://docs.trezalabs.com/api/pipeline-api.md).

***

## Ownership and scope

* **Account-scoped.** A key can only act on resources owned by the same account. In particular, a key can only invoke pipelines your account owns; calls to another account's pipeline return `403`.
* **Published only.** Pipeline endpoints serve the published snapshot. An unpublished pipeline returns `409`.
* **Credits.** Calls that run a pipeline draw from your account's prepaid credit balance. If the balance is empty, requests return `402`.

***

## Scopes

Keys carry scoped permissions that gate access per feature. Grant only the scopes a key needs.

| Scope             | Grants                                                                                                                                                                                                             |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `pipelines:read`  | List pipelines and read run history over the [MCP server](https://docs.trezalabs.com/api/mcp-server.md), and poll runs with `GET .../invoke` on the [Pipeline API](https://docs.trezalabs.com/api/pipeline-api.md) |
| `pipelines:run`   | Start pipeline runs: `/invoke` and `/chat/completions` on the [Pipeline API](https://docs.trezalabs.com/api/pipeline-api.md), and over the [MCP server](https://docs.trezalabs.com/api/mcp-server.md)              |
| `pipelines:write` | Author and publish pipelines, and add to or edit your media library, over the [MCP server](https://docs.trezalabs.com/api/mcp-server.md)                                                                           |
| `keys:provision`  | Mint new keys with `create_api_key` over an OAuth connection. A key can never mint another key                                                                                                                     |

Invoking a published pipeline requires a valid key that owns the pipeline and carries `pipelines:run`.

***

## Manage and rotate

* **Revoke** a key from the API keys page the moment you suspect it is exposed.
* **Rotate** keys periodically: create a new key, move your integrations over, then delete the old one.
* **Never** embed a key in client-side code or a public repository. Call Treza from your backend, where the key stays secret.

***

## Related

* [Pipeline API](https://docs.trezalabs.com/api/pipeline-api.md) - call a published pipeline with your key.
* [MCP Server](https://docs.trezalabs.com/api/mcp-server.md) - connect Claude and other AI assistants with `pipelines:*` scopes.
* [Build your first pipeline](https://docs.trezalabs.com/pipelines/quickstart.md) - end-to-end, including creating a key.
