# Authentication (/api/authentication)

The trumpet API uses Bearer token authentication. Every request must include a valid API key in the `Authorization` header.

## Bearer tokens [#bearer-tokens]

Include your API key in the `Authorization` header using the `Bearer` scheme:

```
Authorization: Bearer trpt_a1b2c3_Ks8dF2m...
```

Every API key starts with the `trpt_` prefix, followed by a short brand identifier and a cryptographically random string.

## Example request [#example-request]

<CodeBlockTabs defaultValue="curl">
<CodeBlockTabsList>
<CodeBlockTabsTrigger value="curl">
cURL
</CodeBlockTabsTrigger>

<CodeBlockTabsTrigger value="javascript">
JavaScript
</CodeBlockTabsTrigger>

<CodeBlockTabsTrigger value="python">
Python
</CodeBlockTabsTrigger>
</CodeBlockTabsList>

<CodeBlockTab value="curl">
```bash
curl -X POST https://trumpet.app/api/v1/pods/new \
  -H "Authorization: Bearer trpt_a1b2c3_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "template_id": "69f0bafc4cc54b506b0355d8"
  }'
```
</CodeBlockTab>

<CodeBlockTab value="javascript">
```javascript
const response = await fetch("https://trumpet.app/api/v1/pods/new", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.TRUMPET_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    template_id: "69f0bafc4cc54b506b0355d8",
  }),
});

const data = await response.json();
```
</CodeBlockTab>

<CodeBlockTab value="python">
```python
import os
import requests

response = requests.post(
    "https://trumpet.app/api/v1/pods/new",
    headers={
        "Authorization": f"Bearer {os.environ['TRUMPET_API_KEY']}",
        "Content-Type": "application/json",
    },
    json={"template_id": "69f0bafc4cc54b506b0355d8"},
)

data = response.json()
```
</CodeBlockTab>
</CodeBlockTabs>

## Scopes [#scopes]

Each API key is issued with one or more scopes that determine which endpoints it can access. If a key lacks the required scope for an endpoint, the API returns a `403 Forbidden` response.

| Scope | Access |
|-------|--------|
| `CreatePod` | Create new Pods via `POST /v1/pods/new` |

<Callout type="info" title="More scopes coming soon">
Additional scopes will be added as new API endpoints become available. Your existing keys will not gain new scopes automatically — you'll need to create new keys or update existing ones.
</Callout>

Additional scopes documented on other endpoint pages:

| Scope | Endpoint |
|-------|----------|
| `ReadCustomStatuses` | [List Custom Statuses](/api/list-custom-statuses) |
| `UpdatePod` | [Update Pod](/api/update-pod) |

## Key management [#key-management]

You can manage your API keys from **Settings → API Keys** in the trumpet dashboard. From there you can:

**Create keys** — Generate a new key with a name and scopes. The raw key is shown only once.

**Revoke keys** — Immediately disable a key. The key remains visible in your list for auditing but stops working instantly.

**Delete keys** — Permanently remove a key from your list. The key is also revoked if it wasn't already.

## Authentication errors [#authentication-errors]

If authentication fails, the API returns one of these responses:

| Status | Meaning |
|--------|---------|
| `401 Unauthorized` | Missing or invalid API key. Check the Authorization header format and that the key is correct. |
| `403 Forbidden` | The API key is valid but lacks the required scope for this endpoint. |

<Callout type="warn" title="Keep your keys safe">
Never commit API keys to version control or include them in client-side code. Use environment variables or a secrets manager instead.
</Callout>

## Related [#related]

<Cards>
<Card title="Getting Started" href="/api/getting-started">
Account setup, API keys, and your first request.
</Card>

<Card title="Create Pod" href="/api/create-pod">
Create Pods from a template with an optional CRM link.
</Card>

<Card title="Update Pod" href="/api/update-pod">
Change status or link a CRM record on an existing Pod.
</Card>
</Cards>