> ## Documentation Index
> Fetch the complete documentation index at: https://weights.fyi/run/llms.txt

# POST /v1/nodes/{node_id}/drain

```text
POST https://weights.fyi/run/v1/nodes/<node_id>/drain
Authorization: Bearer <token>                    scope: manage
[{"reason": "<why>"}]
```

**Available since:** Not available yet: built on 2026-11-16, live with the deploy that carries it. Answered only where this service enrolls your own workers (otherwise the path answers 404); see [Bring your own model](/run/docs/your-model.md).

**Answer time:** synchronous: the drain is recorded at once; the worker stops after the calls it holds are answered.

Gets one of your workers ready to be switched off. The service offers it no new call at once, and calls it already took run to their end and are answered as usual. The `weights` agent on the computer then closes its connection and stops; `open_sessions` reads 0 once it has. A call the worker had not yet started is handed back and answered by another worker of the model, where there is one.

A drained worker serves again on its agent's first start after [resume](/run/docs/reference/workers-resume.md); started before the resume, the agent stops again at once. An agent older than this call does not stop by itself: it stays connected and receives no call, as on a [pause](/run/docs/reference/workers-pause.md), until it is resumed or stopped. The call is safe to repeat: a worker already draining answers the same worker again.

## Request

| Name | Where | Required | Meaning |
|---|---|---|---|
| `Authorization` | header | yes | `Bearer` and a token with `manage`. |
| `node_id` | path | yes | The worker's `id` from [`GET /v1/nodes`](/run/docs/reference/workers-list.md), a UUID. |
| `reason` | body | no | Why, for your own record: at most 512 characters. Left out, "drained by the workspace" is recorded. |

## Return value

**200 OK** with the worker as [`GET /v1/nodes`](/run/docs/reference/workers-list.md) lists it:

| Field | Meaning |
|---|---|
| `serving` | `draining`. |
| `serving_changed_at`, `serving_reason` | When it changed and the reason recorded; the first change's, when the call is repeated. |
| `open_sessions` | Read as the change is recorded, so it can still count a connection that closes a moment later. |
| the rest | `id`, `workspace_id`, `name`, `status`, `join_token_id`, `facts`, `region`, `spki_sha256`, `enrolled_at`, `revoked_at` and `offers`, unchanged. |

## Errors

| Status | Code | When it happens | What to do |
|---|---|---|---|
| `400` | `invalid_reason`, `invalid_json` | `reason` is not text or is longer than 512 characters, or the body is not JSON. | Fix the body, or send none. |
| `401` | `unauthorized`, `invalid_token`, `token_revoked`, `token_expired` | No token, or one that does not work (any more). | Use a valid token. |
| `403` | `scope_required`, `account_suspended` | The token lacks `manage`, or the account is suspended. | Use a token with `manage`. |
| `403` | `node_revoked` | The worker was revoked: it never serves again. | Enroll the computer again with a new join token. |
| `404` | `node_not_found` | Your workspace has no worker of that id, or the id is not a UUID. | Use an `id` from the worker list. |
| `413` | `body_too_large` | The body is over the small-body limit. | Send a shorter reason. |
| `503` | `byoc_unavailable` | Worker enrollment is not available on this service right now. | Retry later. |

## Examples

```sh
curl -s https://weights.fyi/run/v1/nodes/NODE_ID/drain -H "Authorization: Bearer $WEIGHTS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"reason": "switching it off for the trip"}'
```

```json
{"id": "0b6f3c52-8f0e-4b57-9a54-3f1c2d7e9a10", "workspace_id": 7, "name": "studio-1", "status": "active",
 "join_token_id": 12, "facts": {"agent_version": "...", "platform": "Linux-aarch64"}, "region": null,
 "spki_sha256": "5f2c1b9e8a7d6c4b3a29180f7e6d5c4b3a2918f7e6d5c4b3a29180f7e6d5c4b3",
 "enrolled_at": "2026-11-14T09:30:00+00:00", "revoked_at": null, "serving": "draining",
 "serving_changed_at": "2026-11-16T18:00:00+00:00", "serving_reason": "switching it off for the trip", "open_sessions": 1,
 "offers": [
   {"model": "almanakje-gemma3-12b", "backend_kind": "openai", "upstream_model": "gemma3:12b", "max_in_flight": 4,
    "call_timeout_seconds": 300.0, "modalities": ["text"], "region": null, "status": "published",
    "pool": "byoc-7-almanakje-gemma3-12b", "priority": 1, "chat_fields": ["tools", "tool_choice"]}
 ]}
```

## History

- 2026-11-16 (built, live with the deploy that carries it): drain a worker.

## See also

- [`POST /v1/nodes/{node_id}/resume`](/run/docs/reference/workers-resume.md) to serve again.
- [`POST /v1/nodes/{node_id}/pause`](/run/docs/reference/workers-pause.md) to keep the agent connected instead.
- [Bring your own model](/run/docs/your-model.md), the topic.
