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

# API Keys

# API Keys

Your API key authenticates event ingestion requests. Each account has one active API key at a time. You can retrieve it and rotate it (issuing a new key and immediately invalidating the old one) at any time.

All endpoints require a valid JWT session token.

***

## Get your API key

Returns your current active API key.

```text theme={null}
GET /v1/tenants/api-keys
```

### Authentication

```text theme={null}
Authorization: Bearer <jwt>
```

### Example

```bash theme={null}
curl https://api.eldrstream.com/v1/tenants/api-keys \
  -H "Authorization: Bearer <jwt>"
```

### Response

```json theme={null}
[
  {
    "id": "a3f8bc1d2e",
    "key": "eldr_sk_9f4c2a8b1c3d...",
    "is_active": true,
    "created_at": "2025-01-10T12:00:00",
    "last_used": "2025-01-15T09:45:22"
  }
]
```

| Field        | Description                                                            |
| ------------ | ---------------------------------------------------------------------- |
| `id`         | Your tenant ID                                                         |
| `key`        | The API key value. Treat this as a secret — do not expose it publicly. |
| `is_active`  | Whether this key is currently valid                                    |
| `created_at` | When the key was last rotated or created                               |
| `last_used`  | Timestamp of the most recent successful use, or `null` if unused       |

***

## Rotate your API key

Generates a new API key and immediately deactivates the previous one. All ingestion requests using the old key will begin failing instantly.

```text theme={null}
POST /v1/tenants/api-keys
```

### Authentication

```text theme={null}
Authorization: Bearer <jwt>
```

### Example

```bash theme={null}
curl -X POST https://api.eldrstream.com/v1/tenants/api-keys \
  -H "Authorization: Bearer <jwt>"
```

### Response

```json theme={null}
{
  "id": "a3f8bc1d2e",
  "key": "eldr_sk_7b3e1c9f2a...",
  "is_active": true,
  "created_at": "2025-01-15T10:45:00",
  "last_used": null
}
```

### Status codes

| Status                    | Meaning                                                                     |
| ------------------------- | --------------------------------------------------------------------------- |
| `200 OK`                  | New key issued, old key invalidated                                         |
| `503 Service Unavailable` | Key rotation failed. Your existing key is still active — retry the request. |

***

## Best practices

* **Rotate proactively** if you suspect your key has been exposed.
* **Store keys in environment variables** or a secrets manager, never in source code.
* **Update all services** that use the old key before or immediately after rotating, since the old key stops working instantly.
