# workers.provision_preview_request

`POST /api/public/v1/workers/{id}/provision/preview`

Request the same exact host snapshot as the UI; UNSUPPORTED when worker cannot preview, BUSY while sessions run.

- Capability: `device.manage`
- Command (idempotent): yes — send a `command_id`; resending the same id and body returns the stored receipt
- Idempotency: resend the same `idempotency_key` on retry; never generate a new key.
- MCP tool: `workers_provision_preview_request`

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string (uuid) | Yes | Device id |
| `command_id` | body | string (uuid) | Yes | Client-generated UUID for this command. Send the same id (and body) again to get the stored receipt instead of a second change; a different body under the same id is CONFLICT. |
| `idempotency_key` | body | string | No | (min length 1, max length 163) |
| `action` | body | "apply" \| "undo" | Yes |  |

## Response

`200` with `{ ok, data, operation_id, state_version, retryable, next }`; command admission does not prove worker completion.

| Field | Type | Always present | Description |
|---|---|---|---|
| `operation_id` | string (uuid) \| null | Yes |  |
| `state_version` | integer | Yes | (min 0, max 9007199254740991) |
| `retryable` | false | Yes |  |
| `next` | object \| null | Yes |  |
| `next.operation` | "operations.get" | Yes |  |
| `next.operation_id` | string (uuid) | Yes |  |
| `ok` | true | Yes |  |
| `data` | object | Yes |  |

New fields can appear at any time; ignore the ones you do not know.

## Errors

| Code | HTTP | Retryable |
|---|---|---|
| `UNAUTHENTICATED` | 401 | No |
| `FORBIDDEN` | 403 | No |
| `RATE_LIMITED` | 429 | Yes |
| `VALIDATION_FAILED` | 422 | No |
| `NOT_FOUND` | 404 | No |
| `CONFLICT` | 409 | No |
| `OUTCOME_UNKNOWN` | 202 | Yes |
| `ACTION_OUTCOME_UNKNOWN` | 202 | No |
| `IDEMPOTENCY_KEY_REUSED` | 409 | No |
| `BUSY` | 409 | Yes |
| `UNSUPPORTED` | 501 | No |
| `DEPENDENCY_UNAVAILABLE` | 503 | Yes |
| `UNKNOWN` | 500 | No |

## Examples (curl)

```bash
curl -X POST "https://browlix.com/api/public/v1/workers/<id>/provision/preview" \
  -H "Authorization: Bearer $BROWLIX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"command_id":"<uuid>","action":"apply"}'
```

## Examples (TypeScript SDK)

```ts
import { Browlix } from "@browlix/sdk";

const bx = new Browlix({ apiKey: process.env.BROWLIX_API_KEY! });
const reply = await bx.call("workers.provision_preview_request", { path: { id: "<id>" }, body: {"action":"apply"} });
console.log(reply.data);
```

## Examples (Python)

```python
import os, uuid
import requests

r = requests.post(
    "https://browlix.com/api/public/v1/workers/<id>/provision/preview",
    headers={"Authorization": f"Bearer {os.environ['BROWLIX_API_KEY']}"},
    json={"command_id":str(uuid.uuid4()),"action":"apply"},
    timeout=60,
)
print(r.status_code, r.json())
```

## Examples (MCP)

```json
{
  "method": "tools/call",
  "params": {
    "name": "workers_provision_preview_request",
    "arguments": {
      "id": "<id>",
      "action": "apply"
    }
  }
}
```
