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

# API Overview

> LogFleet REST API reference

The LogFleet API is organized around REST. It accepts JSON-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes and authentication.

## Base URL

```
https://api.logfleet.io/api/v1
```

For local development:

```
http://localhost:8080/api/v1
```

## Authentication

LogFleet uses two authentication methods:

| Method     | Header                          | Use Case                   |
| ---------- | ------------------------------- | -------------------------- |
| JWT Bearer | `Authorization: Bearer {token}` | Dashboard, user operations |
| API Key    | `X-API-Key: {key}`              | Edge agents                |

See the [Authentication](/authentication) guide for details.

## API Groups

<CardGroup cols={2}>
  <Card title="Authentication" icon="key" href="/api-reference/auth/register">
    User registration, login, and password management
  </Card>

  <Card title="Agents" icon="server" href="/api-reference/agents/list">
    Manage edge agents and their configurations
  </Card>

  <Card title="API Keys" icon="lock" href="/api-reference/api-keys/list">
    Create and manage API keys for edge agents
  </Card>

  <Card title="Streaming" icon="satellite-dish" href="/api-reference/streaming/start">
    On-demand log streaming from edge agents
  </Card>

  <Card title="Metric Configs" icon="chart-line" href="/api-reference/metric-configs/overview">
    Configure log-to-metric extraction rules
  </Card>

  <Card title="Edge API" icon="microchip" href="/api-reference/edge/overview">
    Endpoints used by edge agents (API Key auth)
  </Card>
</CardGroup>

## Request Format

All requests should include:

```bash theme={null}
Content-Type: application/json
```

Request bodies use JSON format:

```json theme={null}
{
  "field": "value",
  "nested": {
    "property": 123
  }
}
```

## Response Format

Successful responses return the requested data:

```json theme={null}
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "example",
  "created_at": "2024-01-15T10:00:00Z"
}
```

List endpoints return paginated results:

```json theme={null}
{
  "items": [...],
  "total": 100,
  "page": 1,
  "page_size": 20
}
```

## Error Handling

Errors return appropriate HTTP status codes with details:

```json theme={null}
{
  "error": "validation_error",
  "message": "Invalid request parameters",
  "details": {
    "email": "must be a valid email address"
  }
}
```

### Status Codes

| Code  | Description                                            |
| ----- | ------------------------------------------------------ |
| `200` | Success                                                |
| `201` | Created                                                |
| `204` | No Content (successful deletion)                       |
| `400` | Bad Request - Invalid parameters                       |
| `401` | Unauthorized - Invalid/missing auth                    |
| `403` | Forbidden - Insufficient permissions                   |
| `404` | Not Found - Resource doesn't exist                     |
| `409` | Conflict - Resource already exists or version conflict |
| `429` | Too Many Requests - Rate limited                       |
| `500` | Internal Server Error                                  |

## Rate Limiting

API requests are rate limited per endpoint group:

| Endpoint Group   | Rate Limit   |
| ---------------- | ------------ |
| Authentication   | 10 req/min   |
| Dashboard        | 60 req/min   |
| Agents, API Keys | 100 req/min  |
| Edge API         | 1000 req/min |
| Streaming        | 10 req/min   |

When rate limited, the response includes headers:

```
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1705312800
Retry-After: 60
```

## Pagination

List endpoints support pagination:

| Parameter   | Type    | Default | Description              |
| ----------- | ------- | ------- | ------------------------ |
| `page`      | integer | 1       | Page number (1-indexed)  |
| `page_size` | integer | 20      | Items per page (max 100) |

Example:

```bash theme={null}
GET /api/v1/agents?page=2&page_size=50
```

## Timestamps

All timestamps use ISO 8601 format in UTC:

```
2024-01-15T10:30:00Z
```

## UUIDs

All resource IDs are UUIDs (v4):

```
550e8400-e29b-41d4-a716-446655440000
```
