Writes, idempotency and errors
Apply atomic changes, retry safely and respond to Pigeon API errors.
On this page
Submit an operation
Send a JSON object containing mutations to POST /v1/operations with a nonempty Idempotency-Key header. Each mutation uses one action. The Hub assigns record IDs, revision pairs, clock fields and origin. For existing records, pass the exact revision pair you edited in base.revision and base.revision_op.
Create
Use a durable UUID as create_id, the registered kind, its exact schema and a kind body. A typed reference can use another mutation's create_id as a temporary target. The Hub rewrites it to the assigned record ID. Creation order does not matter, and a batch can contain cycles. An unavailable planned target or invalid typed reference rejects the operation. Writes may claim external IDs only in the caller's authorized namespace.
{
"mutations": [
{
"action": "create",
"create_id": "01936f3e-0f00-7a11-8c22-0b6a11aa0001",
"kind": "note",
"schema": "note@1.0",
"body": {
"title": "Garden",
"summary": "Working notes",
"sections": [],
"links": [],
"entities": [],
"guessed_kind": "guide",
"tags": []
}
}
]
}Patch
Prefer a patch for targeted edits. Omitted keys leave the value untouched. Field objects merge recursively, scalars and atomic lists replace as a unit, and a modeled field set to null clears it. The final body must still meet the kind rules. Use part_ops for addressable lists. An insert has parent, list, a canonical part value, and optional after. Omit after to insert or move first. Address the root with $root. Supply a unique part id inside value or let the Hub assign it. Move, remove and part-field patch operations address a part by ID. Use the part map to find addressable lists and singleton parts.
{
"mutations": [
{
"action": "patch",
"id": "01936f3e-5b7a-7c1d-9a40-2f1c8e0b6a11",
"base": {
"revision": 7,
"revision_op": "01936f40-2c11-7a00-8b2e-55aa10c4e001"
},
"conflict": "strict",
"fields": {
"title": "Garden notes"
},
"part_ops": [
{
"op": "insert",
"parent": "$root",
"list": "sections",
"value": {
"heading": "Watering",
"bullets": [
"Check on Fridays"
]
}
}
]
}
]
}Update
Send a valid complete kind body. The Hub computes intent relative to the supplied base, so omitting a caller-owned field from the base requests its removal. Concurrent additions absent from the base have no removal intent. Server metadata, protected lineage and omitted state survive. Fetch and use a full record for a replacement.
{
"mutations": [
{
"action": "update",
"id": "01936f3e-5b7a-7c1d-9a40-2f1c8e0b6a11",
"base": {
"revision": 7,
"revision_op": "01936f40-2c11-7a00-8b2e-55aa10c4e001"
},
"body": {
"title": "Garden notes",
"summary": "Working notes",
"sections": [],
"links": [],
"entities": [],
"guessed_kind": "guide",
"tags": []
}
}
]
}Delete
This action removes the caller’s link. If it was the final link, the Hub tombstones the record. Pigeon also gives the owner a separate whole-record deletion action. A retry or write against a tombstone can report gone.
{
"mutations": [
{
"action": "delete",
"id": "01936f3e-5b7a-7c1d-9a40-2f1c8e0b6a11",
"base": {
"revision": 7,
"revision_op": "01936f40-2c11-7a00-8b2e-55aa10c4e001"
}
}
]
}Reset to source
For a separate source-backed note with a current base, pass reset addresses on a patch to return edited fields, lists or parts to the source. Omit part for a root field or list. Use a part ID alone for a whole part, or part: "$root" alone for the whole source-backed body. A field address can include a nested path. The Hub applies resets before other field and part edits and rejects overlapping intent. State survives unless explicitly supplied.
{
"mutations": [
{
"action": "patch",
"id": "01936f3e-5b7a-7c1d-9a40-2f1c8e0b6a27",
"base": {
"revision": 8,
"revision_op": "01936f40-2c11-7a00-8b2e-55aa10c4e002"
},
"reset": [
{
"field": "title"
}
]
}
]
}Patch account state
Use state_patch for intent from an editor or a queued offline device. A patch can also include body fields, Part operations and a reset. Supply at most 1,000 state intents across the operation. Use each address once per patch. A whole-key operation also occupies any entry or member addresses under that key.
| Intent | Meaning |
|---|---|
set, remove | Store a JSON value at key or clear the key. JSON null is a stored value where the key accepts it. |
set_entry, remove_entry | Set or clear one entry in recipe cooked or media episodes. A repeated removal has no effect. |
add_member, remove_member | Add or remove a member of tags or guide completed_stop_ids. Tags trim surrounding whitespace, normalize to NFC and match case-insensitively. A new guide mark must name a stop in the resulting guide. Use fresh Part IDs for new stops. A reset can restore the original stop ID. |
merge_experience | Merge the supplied value into place experience. Compare each updated_at by instant, then break ties by canonical JSON UTF-8 order. The earliest opened_at survives. Merged timestamps use UTC. Clear a visit date or rating with a timestamped null and a note with a timestamped empty string. |
Use the record's base revision pair. With a known stale base, disjoint edits survive and conflicting key, entry or member writes follow commit order. History records overwritten values by address. Strict patches require the current pair. Unknown revision pairs return base_unknown. Reconcile before resubmitting. An intent that leaves everything unchanged returns unchanged without a new revision.
Choose state to replace caller-owned keys. A replacement preserves omitted server-owned send values. Changing a server-owned value or addressing it in state_patch returns server_owned_field. Combining state and state_patch returns patch_invalid. The final map must fit in 64 KiB of compact UTF-8 JSON. If another device used the available space, the write returns state_too_large and keeps the committed state intact. Keep the local intent, refresh the record and remove state or revise the edit before retrying.
{
"mutations": [
{
"action": "patch",
"id": "01936f3e-5b7a-7c1d-9a40-2f1c8e0b6a11",
"base": {
"revision": 7,
"revision_op": "01936f40-2c11-7a00-8b2e-55aa10c4e001"
},
"state_patch": [
{
"op": "set",
"key": "pinned",
"value": true
},
{
"op": "remove",
"key": "connector_draft"
},
{
"op": "add_member",
"key": "tags",
"member": "Weekends"
},
{
"op": "remove_member",
"key": "tags",
"member": "Summer"
},
{
"op": "merge_experience",
"value": {
"version": 1,
"opened_at": "2026-11-30T14:00:00-05:00",
"visits": {
"current": {
"date": {
"value": "2026-11-30",
"updated_at": "2026-11-30T14:00:00-05:00"
},
"rating": {
"value": null,
"updated_at": "2026-11-30T14:00:00-05:00"
},
"note": {
"value": "",
"updated_at": "2026-11-30T14:00:00-05:00"
}
}
}
}
}
]
},
{
"action": "patch",
"id": "01936f3e-5b7a-7c1d-9a40-2f1c8e0b6a12",
"base": {
"revision": 7,
"revision_op": "01936f40-2c11-7a00-8b2e-55aa10c4e001"
},
"state_patch": [
{
"op": "set_entry",
"key": "cooked",
"entry": "cook-2",
"value": {
"at": "2026-11-30T14:00:00-05:00",
"scale": 2,
"notes": "Use the large pan."
}
},
{
"op": "remove_entry",
"key": "cooked",
"entry": "cook-1"
}
]
},
{
"action": "patch",
"id": "01936f3e-5b7a-7c1d-9a40-2f1c8e0b6a13",
"base": {
"revision": 7,
"revision_op": "01936f40-2c11-7a00-8b2e-55aa10c4e001"
},
"state_patch": [
{
"op": "set_entry",
"key": "episodes",
"entry": "s1e2",
"value": "2026-11-30T14:00:00-05:00"
}
]
},
{
"action": "patch",
"id": "01936f3e-5b7a-7c1d-9a40-2f1c8e0b6a14",
"base": {
"revision": 7,
"revision_op": "01936f40-2c11-7a00-8b2e-55aa10c4e001"
},
"state_patch": [
{
"op": "add_member",
"key": "completed_stop_ids",
"member": "museum"
}
]
}
]
}Interpret a receipt
The receipt has one entry per mutation. Read results[].outcome even on HTTP 200. The record, when present, uses the complete canonical read envelope. inserted_part_ids returns the IDs assigned or accepted for the patch's inserts in request order. The example follows the patch above.
{
"op": "01936f40-2c11-7a00-8b2e-55aa10c4e002",
"seq": 81,
"results": [
{
"id": "01936f3e-5b7a-7c1d-9a40-2f1c8e0b6a11",
"outcome": "applied",
"record": {
"id": "01936f3e-5b7a-7c1d-9a40-2f1c8e0b6a11",
"create_id": "01936f3e-0f00-7a11-8c22-0b6a11aa0001",
"kind": "note",
"schema": "note@1.0",
"revision": 8,
"revision_op": "01936f40-2c11-7a00-8b2e-55aa10c4e002",
"account": "0194ab00-0000-7000-8000-000000000001",
"created_at": "2026-01-01T00:00:00Z",
"updated_at": "2026-01-01T00:00:00Z",
"origin": {
"connection": "cnx_0194ab00-0000-7000-8000-000000000001",
"app": "demo"
},
"home": "demo",
"external_ids": [],
"provenance": {},
"relations": [],
"flags": [],
"gaps": [],
"body": {
"title": "Garden notes",
"summary": "Working notes",
"sections": [
{
"id": "c47e2420-0ce1-44e0-8b33-ad9e613b48b7",
"heading": "Watering",
"bullets": [
"Check on Fridays"
]
},
{
"id": "soil",
"heading": "Soil",
"bullets": [
"Add compost"
]
}
],
"links": [],
"entities": [],
"guessed_kind": "guide",
"tags": []
},
"state": {}
},
"inserted_part_ids": [
"c47e2420-0ce1-44e0-8b33-ad9e613b48b7"
]
}
]
}created, applied and merged describe committed record writes. unchanged means the resolved record did not change. conflict can include applicable changes and a retained conflict copy for the rest. unlinked and deleted describe removal. exists and gone also cover durable create-ID lookup. The shared receipt also represents explicit conflict or restore actions. A replay can report not_found for a result that the caller can no longer read.
Supply conflict: "strict" to reject a stale revision instead of requesting merge. Refresh the record when a write returns revision_conflict or base_unknown. Request errors roll back the operation. A send or write can return response_too_large after the result exists when re-reading a receipt, so retain the original key and reconcile uncertain writes through the feed.
Retry the same intent safely
Persist the exact request, key and create IDs. Reuse them when retrying. The seven-day key window is scoped to the account and connection. A different request under the same key returns idempotency_key_reused. A reused create ID with a new key or after expiry still resolves to exists or gone without editing the record. Generate a new create ID for a new record. A retry of POST /v1/sends with the same key and retry_of replays the committed receipt even if the earlier failed send has changed or been deleted.
Handle a problem response
Read the HTTP status and the code in the Hub problem. Keep the request-id response header for troubleshooting. Missing records, records in another account and records you cannot read all return the same not_found response. Search and browse omit unreadable records. Readable sends omit unreadable result targets, their result gaps and unreadable relations. Following a typed reference does not grant read access. A new reference to a missing, unreadable or deleted record returns 422 dangling_reference. A malformed UUID in a record or snapshot URL returns 422 invalid_id.
{
"type": "about:blank",
"title": "not_found",
"status": 404,
"code": "not_found"
}Runtime checks, status codes and limits · Request and receipt schemas