# Update a library block

> Renames or re-tags a library entry, and/or REPLACES its content with a block of a trip (`fromTrip`: the same capture as saving; the block must be of the entry's type, else 422 `root_type_mismatch`; needs `trips:read`).

`PATCH /v1/library/entries/{entryId}`

Renames or re-tags a library entry, and/or REPLACES its content with a block of a trip (`fromTrip`: the same capture as saving; the block must be of the entry's type, else 422 `root_type_mismatch`; needs `trips:read`). A refresh is refused with 409 `being_edited` while the entry is open in the builder. Pass the `updatedAt` you read as `expectedUpdatedAt` to refuse a stale write with a 409. Undo with POST /changes/{changeId}/revert.

**Permissions:** `catalog:write` · **Kind:** write · **Cost:** 1 unit · MCP tool [`update_library_entry`](https://api.bymundi.com/docs/mcp/tools/update_library_entry.md)

Undoable: the response carries `Bymundi-Change-Id`; [revert it](https://api.bymundi.com/docs/guides/undo-and-dry-run.md) with `POST /v1/changes/{changeId}/revert`.

## Path parameters

| Field | Type | Required | Description |
|---|---|---|---|
| `entryId` | uuid | yes |  |

## Body

| Field | Type | Required | Description |
|---|---|---|---|
| `title` | string |  | max 200 chars |
| `tags` | string[] |  | Replaces the tags; lowercased. max 20 items |
| `fromTrip` | object |  |  |
| `fromTrip.tripId` | uuid | yes |  |
| `fromTrip.blockId` | string | yes | The block's id or its short ref from get_itinerary. max 64 chars |
| `expectedUpdatedAt` | datetime |  |  |

## Response `200`

| Field | Type | Required | Description |
|---|---|---|---|
| `object` | "library_entry" | yes |  |
| `id` | uuid | yes |  |
| `title` | string | yes |  |
| `rootType` | string | yes |  |
| `tags` | string[] | yes |  |
| `updatedAt` | string | yes |  |
| `snapshot` | object | yes |  |

## Errors

Errors are [problem details](https://api.bymundi.com/docs/guides/errors.md). Besides the refusals described above, any call like this one can return:

- [`invalid_request`](https://api.bymundi.com/problems/invalid_request.md) — Invalid request
- [`unauthorized`](https://api.bymundi.com/problems/unauthorized.md) — Missing or invalid API key
- [`insufficient_scope`](https://api.bymundi.com/problems/insufficient_scope.md) — Missing permission
- [`rate_limited`](https://api.bymundi.com/problems/rate_limited.md) — Rate limit reached
- [`not_found`](https://api.bymundi.com/problems/not_found.md) — Not found
- [`idempotency_key_reused`](https://api.bymundi.com/problems/idempotency_key_reused.md) — Idempotency-Key reused
- [`request_in_progress`](https://api.bymundi.com/problems/request_in_progress.md) — Request in progress

## Examples

#### curl

```bash
curl -X PATCH https://api.bymundi.com/v1/library/entries/$ENTRY_ID \
  -H "Authorization: Bearer $BYMUNDI_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{}'
```

#### JavaScript

```javascript
const res = await fetch(`https://api.bymundi.com/v1/library/entries/${entryId}`, {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.BYMUNDI_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": crypto.randomUUID(),
  },
  body: JSON.stringify({}),
});
if (!res.ok) throw new Error((await res.json()).detail);
const data = await res.json();
```

#### Python

```python
import os, uuid, requests

res = requests.patch(
    f"https://api.bymundi.com/v1/library/entries/{entryId}",
    headers={"Authorization": f"Bearer {os.environ['BYMUNDI_KEY']}", "Idempotency-Key": str(uuid.uuid4())},
    json={},
)
res.raise_for_status()
data = res.json()
```
