# bookmarks.apply

`POST /api/public/v1/bookmarks/imports/{id}/apply`

Queue an import on up to 500 profiles; each profile applies it through its browser's own bookmarks at its next start. merge adds links not already in the target folder; replace first empties the target (one bookmarks-bar folder, or the whole bar and other bookmarks). Per profile: queued, conflict (its rev changed since your preview; nothing queued) or not_found.

- Capability: `bookmark.import`
- Command: yes — send a `command_id`; resending the same id and body returns the stored receipt
- MCP tool: `bookmarks_apply`

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string (uuid) | yes | Bookmark import 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. |
| `mode` | body | "merge" \| "replace" | yes | merge: add links not already there; replace: empty the target first |
| `scope` | body | "folder" \| "all" | yes | folder: everything goes into one bookmarks-bar folder (created if missing); all: the bar and other bookmarks as in the file |
| `folder` | body | string | no | scope=folder: the bookmarks-bar folder name (min length 1, max length 120) |
| `targets` | body | array<object> | yes | (min 1 items, max 500 items) |

## Response

`201` with `{ data, replayed: false, correlation_id }` the first time; `200` with `replayed: true` for a repeated `command_id`.

| Field | Type | Always present | Description |
|---|---|---|---|
| `data` | object | yes |  |
| `data.results` | array<object> | yes |  |
| `data.results[].profile_id` | string (uuid) | yes |  |
| `data.results[].state` | "queued" \| "conflict" \| "not_found" | yes |  |
| `data.results[].op_id` | string (uuid) | no |  |
| `data.results[].rev` | integer | no | (min -9007199254740991, max 9007199254740991) |
| `data.queued` | integer | yes | (min -9007199254740991, max 9007199254740991) |
| `data.conflicts` | integer | yes | (min -9007199254740991, max 9007199254740991) |
| `data.not_found` | integer | yes | (min -9007199254740991, max 9007199254740991) |
| `correlation_id` | string (uuid) | yes |  |
| `replayed` | boolean | no | true when this command_id was already applied and the stored receipt came back |

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 |
| `DEPENDENCY_UNAVAILABLE` | 503 | yes |
| `UNKNOWN` | 500 | no |

## Example (curl)

```bash
curl -X POST "https://browlix.com/api/public/v1/bookmarks/imports/<id>/apply" \
  -H "Authorization: Bearer $BROWLIX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"command_id":"<uuid>","mode":"merge","scope":"folder","targets":[]}'
```

## Example (TypeScript SDK)

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

const bx = new Browlix({ apiKey: process.env.BROWLIX_API_KEY! });
const reply = await bx.call("bookmarks.apply", { path: { id: "<id>" }, body: {"mode":"merge","scope":"folder","targets":[]} });
console.log(reply.data);
```

## Example (Python)

```python
import os, uuid
import requests

r = requests.post(
    "https://browlix.com/api/public/v1/bookmarks/imports/<id>/apply",
    headers={"Authorization": f"Bearer {os.environ['BROWLIX_API_KEY']}"},
    json={"command_id":str(uuid.uuid4()),"mode":"merge","scope":"folder","targets":[]},
    timeout=60,
)
print(r.status_code, r.json())
```

## Example (MCP)

```json
{
  "method": "tools/call",
  "params": {
    "name": "bookmarks_apply",
    "arguments": {
      "id": "<id>",
      "mode": "merge",
      "scope": "folder",
      "targets": []
    }
  }
}
```
