{
  "applyOperation": {
    "post": {
      "operationId": "applyOperation",
      "tags": ["Operations"],
      "summary": "Apply an atomic batch of mutations",
      "description": "Create a canonical kind, update its body relative to a revision base, patch fields or addressable parts, or unlink with delete. A patch can reset owner-edited addresses to the source at the current base. Reset addresses and other changes commit in one revision. Omitted state stays unchanged. A connector with ordinary record write access can supply either a replacement state map or state_patch intents on a patch. State intents merge against the current map under the account lock and share the final 64 KiB state limit. A replacement preserves omitted server-owned send values. Attempts to change or clear them return 422 server_owned_field. Fields merge recursively and null clears a modeled field. References to create IDs resolve within the same operation. Retain each create ID across retries. Reusing it returns exists or gone. The Idempotency-Key replays the original authorized receipt for seven days in the same account and connection. A replay result that is no longer readable has outcome not_found and omits the record. Assistant-only grants allow strict patches to supported editable kinds.",
      "parameters": [
        {"$ref": "../components/parameters.yaml#/IdempotencyKey"},
        {
          "name": "batch",
          "in": "query",
          "schema": {
            "type": "boolean",
            "default": false
          },
          "description": "Mark this as a Pro batch operation."
        }
      ],
      "requestBody": {
        "required": true,
        "content": {
          "application/json": {
            "schema": {"$ref": "../components/schemas.yaml#/OperationInput"},
            "examples": {
              "resetToSource": {
                "summary": "Return the title to the source and edit the summary",
                "value": {
                  "mutations": [{
                    "action": "patch",
                    "id": "0194ab00-0000-7000-8000-000000000001",
                    "base": {"revision": 3, "revision_op": "0194ab00-0000-7000-8000-000000000002"},
                    "reset": [{"field": "title"}],
                    "fields": {"summary": "Bring this to the next planning meeting."}
                  }]
                }
              }
            }
          }
        }
      },
      "x-route-error-codes": {"403": ["namespace_denied", "write_scope_required"], "404": ["not_found"], "409": ["base_unknown", "grocery_list_exists", "invalid_deletion_target", "preferences_exists", "reset_conflict", "reset_dependency", "revision_conflict"], "410": ["history_expired"], "413": ["body_too_large", "reference_work_exceeded", "state_too_large"], "422": ["assistant_edit_shape", "base_required", "body_identity_changed", "body_invalid", "create_reference_unavailable", "dangling_reference", "duplicate_create_id", "idempotency_key_reused", "immutable_record", "invalid_body", "invalid_operation", "invalid_request", "invalid_state", "lineage_protected", "patch_invalid", "pre_tombstone_fanout_limit", "pre_tombstone_scan_limit", "record_identity_changed", "reference_hash_mismatch", "reference_kind_mismatch", "reference_part_mismatch", "reset_invalid", "reset_no_upstream", "reset_not_edited", "too_many_external_ids", "unsupported_schema"], "429": ["daily_edit_cap_reached"], "503": ["history_corrupt", "ledger_unavailable"]},
      "responses": {
        "200": {
          "description": "Successful response.",
          "headers": {
            "request-id": {"$ref": "../components/headers.yaml#/RequestId"},
            "Cache-Control": {"$ref": "../components/headers.yaml#/CacheControl"}
          },
          "content": {"application/json": {"schema": {"$ref": "../components/schemas.yaml#/OperationReceipt"}}}
        },
        "400": {
          "description": "The request could not be parsed or contains an invalid parameter.",
          "headers": {"request-id": {"$ref": "../components/headers.yaml#/RequestId"}, "Cache-Control": {"$ref": "../components/headers.yaml#/CacheControl"}},
          "content": {"application/problem+json": {"schema": {"$ref": "../components/schemas.yaml#/Problem"}}},
          "x-error-codes": ["invalid_json"]
        },
        "401": {
          "description": "The credential is missing, invalid or tied to a superseded grant.",
          "headers": {"request-id": {"$ref": "../components/headers.yaml#/RequestId"}, "Cache-Control": {"$ref": "../components/headers.yaml#/CacheControl"}},
          "content": {"application/problem+json": {"schema": {"$ref": "../components/schemas.yaml#/Problem"}}},
          "x-error-codes": ["episode_superseded", "unauthorized"]
        },
        "402": {
          "description": "Pro is required for assistant edits and for batch=true.",
          "headers": {"request-id": {"$ref": "../components/headers.yaml#/RequestId"}, "Cache-Control": {"$ref": "../components/headers.yaml#/CacheControl"}},
          "content": {"application/problem+json": {"schema": {"$ref": "../components/schemas.yaml#/Problem"}}},
          "x-error-codes": ["pro_required"]
        },
        "403": {
          "description": "The active credential or configuration does not permit this action.",
          "headers": {"request-id": {"$ref": "../components/headers.yaml#/RequestId"}, "Cache-Control": {"$ref": "../components/headers.yaml#/CacheControl"}},
          "content": {"application/problem+json": {"schema": {"$ref": "../components/schemas.yaml#/Problem"}}},
          "x-error-codes": ["connection_disconnected", "connection_paused", "connection_required", "namespace_denied", "pro_required", "sapphire_account_required", "scope_denied", "write_scope_required"]
        },
        "404": {
          "description": "The requested object was not found.",
          "headers": {"request-id": {"$ref": "../components/headers.yaml#/RequestId"}, "Cache-Control": {"$ref": "../components/headers.yaml#/CacheControl"}},
          "content": {"application/problem+json": {"schema": {"$ref": "../components/schemas.yaml#/Problem"}}},
          "x-error-codes": ["not_found"]
        },
        "409": {
          "description": "The request conflicts with the current state.",
          "headers": {"request-id": {"$ref": "../components/headers.yaml#/RequestId"}, "Cache-Control": {"$ref": "../components/headers.yaml#/CacheControl"}},
          "content": {"application/problem+json": {"schema": {"$ref": "../components/schemas.yaml#/Problem"}}},
          "x-error-codes": ["base_unknown", "grocery_list_exists", "invalid_deletion_target", "pigeon_data_deleting", "preferences_exists", "reset_conflict", "reset_dependency", "revision_conflict"]
        },
        "410": {
          "description": "The account, snapshot, cursor or history is no longer available.",
          "headers": {"request-id": {"$ref": "../components/headers.yaml#/RequestId"}, "Cache-Control": {"$ref": "../components/headers.yaml#/CacheControl"}},
          "content": {"application/problem+json": {"schema": {"$ref": "../components/schemas.yaml#/Problem"}}},
          "x-error-codes": ["account_deleted", "history_expired"]
        },
        "413": {
          "description": "The request or its resulting work exceeds a size limit.",
          "headers": {"request-id": {"$ref": "../components/headers.yaml#/RequestId"}, "Cache-Control": {"$ref": "../components/headers.yaml#/CacheControl"}},
          "content": {"application/problem+json": {"schema": {"$ref": "../components/schemas.yaml#/Problem"}}},
          "x-error-codes": ["body_too_large", "operation_too_large", "reference_work_exceeded", "response_too_large", "state_too_large"]
        },
        "422": {
          "description": "The request violates a protocol or data rule.",
          "headers": {"request-id": {"$ref": "../components/headers.yaml#/RequestId"}, "Cache-Control": {"$ref": "../components/headers.yaml#/CacheControl"}},
          "content": {"application/problem+json": {"schema": {"$ref": "../components/schemas.yaml#/Problem"}}},
          "x-error-codes": ["assistant_edit_shape", "base_required", "body_identity_changed", "body_invalid", "create_reference_unavailable", "dangling_reference", "duplicate_create_id", "idempotency_key_reused", "immutable_record", "invalid_body", "invalid_operation", "invalid_request", "invalid_state", "lineage_protected", "patch_invalid", "pre_tombstone_fanout_limit", "pre_tombstone_scan_limit", "record_identity_changed", "reference_hash_mismatch", "reference_kind_mismatch", "reference_part_mismatch", "reset_invalid", "reset_no_upstream", "reset_not_edited", "server_owned_field", "too_many_external_ids", "unsupported_schema"]
        },
        "429": {
          "description": "A transport or assistant edit rate limit was reached.",
          "headers": {"request-id": {"$ref": "../components/headers.yaml#/RequestId"}, "Cache-Control": {"$ref": "../components/headers.yaml#/CacheControl"}, "Retry-After": {"$ref": "../components/headers.yaml#/RetryAfter"}},
          "content": {"application/problem+json": {"schema": {"$ref": "../components/schemas.yaml#/Problem"}}},
          "x-error-codes": ["daily_edit_cap_reached", "rate_limited"]
        },
        "503": {
          "description": "The hub or an operation dependency is unavailable.",
          "headers": {"request-id": {"$ref": "../components/headers.yaml#/RequestId"}, "Cache-Control": {"$ref": "../components/headers.yaml#/CacheControl"}, "Retry-After": {"$ref": "../components/headers.yaml#/RetryAfter"}},
          "content": {"application/problem+json": {"schema": {"$ref": "../components/schemas.yaml#/Problem"}}},
          "x-error-codes": ["history_corrupt", "hub_not_ready", "identity_unavailable", "internal_error", "ledger_unavailable"]
        }
      }
    }
  },
  "resolveRecordConflict": {
    "post": {
      "operationId": "resolveRecordConflict",
      "tags": ["Operations"],
      "summary": "Resolve a conflict copy",
      "description": "The conflict belongs to the caller's connection. Supply the current record revision as the base.",
      "parameters": [
        {"$ref": "../components/parameters.yaml#/RecordId"},
        {
          "name": "cid",
          "in": "path",
          "required": true,
          "description": "ID of the caller's connection.",
          "schema": {"type": "string", "description": "Connection identifier."}
        },
        {"$ref": "../components/parameters.yaml#/IdempotencyKey"}
      ],
      "requestBody": {
        "required": true,
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "required": ["choice", "base"],
              "properties": {
                "choice": {"type": "string", "enum": ["keep_current", "discard", "use_mine"]},
                "base": {"$ref": "../components/schemas.yaml#/RevisionBase"}
              },
              "additionalProperties": false
            }
          }
        }
      },
      "x-route-error-codes": {"404": ["not_found"], "409": ["base_unknown", "revision_conflict", "still_conflicting"], "410": ["history_expired"], "413": ["body_too_large", "reference_work_exceeded"], "422": ["base_required", "body_identity_changed", "body_invalid", "dangling_reference", "idempotency_key_reused", "immutable_record", "invalid_body", "invalid_choice", "invalid_operation", "invalid_request", "patch_invalid", "reference_hash_mismatch", "reference_kind_mismatch", "reference_part_mismatch", "unsupported_schema"], "503": ["history_corrupt", "ledger_unavailable"]},
      "responses": {
        "200": {
          "description": "Successful response.",
          "headers": {
            "request-id": {"$ref": "../components/headers.yaml#/RequestId"},
            "Cache-Control": {"$ref": "../components/headers.yaml#/CacheControl"}
          },
          "content": {"application/json": {"schema": {"$ref": "../components/schemas.yaml#/OperationReceipt"}}}
        },
        "400": {
          "description": "The request could not be parsed or contains an invalid parameter.",
          "headers": {"request-id": {"$ref": "../components/headers.yaml#/RequestId"}, "Cache-Control": {"$ref": "../components/headers.yaml#/CacheControl"}},
          "content": {"application/problem+json": {"schema": {"$ref": "../components/schemas.yaml#/Problem"}}},
          "x-error-codes": ["invalid_json"]
        },
        "401": {
          "description": "The credential is missing, invalid or tied to a superseded grant.",
          "headers": {"request-id": {"$ref": "../components/headers.yaml#/RequestId"}, "Cache-Control": {"$ref": "../components/headers.yaml#/CacheControl"}},
          "content": {"application/problem+json": {"schema": {"$ref": "../components/schemas.yaml#/Problem"}}},
          "x-error-codes": ["episode_superseded", "unauthorized"]
        },
        "403": {
          "description": "The active credential or configuration does not permit this action.",
          "headers": {"request-id": {"$ref": "../components/headers.yaml#/RequestId"}, "Cache-Control": {"$ref": "../components/headers.yaml#/CacheControl"}},
          "content": {"application/problem+json": {"schema": {"$ref": "../components/schemas.yaml#/Problem"}}},
          "x-error-codes": ["connection_disconnected", "connection_paused", "connection_required", "pro_required", "sapphire_account_required", "scope_denied"]
        },
        "404": {
          "description": "The requested object was not found.",
          "headers": {"request-id": {"$ref": "../components/headers.yaml#/RequestId"}, "Cache-Control": {"$ref": "../components/headers.yaml#/CacheControl"}},
          "content": {"application/problem+json": {"schema": {"$ref": "../components/schemas.yaml#/Problem"}}},
          "x-error-codes": ["not_found"]
        },
        "409": {
          "description": "The request conflicts with the current state.",
          "headers": {"request-id": {"$ref": "../components/headers.yaml#/RequestId"}, "Cache-Control": {"$ref": "../components/headers.yaml#/CacheControl"}},
          "content": {"application/problem+json": {"schema": {"$ref": "../components/schemas.yaml#/Problem"}}},
          "x-error-codes": ["base_unknown", "pigeon_data_deleting", "revision_conflict", "still_conflicting"]
        },
        "410": {
          "description": "The account, snapshot, cursor or history is no longer available.",
          "headers": {"request-id": {"$ref": "../components/headers.yaml#/RequestId"}, "Cache-Control": {"$ref": "../components/headers.yaml#/CacheControl"}},
          "content": {"application/problem+json": {"schema": {"$ref": "../components/schemas.yaml#/Problem"}}},
          "x-error-codes": ["account_deleted", "history_expired"]
        },
        "413": {
          "description": "The request or its resulting work exceeds a size limit.",
          "headers": {"request-id": {"$ref": "../components/headers.yaml#/RequestId"}, "Cache-Control": {"$ref": "../components/headers.yaml#/CacheControl"}},
          "content": {"application/problem+json": {"schema": {"$ref": "../components/schemas.yaml#/Problem"}}},
          "x-error-codes": ["body_too_large", "operation_too_large", "reference_work_exceeded", "response_too_large"]
        },
        "422": {
          "description": "The request violates a protocol or data rule.",
          "headers": {"request-id": {"$ref": "../components/headers.yaml#/RequestId"}, "Cache-Control": {"$ref": "../components/headers.yaml#/CacheControl"}},
          "content": {"application/problem+json": {"schema": {"$ref": "../components/schemas.yaml#/Problem"}}},
          "x-error-codes": ["base_required", "body_identity_changed", "body_invalid", "dangling_reference", "idempotency_key_reused", "immutable_record", "invalid_body", "invalid_choice", "invalid_id", "invalid_operation", "invalid_request", "patch_invalid", "reference_hash_mismatch", "reference_kind_mismatch", "reference_part_mismatch", "unsupported_schema"]
        },
        "429": {
          "description": "A request or work budget is exhausted.",
          "headers": {"request-id": {"$ref": "../components/headers.yaml#/RequestId"}, "Cache-Control": {"$ref": "../components/headers.yaml#/CacheControl"}, "Retry-After": {"$ref": "../components/headers.yaml#/RetryAfter"}},
          "content": {"application/problem+json": {"schema": {"$ref": "../components/schemas.yaml#/Problem"}}},
          "x-error-codes": ["rate_limited"]
        },
        "503": {
          "description": "The hub or an operation dependency is unavailable.",
          "headers": {"request-id": {"$ref": "../components/headers.yaml#/RequestId"}, "Cache-Control": {"$ref": "../components/headers.yaml#/CacheControl"}, "Retry-After": {"$ref": "../components/headers.yaml#/RetryAfter"}},
          "content": {"application/problem+json": {"schema": {"$ref": "../components/schemas.yaml#/Problem"}}},
          "x-error-codes": ["history_corrupt", "hub_not_ready", "identity_unavailable", "internal_error", "ledger_unavailable"]
        }
      }
    }
  }
}
