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

# Admin API

> Runtime backend management API

## Overview

Secure API for managing backends without restart.

## Authentication

Add `X-API-Key` header when API key is configured:

```bash theme={null}
curl -H "X-API-Key: YOUR_KEY" http://localhost:8080/admin/backends
```

## Endpoints

| Method | Endpoint                  | Description       |
| ------ | ------------------------- | ----------------- |
| GET    | `/admin/backends`         | List all backends |
| POST   | `/admin/backends`         | Add backend       |
| DELETE | `/admin/backends`         | Remove backend    |
| PUT    | `/admin/backends/weight`  | Update weight     |
| POST   | `/admin/backends/drain`   | Start draining    |
| POST   | `/admin/backends/undrain` | Stop draining     |
| GET    | `/admin/health`           | API health check  |

## Examples

```bash theme={null}
# List backends
curl -H "X-API-Key: YOUR_KEY" http://localhost:8080/admin/backends

# Add backend
curl -X POST -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"address":"10.0.0.5:8080","weight":100}' \
  http://localhost:8080/admin/backends

# Update weight
curl -X PUT -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"address":"10.0.0.5:8080","weight":150}' \
  http://localhost:8080/admin/backends/weight

# Drain for maintenance
curl -X POST -H "X-API-Key: YOUR_KEY" \
  -d '{"address":"10.0.0.5:8080"}' \
  http://localhost:8080/admin/backends/drain
```

## Response Format

```json theme={null}
{
  "success": true,
  "message": "Backends listed",
  "data": [
    {
      "address": "10.0.0.1:8080",
      "weight": 100,
      "healthy": true,
      "active_connections": 5,
      "total_requests": 1234
    }
  ]
}
```

## Error Response

```json theme={null}
{
  "success": false,
  "message": "Backend not found"
}
```
