# pages.reference_action

`POST /api/public/v1/sessions/{id}/reference-action`

Queue a scoped reference action; unsupported dispatch fails closed.

- Capability: `agent.act`
- Command (idempotent): No
- Idempotency: resend the same `idempotency_key` on retry; never generate a new key.
- MCP tool: `pages_reference_action`

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string (uuid) | Yes |  |
| `idempotency_key` | body | string | Yes | (min length 1, max length 163) |
| `target_id` | body | string | Yes | (min length 1, max length 128) |
| `epoch` | body | integer | Yes | (max 9007199254740991) |
| `snapshot_id` | body | integer | Yes | (max 9007199254740991) |
| `reference_id` | body | string | Yes | (max length 64) |
| `action` | body | object | 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 |
| `DEPENDENCY_UNAVAILABLE` | 503 | Yes |
| `UNKNOWN` | 500 | No |

## Examples (curl)

```bash
curl -X POST "https://browlix.com/api/public/v1/sessions/<id>/reference-action" \
  -H "Authorization: Bearer $BROWLIX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"idempotency_key":"<idempotency_key>","target_id":"<target_id>","epoch":0,"snapshot_id":0,"reference_id":"<reference_id>","action":{}}'
```

## Examples (TypeScript SDK)

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

const bx = new Browlix({ apiKey: process.env.BROWLIX_API_KEY! });
const reply = await bx.call("pages.reference_action", { path: { id: "<id>" }, body: {"idempotency_key":"<idempotency_key>","target_id":"<target_id>","epoch":0,"snapshot_id":0,"reference_id":"<reference_id>","action":{}} });
console.log(reply.data);
```

## Examples (Python)

```python
import os
import requests

r = requests.post(
    "https://browlix.com/api/public/v1/sessions/<id>/reference-action",
    headers={"Authorization": f"Bearer {os.environ['BROWLIX_API_KEY']}"},
    json={"idempotency_key":"<idempotency_key>","target_id":"<target_id>","epoch":0,"snapshot_id":0,"reference_id":"<reference_id>","action":{}},
    timeout=60,
)
print(r.status_code, r.json())
```

## Examples (MCP)

```json
{
  "method": "tools/call",
  "params": {
    "name": "pages_reference_action",
    "arguments": {
      "id": "<id>",
      "idempotency_key": "<idempotency_key>",
      "target_id": "<target_id>",
      "epoch": 0,
      "snapshot_id": 0,
      "reference_id": "<reference_id>",
      "action": {}
    }
  }
}
```
