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

# Replicas

> Read how many replicas a dedicated endpoint is running and change its minimum and maximum, within your contract's ceiling, from the dashboard or the API.

A dedicated endpoint runs between a minimum and a maximum number of replicas. Active replicas follow your live traffic between the two. Requests beyond what your maximum can serve get a `429` with `Retry-After` right away; nothing is queued.

You can read the live count and change the minimum and maximum yourself, up to the ceiling in your contract:

* In the dashboard: open **Dedicated** at [app.wafer.ai](https://app.wafer.ai), pick the endpoint, and use **Edit min / max** in the Replicas panel. Where your contract bills by replica-hour, the dialog estimates what the new limits bill before you save. Account owners and admins can save.
* With the API below, using an API key from the account that owns the endpoint.

Changes apply within a minute.

> [!NOTE]
>
> Replica control is switched on per endpoint. If the Replicas panel says it isn't switched on, or the API returns `404` or `409` as described under [Errors](#errors), contact Wafer to turn it on.

## Read replicas

`GET https://api.wafer.ai/v1/dedicated/replicas/{endpoint}` returns the endpoint's limits and live state. `{endpoint}` is your endpoint's hostname. Any API key on the account that owns the endpoint can read it.

```bash theme={null}
curl -sS "https://api.wafer.ai/v1/dedicated/replicas/<YOUR_ENDPOINT_HOST>" \
  -H "Authorization: Bearer <YOUR_WAFER_API_KEY>"
```

```json theme={null}
{
  "endpoint": "acme.wafer.ai",
  "enabled": true,
  "min_replicas": 2,
  "max_replicas": 20,
  "ceiling_replicas": 32,
  "effective_ceiling_replicas": 32,
  "effective_max_replicas": 20,
  "state": "live",
  "active_replicas": 4,
  "healthy_capacity_replicas": 32,
  "inflight": 37,
  "active_capacity_inflight": 48,
  "max_capacity_inflight": 240,
  "per_replica_concurrency": {"primary": 12, "overflow": 12},
  "primary_replicas": 20,
  "shed_429_last_hour": 0,
  "capacity_degraded": false,
  "observed_at": "2026-10-13T17:04:12Z",
  "updated_at": "2026-10-12T21:30:00Z",
  "generation": 7
}
```

| Field | Meaning |
| - | - |
| `enabled` | `true` when you can change the limits yourself. |
| `min_replicas`, `max_replicas` | The limits now in force. |
| `ceiling_replicas` | The highest `max_replicas` your contract allows. |
| `effective_ceiling_replicas`, `effective_max_replicas` | The ceiling and maximum that can be served right now. Lower than the set values only while capacity is reduced. |
| `state` | `live`, `stale` (live data is delayed), or `no_data`. The live counts below are `null` when there is no data. |
| `active_replicas` | Replicas serving your traffic now. |
| `healthy_capacity_replicas` | Replicas that are healthy and could serve. |
| `inflight` | Requests in flight now. |
| `active_capacity_inflight`, `max_capacity_inflight` | Requests the active replicas, and your maximum, can serve at once. |
| `per_replica_concurrency` | Requests one replica serves at once. |
| `shed_429_last_hour` | Requests refused with `429` in the last hour because they were beyond your maximum. |
| `capacity_degraded` | `true` while fewer replicas are healthy than your minimum. |
| `generation` | Increases by one on every change to the limits. Send it back as `if_generation` to avoid overwriting someone else's change. |
| `observed_at`, `updated_at` | When the live counts were observed, and when the limits last changed. |

## Change the minimum and maximum

`PUT https://api.wafer.ai/v1/dedicated/replicas/{endpoint}` sets both limits and returns the same object as the read. The API key must be enabled for replica management: ask Wafer to enable it for the key you want to automate with. Other keys on the account can read but get a `403` on a change.

```bash theme={null}
curl -sS -X PUT "https://api.wafer.ai/v1/dedicated/replicas/<YOUR_ENDPOINT_HOST>" \
  -H "Authorization: Bearer <YOUR_WAFER_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{"min_replicas": 4, "max_replicas": 20, "if_generation": 7}'
```

| Field | Meaning |
| - | - |
| `min_replicas` | Required. Replicas kept ready at all times. `0` or more, and no more than `max_replicas`. |
| `max_replicas` | Required. The most replicas your traffic can use. At least `1`, and no more than `ceiling_replicas`. |
| `if_generation` | Optional. The `generation` you last read. The change is refused with `409` if the limits changed since. |

The limits are checked on the server on every change. A request outside them is refused and changes nothing. To raise your ceiling, contact Wafer.

## What a change bills

Your contract sets how dedicated capacity is billed. Where it bills by replica-hour, you are billed for the replicas active each hour, from `min_replicas` up to `max_replicas`. While fewer than `min_replicas` are healthy, you are billed only for the healthy ones. At full capacity, raising the minimum raises the least you are billed each hour; raising the maximum raises the most.

Where your contract bills by replica-hour, the **Billing** page at [app.wafer.ai](https://app.wafer.ai) shows your rate, spend per day, and month to date, and the limits dialog on the **Dedicated** page estimates a change per hour and per 30 days, at full capacity and today's rate, before you save it. Otherwise the dialog shows no bill figures: your contract sets whether the limits change your bill.

## Replica history

`GET https://api.wafer.ai/v1/dedicated/replicas/{endpoint}/history?days=30` returns the limits and active replicas over time. `days` is `1` to `90` and defaults to `30`. `steps` is sampled, not a complete change log: after the first step in the window, at most the last change in each time bucket is kept. Buckets are 5 minutes for up to 2 days, 1 hour for up to 14 days, and 6 hours beyond that.

```bash theme={null}
curl -sS "https://api.wafer.ai/v1/dedicated/replicas/<YOUR_ENDPOINT_HOST>/history?days=7" \
  -H "Authorization: Bearer <YOUR_WAFER_API_KEY>"
```

| Field | Meaning |
| - | - |
| `since` | Start of the window returned. |
| `steps` | Sampled changes to the limits: `applied_at`, `min_replicas`, `max_replicas`. |
| `bounds` | The limits as observed over time: `observed_at`, `min_replicas`, `max_replicas`. |
| `active` | Active replicas over time: `observed_at`, `active`. |
| `active_since` | When active-replica observations begin, or `null` if there are none. |
| `truncated` | `true` when the window holds more changes than can be read and the earliest are left out. |
| `covers_since` | `true` when `steps` includes the limits already in force at `since`. |

## Errors

Every error is JSON with one `error` object:

```json theme={null}
{
  "error": {
    "type": "invalid_request_error",
    "code": "http_422",
    "message": "max_replicas must be at most 32 for this endpoint",
    "request_id": "<REQUEST_ID>"
  }
}
```

`message` says what was refused. `code` is `http_<status>` unless the table names another. `request_id` is included when the request has one; quote it when you contact Wafer.

| Status | `type` | Meaning |
| - | - | - |
| `401` | `authentication_error` | The API key is missing or invalid. |
| `403` | `permission_error` | The key's account doesn't own this endpoint, or, on a change, the key isn't enabled for replica management. |
| `404` | `not_found_error` | Replica control isn't available for this endpoint. |
| `409` | `conflict_error` | Replica control is turned off for this endpoint, or the limits changed since the `if_generation` you sent. Read again and retry. |
| `422` | `invalid_request_error` | The limits break a rule: `min_replicas` above `max_replicas`, `max_replicas` below `1` or above `ceiling_replicas`. |
| `422` | `invalid_request_error` | The request doesn't match the schema: a missing or unknown body field, a value that isn't a whole number from `0` to `256`, or `days` outside `1` to `90`. `code` is `schema_validation_failed` and `param` names the field. Further problems are listed in `additional_errors`, each with `param` and `message`. |
| `429` | `rate_limit_error` | Too many requests. `code` is `rate_limit_exceeded`. Reads allow 60 per minute per key; changes allow 10 per minute per key. Retry after the minute window resets. |
