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

# API Reference

> Complete reference for the Flux REST API

The Flux API is organized around REST. Our API has predictable resource-oriented URLs, accepts JSON-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes.

## Base URL

```
https://api.flux.dev/v1
```

## Authentication

The Flux API uses API keys to authenticate requests. Include your key in the `Authorization` header:

```bash theme={null}
Authorization: Bearer sk_live_your_api_key
```

<Warning>
  All API requests must be made over HTTPS. Requests over HTTP will fail.
</Warning>

## Request Format

For POST and PUT requests, encode parameters as JSON:

```bash theme={null}
curl -X POST https://api.flux.dev/v1/events \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{"type": "user.signup", "data": {"userId": "123"}}'
```

## Response Format

All responses return JSON. Successful responses include the requested resource:

```json theme={null}
{
  "id": "evt_1a2b3c4d",
  "type": "user.signup",
  "created": "2024-01-15T10:30:00Z",
  "data": {
    "userId": "123"
  }
}
```

List endpoints return paginated results:

```json theme={null}
{
  "data": [...],
  "hasMore": true,
  "nextCursor": "cur_abc123"
}
```

## Errors

Errors return a consistent structure with an error code and message:

```json theme={null}
{
  "error": {
    "code": "invalid_request",
    "message": "The 'type' field is required",
    "param": "type"
  }
}
```

### HTTP Status Codes

| Code  | Description                         |
| ----- | ----------------------------------- |
| `200` | Success                             |
| `201` | Created                             |
| `400` | Bad Request — Invalid parameters    |
| `401` | Unauthorized — Invalid API key      |
| `404` | Not Found — Resource doesn't exist  |
| `429` | Rate Limited — Too many requests    |
| `500` | Server Error — Something went wrong |

## Pagination

List endpoints support cursor-based pagination:

```bash theme={null}
GET /v1/events?limit=50&cursor=cur_abc123
```

| Parameter | Description                         |
| --------- | ----------------------------------- |
| `limit`   | Number of items to return (max 100) |
| `cursor`  | Cursor for the next page            |

## Rate Limiting

The API is rate limited based on your plan. When rate limited, you'll receive a `429` response with a `Retry-After` header indicating when to retry.
