{
  "applyOperation": {
    "post": {
      "operationId": "applyOperation",
      "tags": ["Operations"],
      "summary": "Apply an atomic batch of mutations",
      "description": "Retain create IDs and send the revision base when editing. Supply a canonical record, a part-tree body, or a patch as appropriate. Deleting through a connected app unlinks that app only. Use the receipt to update your mirror. Some per-record outcomes omit the record.",
      "parameters": [
        {"$ref": "../components/parameters.yaml#/IdempotencyKey"}
      ],
      "requestBody": {
        "required": true,
        "content": {"application/json": {"schema": {"$ref": "../components/schemas.yaml#/OperationInput"}}}
      },
      "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": {"$ref": "../components/responses.yaml#/Hub401"},
        "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"}},
            "application/json": {"schema": {"$ref": "../components/schemas.yaml#/Problem"}}
          },
          "x-error-codes": [
            "connection_disconnected",
            "connection_required",
            "namespace_denied",
            "owner_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", "revision_conflict", "reset_dependency", "reset_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"]
        },
        "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_and_patch",
            "body_and_record",
            "body_identity_changed",
            "body_invalid",
            "create_reference_not_in_operation",
            "create_reference_unavailable",
            "dangling_reference",
            "duplicate_create_id",
            "idempotency_key_reused",
            "immutable_record",
            "invalid_body",
            "invalid_mutation",
            "invalid_operation",
            "invalid_request",
            "patch_invalid",
            "reset_invalid",
            "pre_tombstone_fanout_limit",
            "pre_tombstone_scan_limit",
            "record_identity_changed",
            "server_owned_metadata",
            "too_many_external_ids",
            "unsupported_operation_version",
            "unsupported_schema"
          ]
        },
        "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"}},
            "application/json": {"schema": {"$ref": "../components/schemas.yaml#/Problem"}}
          },
          "x-error-codes": ["history_corrupt", "hub_not_configured", "hub_not_ready", "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
            }
          }
        }
      },
      "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": {"$ref": "../components/responses.yaml#/Hub401"},
        "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"}},
            "application/json": {"schema": {"$ref": "../components/schemas.yaml#/Problem"}}
          },
          "x-error-codes": ["connection_disconnected", "connection_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", "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"]
        },
        "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_operation",
            "invalid_request",
            "unsupported_schema"
          ]
        },
        "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"}},
            "application/json": {"schema": {"$ref": "../components/schemas.yaml#/Problem"}}
          },
          "x-error-codes": ["history_corrupt", "hub_not_configured", "hub_not_ready", "internal_error", "ledger_unavailable"]
        }
      }
    }
  }
}
