# pages.reference_action

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

Yêu cầu thao tác bằng tham chiếu; từ chối nếu chưa hỗ trợ.

- Quyền: `agent.act`
- Lệnh (chống trùng): Không
- Chống trùng: gửi cùng `idempotency_key` khi thử lại; không tạo khóa mới.
- Tool MCP: `pages_reference_action`

## Tham số

| Tên | Vị trí | Kiểu | Bắt buộc | Mô tả |
|---|---|---|---|---|
| `id` | path | string (uuid) | Có |  |
| `idempotency_key` | body | string | Có | (độ dài tối thiểu 1, độ dài tối đa 163) |
| `target_id` | body | string | Có | (độ dài tối thiểu 1, độ dài tối đa 128) |
| `epoch` | body | integer | Có | (tối đa 9007199254740991) |
| `snapshot_id` | body | integer | Có | (tối đa 9007199254740991) |
| `reference_id` | body | string | Có | (độ dài tối đa 64) |
| `action` | body | object | Có |  |

## Phản hồi

`200` với `{ ok, data, operation_id, state_version, retryable, next }`; kết quả chấp nhận lệnh không chứng minh worker hoàn tất.

| Trường | Kiểu | Luôn có | Mô tả |
|---|---|---|---|
| `operation_id` | string (uuid) \| null | Có |  |
| `state_version` | integer | Có | (tối thiểu 0, tối đa 9007199254740991) |
| `retryable` | false | Có |  |
| `next` | object \| null | Có |  |
| `next.operation` | "operations.get" | Có |  |
| `next.operation_id` | string (uuid) | Có |  |
| `ok` | true | Có |  |
| `data` | object | Có |  |

Trường mới có thể xuất hiện bất cứ lúc nào; hãy bỏ qua trường bạn không biết.

## Lỗi

| Mã | HTTP | Thử lại |
|---|---|---|
| `UNAUTHENTICATED` | 401 | Không |
| `FORBIDDEN` | 403 | Không |
| `RATE_LIMITED` | 429 | Có |
| `VALIDATION_FAILED` | 422 | Không |
| `NOT_FOUND` | 404 | Không |
| `DEPENDENCY_UNAVAILABLE` | 503 | Có |
| `UNKNOWN` | 500 | Không |

## Ví dụ (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":{}}'
```

## Ví dụ (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);
```

## Ví dụ (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())
```

## Ví dụ (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": {}
    }
  }
}
```
