{
  "openapi": "3.0.3",
  "info": {
    "title": "Medsenger Clinic Accounting API",
    "version": "1.0.0",
    "description": "Read-only clinic-scoped requests and contracts API. Requires permission granted by a system administrator in /admin and activation by the clinic main administrator. Revoking either blocks access with api_disabled (403). One revocable/reissuable Bearer key per clinic. Optional cloud fiscalization. Current state and last change markers only. Default limit: 120 requests/minute per clinic. Currency amounts are integer minor units. All dates and date filters are Unix timestamps in seconds (integer int64), including nested payment and receipt dates. Unknown dates are null. Numbered pages require no session or continuation token. Unknown historical values remain null. No medical records or gateway credentials are exported.\n\nFor a complete local replica, poll each resource separately without status, is_paid, created_from or created_to. Start at page=1; on the first run omit updated_since. Keep limit and filters fixed for the whole pass. Remember meta.generated_at from the first successful page, then fetch page+1 until meta.has_more=false. Only after all pages are stored successfully, commit that first-page timestamp as the next inclusive updated_since; do not add one second, use the last page's time, the local clock or max(updated_at). Repeated records are expected. Upsert by (clinic_id, resource, id), compare the revision of that same record and apply deletion markers; keep the deletion revision to avoid resurrecting stale records. Revisions increase across both resources within a clinic and may have gaps; they are not a supported query cursor. Pages are ordered by ID, not revision. Responses are current state, not a point-in-time snapshot or event history. Records can change between pages and related resources are eventually consistent. Repeat polling to converge. For 429/503 retry the same request after Retry-After, without advancing the checkpoint; after a partial failed pass the saved checkpoint must stay unchanged.\n\nAll supplied filters are combined with AND. Unknown query parameters cause 422 on list endpoints, including clinic_id and is_paid on /contracts. status and is_paid filter current state, so records leaving the selection are not reported. Published deletion markers have no stored status, payment flag or creation date, and are excluded by any status, is_paid, created_from or created_to filter. Use those filters for reports; for complete synchronization use only updated_since, page and limit and apply business filters locally.\n\nHEAD is also supported on the four resource paths and returns response headers without a body. GET responses use application/json and Cache-Control: no-store, private. Every documented property is present even when its value is null, except deletion markers, which have their own reduced shape. Examples contain fictional data and non-operational receipt links."
  },
  "servers": [
    {
      "url": "https://medsenger.ru/api/integrations/v1"
    }
  ],
  "security": [
    {
      "clinicApiKey": []
    }
  ],
  "paths": {
    "/consulting-orders": {
      "get": {
        "operationId": "listOrders",
        "summary": "List current consulting-orders or synchronize changes",
        "description": "For a complete local replica, poll each resource separately without status, is_paid, created_from or created_to. Start at page=1; on the first run omit updated_since. Keep limit and filters fixed for the whole pass. Remember meta.generated_at from the first successful page, then fetch page+1 until meta.has_more=false. Only after all pages are stored successfully, commit that first-page timestamp as the next inclusive updated_since; do not add one second, use the last page's time, the local clock or max(updated_at). Repeated records are expected. Upsert by (clinic_id, resource, id), compare the revision of that same record and apply deletion markers; keep the deletion revision to avoid resurrecting stale records. Revisions increase across both resources within a clinic and may have gaps; they are not a supported query cursor. Pages are ordered by ID, not revision. Responses are current state, not a point-in-time snapshot or event history. Records can change between pages and related resources are eventually consistent. Repeat polling to converge. For 429/503 retry the same request after Retry-After, without advancing the checkpoint; after a partial failed pass the saved checkpoint must stay unchanged.\n\nAll supplied filters are combined with AND. Unknown query parameters cause 422 on list endpoints, including clinic_id and is_paid on /contracts. status and is_paid filter current state, so records leaving the selection are not reported. Published deletion markers have no stored status, payment flag or creation date, and are excluded by any status, is_paid, created_from or created_to filter. Use those filters for reports; for complete synchronization use only updated_since, page and limit and apply business filters locally.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            },
            "description": "Page size.",
            "example": 100
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 1,
              "default": 1,
              "maximum": 18446744073709551
            },
            "description": "Page number, starting at 1. No preceding request is required. Keep other parameters fixed throughout a pass.",
            "example": 1
          },
          {
            "name": "created_from",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0,
              "maximum": 253402300799
            },
            "description": "Lower creation-time bound in Unix seconds, inclusive. The bounds refer to exact seconds, not whole calendar days. created_from must not exceed created_to. Excludes deletion markers; unsuitable for complete deletion synchronization.",
            "example": 1791972000
          },
          {
            "name": "created_to",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0,
              "maximum": 253402300799
            },
            "description": "Upper creation-time bound in Unix seconds, inclusive. The bounds refer to exact seconds, not whole calendar days. created_from must not exceed created_to. Excludes deletion markers; unsuitable for complete deletion synchronization.",
            "example": 1792058399
          },
          {
            "name": "updated_since",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0,
              "maximum": 253402300799
            },
            "description": "Inclusive lower bound on publication time of the latest exported change, in Unix seconds. Includes changes to payments, receipts and service completion. Without this parameter, no modification-time restriction applies. Use the previous completed pass first-page generated_at, without adding a second. Includes deletion markers absent status/payment/creation-date filters.",
            "example": 1791972000
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "created",
                "payment_required",
                "accepted",
                "declined"
              ]
            },
            "description": "Filter by current resource status. Current state only; excludes deleted records and records that left this status. Filter locally for a complete replica.",
            "example": "accepted"
          },
          {
            "name": "is_paid",
            "in": "query",
            "schema": {
              "type": "integer",
              "enum": [
                0,
                1
              ]
            },
            "description": "Only orders with an existing payment. No payment is not the same as an unpaid payment. Query values are 0 and 1, not strings true and false. Excludes deletion markers and records that left the selection.",
            "example": 1
          }
        ],
        "responses": {
          "200": {
            "description": "Page of current records or deletion markers",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "oneOf": [
                          {
                            "$ref": "#/components/schemas/Order"
                          },
                          {
                            "$ref": "#/components/schemas/Deleted"
                          }
                        ]
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ],
                  "additionalProperties": false
                },
                "examples": {
                  "OrderList": {
                    "$ref": "#/components/examples/OrderList"
                  },
                  "UnpaidOrderList": {
                    "$ref": "#/components/examples/UnpaidOrderList"
                  },
                  "DeletedOrderList": {
                    "$ref": "#/components/examples/DeletedOrderList"
                  },
                  "EmptyList": {
                    "$ref": "#/components/examples/EmptyList"
                  },
                  "OrderFirstPage": {
                    "$ref": "#/components/examples/OrderFirstPage"
                  },
                  "OrderSecondPage": {
                    "$ref": "#/components/examples/OrderSecondPage"
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "401": {
            "description": "unauthorized: missing, malformed, invalid or revoked Bearer key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "Unauthorized": {
                    "$ref": "#/components/examples/Unauthorized"
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              },
              "WWW-Authenticate": {
                "schema": {
                  "type": "string"
                },
                "description": "Bearer authentication challenge.",
                "example": "Bearer"
              }
            }
          },
          "403": {
            "description": "api_disabled: API disabled by the system or clinic.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ApiDisabled": {
                    "$ref": "#/components/examples/ApiDisabled"
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "404": {
            "description": "not_found: missing, deleted, other-clinic record, or unknown path.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NotFound": {
                    "$ref": "#/components/examples/NotFound"
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "405": {
            "description": "method_not_allowed: only GET and HEAD are supported.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "MethodNotAllowed": {
                    "$ref": "#/components/examples/MethodNotAllowed"
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              },
              "Allow": {
                "schema": {
                  "type": "string"
                },
                "description": "Supported methods.",
                "example": "GET, HEAD"
              }
            }
          },
          "422": {
            "description": "invalid_parameters: invalid list query, unknown parameter, or reversed creation bounds. Unknown parameters may have empty details.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "InvalidParameters": {
                    "$ref": "#/components/examples/InvalidParameters"
                  },
                  "InvalidLimit": {
                    "$ref": "#/components/examples/InvalidLimit"
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "429": {
            "description": "rate_limited: clinic-wide shared rate limit exceeded; retry same request after Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "RateLimited": {
                    "$ref": "#/components/examples/RateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds before retrying.",
                "example": 60
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "503": {
            "description": "export_preparing: changes still preparing; retry same request after Retry-After without advancing checkpoint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ExportPreparing": {
                    "$ref": "#/components/examples/ExportPreparing"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds before retrying.",
                "example": 60
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "500": {
            "description": "internal_error: unexpected server failure. Retry with backoff and keep previous checkpoint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "InternalError": {
                    "$ref": "#/components/examples/InternalError"
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          }
        }
      },
      "head": {
        "operationId": "headListOrders",
        "summary": "Response headers for list current consulting-orders or synchronize changes",
        "description": "Same authorization, query validation, publication and rate limits as GET. Returns status and headers without a body.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            },
            "description": "Page size.",
            "example": 100
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 1,
              "default": 1,
              "maximum": 18446744073709551
            },
            "description": "Page number, starting at 1. No preceding request is required. Keep other parameters fixed throughout a pass.",
            "example": 1
          },
          {
            "name": "created_from",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0,
              "maximum": 253402300799
            },
            "description": "Lower creation-time bound in Unix seconds, inclusive. The bounds refer to exact seconds, not whole calendar days. created_from must not exceed created_to. Excludes deletion markers; unsuitable for complete deletion synchronization.",
            "example": 1791972000
          },
          {
            "name": "created_to",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0,
              "maximum": 253402300799
            },
            "description": "Upper creation-time bound in Unix seconds, inclusive. The bounds refer to exact seconds, not whole calendar days. created_from must not exceed created_to. Excludes deletion markers; unsuitable for complete deletion synchronization.",
            "example": 1792058399
          },
          {
            "name": "updated_since",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0,
              "maximum": 253402300799
            },
            "description": "Inclusive lower bound on publication time of the latest exported change, in Unix seconds. Includes changes to payments, receipts and service completion. Without this parameter, no modification-time restriction applies. Use the previous completed pass first-page generated_at, without adding a second. Includes deletion markers absent status/payment/creation-date filters.",
            "example": 1791972000
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "created",
                "payment_required",
                "accepted",
                "declined"
              ]
            },
            "description": "Filter by current resource status. Current state only; excludes deleted records and records that left this status. Filter locally for a complete replica.",
            "example": "accepted"
          },
          {
            "name": "is_paid",
            "in": "query",
            "schema": {
              "type": "integer",
              "enum": [
                0,
                1
              ]
            },
            "description": "Only orders with an existing payment. No payment is not the same as an unpaid payment. Query values are 0 and 1, not strings true and false. Excludes deletion markers and records that left the selection.",
            "example": 1
          }
        ],
        "responses": {
          "200": {
            "description": "Page of current records or deletion markers",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "401": {
            "description": "unauthorized: missing, malformed, invalid or revoked Bearer key.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              },
              "WWW-Authenticate": {
                "schema": {
                  "type": "string"
                },
                "description": "Bearer authentication challenge.",
                "example": "Bearer"
              }
            }
          },
          "403": {
            "description": "api_disabled: API disabled by the system or clinic.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "404": {
            "description": "not_found: missing, deleted, other-clinic record, or unknown path.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "405": {
            "description": "method_not_allowed: only GET and HEAD are supported.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              },
              "Allow": {
                "schema": {
                  "type": "string"
                },
                "description": "Supported methods.",
                "example": "GET, HEAD"
              }
            }
          },
          "422": {
            "description": "invalid_parameters: invalid list query, unknown parameter, or reversed creation bounds. Unknown parameters may have empty details.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "429": {
            "description": "rate_limited: clinic-wide shared rate limit exceeded; retry same request after Retry-After.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds before retrying.",
                "example": 60
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "503": {
            "description": "export_preparing: changes still preparing; retry same request after Retry-After without advancing checkpoint.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds before retrying.",
                "example": 60
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "500": {
            "description": "internal_error: unexpected server failure. Retry with backoff and keep previous checkpoint.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          }
        }
      }
    },
    "/consulting-orders/{id}": {
      "get": {
        "operationId": "getOrder",
        "summary": "Get one current order",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 1
            },
            "description": "Internal ID of the order or contract.",
            "example": 1001
          }
        ],
        "responses": {
          "200": {
            "description": "Current record",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Order"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                },
                "examples": {
                  "OrderDetail": {
                    "$ref": "#/components/examples/OrderDetail"
                  },
                  "PaymentPendingOrder": {
                    "$ref": "#/components/examples/PaymentPendingOrder"
                  },
                  "ReviewRequiredOrder": {
                    "$ref": "#/components/examples/ReviewRequiredOrder"
                  },
                  "FullReceiptOrder": {
                    "$ref": "#/components/examples/FullReceiptOrder"
                  },
                  "FiscalizationRetryOrder": {
                    "$ref": "#/components/examples/FiscalizationRetryOrder"
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "401": {
            "description": "unauthorized: missing, malformed, invalid or revoked Bearer key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "Unauthorized": {
                    "$ref": "#/components/examples/Unauthorized"
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              },
              "WWW-Authenticate": {
                "schema": {
                  "type": "string"
                },
                "description": "Bearer authentication challenge.",
                "example": "Bearer"
              }
            }
          },
          "403": {
            "description": "api_disabled: API disabled by the system or clinic.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ApiDisabled": {
                    "$ref": "#/components/examples/ApiDisabled"
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "404": {
            "description": "not_found: missing, deleted, other-clinic record, or unknown path.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NotFound": {
                    "$ref": "#/components/examples/NotFound"
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "405": {
            "description": "method_not_allowed: only GET and HEAD are supported.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "MethodNotAllowed": {
                    "$ref": "#/components/examples/MethodNotAllowed"
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              },
              "Allow": {
                "schema": {
                  "type": "string"
                },
                "description": "Supported methods.",
                "example": "GET, HEAD"
              }
            }
          },
          "422": {
            "description": "invalid_parameters: invalid list query, unknown parameter, or reversed creation bounds. Unknown parameters may have empty details.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "InvalidParameters": {
                    "$ref": "#/components/examples/InvalidParameters"
                  },
                  "InvalidLimit": {
                    "$ref": "#/components/examples/InvalidLimit"
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "429": {
            "description": "rate_limited: clinic-wide shared rate limit exceeded; retry same request after Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "RateLimited": {
                    "$ref": "#/components/examples/RateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds before retrying.",
                "example": 60
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "503": {
            "description": "export_preparing: changes still preparing; retry same request after Retry-After without advancing checkpoint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ExportPreparing": {
                    "$ref": "#/components/examples/ExportPreparing"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds before retrying.",
                "example": 60
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "500": {
            "description": "internal_error: unexpected server failure. Retry with backoff and keep previous checkpoint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "InternalError": {
                    "$ref": "#/components/examples/InternalError"
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          }
        },
        "description": "Get the current record for the Bearer clinic. Unknown, deleted and other-clinic IDs return the same 404. Response contains data only, no meta. May return 503 while changes are being published."
      },
      "head": {
        "operationId": "headGetOrder",
        "summary": "Response headers for get one current order",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 1
            },
            "description": "Internal ID of the order or contract.",
            "example": 1001
          }
        ],
        "responses": {
          "200": {
            "description": "Current record",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "401": {
            "description": "unauthorized: missing, malformed, invalid or revoked Bearer key.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              },
              "WWW-Authenticate": {
                "schema": {
                  "type": "string"
                },
                "description": "Bearer authentication challenge.",
                "example": "Bearer"
              }
            }
          },
          "403": {
            "description": "api_disabled: API disabled by the system or clinic.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "404": {
            "description": "not_found: missing, deleted, other-clinic record, or unknown path.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "405": {
            "description": "method_not_allowed: only GET and HEAD are supported.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              },
              "Allow": {
                "schema": {
                  "type": "string"
                },
                "description": "Supported methods.",
                "example": "GET, HEAD"
              }
            }
          },
          "422": {
            "description": "invalid_parameters: invalid list query, unknown parameter, or reversed creation bounds. Unknown parameters may have empty details.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "429": {
            "description": "rate_limited: clinic-wide shared rate limit exceeded; retry same request after Retry-After.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds before retrying.",
                "example": 60
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "503": {
            "description": "export_preparing: changes still preparing; retry same request after Retry-After without advancing checkpoint.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds before retrying.",
                "example": 60
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "500": {
            "description": "internal_error: unexpected server failure. Retry with backoff and keep previous checkpoint.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          }
        },
        "description": "Same authorization, query validation, publication and rate limits as GET. Returns status and headers without a body."
      }
    },
    "/contracts": {
      "get": {
        "operationId": "listContracts",
        "summary": "List current contracts or synchronize changes",
        "description": "For a complete local replica, poll each resource separately without status, is_paid, created_from or created_to. Start at page=1; on the first run omit updated_since. Keep limit and filters fixed for the whole pass. Remember meta.generated_at from the first successful page, then fetch page+1 until meta.has_more=false. Only after all pages are stored successfully, commit that first-page timestamp as the next inclusive updated_since; do not add one second, use the last page's time, the local clock or max(updated_at). Repeated records are expected. Upsert by (clinic_id, resource, id), compare the revision of that same record and apply deletion markers; keep the deletion revision to avoid resurrecting stale records. Revisions increase across both resources within a clinic and may have gaps; they are not a supported query cursor. Pages are ordered by ID, not revision. Responses are current state, not a point-in-time snapshot or event history. Records can change between pages and related resources are eventually consistent. Repeat polling to converge. For 429/503 retry the same request after Retry-After, without advancing the checkpoint; after a partial failed pass the saved checkpoint must stay unchanged.\n\nAll supplied filters are combined with AND. Unknown query parameters cause 422 on list endpoints, including clinic_id and is_paid on /contracts. status and is_paid filter current state, so records leaving the selection are not reported. Published deletion markers have no stored status, payment flag or creation date, and are excluded by any status, is_paid, created_from or created_to filter. Use those filters for reports; for complete synchronization use only updated_since, page and limit and apply business filters locally.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            },
            "description": "Page size.",
            "example": 100
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 1,
              "default": 1,
              "maximum": 18446744073709551
            },
            "description": "Page number, starting at 1. No preceding request is required. Keep other parameters fixed throughout a pass.",
            "example": 1
          },
          {
            "name": "created_from",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0,
              "maximum": 253402300799
            },
            "description": "Lower creation-time bound in Unix seconds, inclusive. The bounds refer to exact seconds, not whole calendar days. created_from must not exceed created_to. Excludes deletion markers; unsuitable for complete deletion synchronization.",
            "example": 1791972000
          },
          {
            "name": "created_to",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0,
              "maximum": 253402300799
            },
            "description": "Upper creation-time bound in Unix seconds, inclusive. The bounds refer to exact seconds, not whole calendar days. created_from must not exceed created_to. Excludes deletion markers; unsuitable for complete deletion synchronization.",
            "example": 1792058399
          },
          {
            "name": "updated_since",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0,
              "maximum": 253402300799
            },
            "description": "Inclusive lower bound on publication time of the latest exported change, in Unix seconds. Includes changes to payments, receipts and service completion. Without this parameter, no modification-time restriction applies. Use the previous completed pass first-page generated_at, without adding a second. Includes deletion markers absent status/payment/creation-date filters.",
            "example": 1791972000
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "waiting_activation",
                "active",
                "expired",
                "closed"
              ]
            },
            "description": "Filter by current resource status. Current state only; excludes deleted records and records that left this status. Filter locally for a complete replica.",
            "example": "closed"
          }
        ],
        "responses": {
          "200": {
            "description": "Page of current records or deletion markers",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "oneOf": [
                          {
                            "$ref": "#/components/schemas/Contract"
                          },
                          {
                            "$ref": "#/components/schemas/Deleted"
                          }
                        ]
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ],
                  "additionalProperties": false
                },
                "examples": {
                  "ContractList": {
                    "$ref": "#/components/examples/ContractList"
                  },
                  "DeletedContractList": {
                    "$ref": "#/components/examples/DeletedContractList"
                  },
                  "EmptyList": {
                    "$ref": "#/components/examples/EmptyList"
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "401": {
            "description": "unauthorized: missing, malformed, invalid or revoked Bearer key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "Unauthorized": {
                    "$ref": "#/components/examples/Unauthorized"
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              },
              "WWW-Authenticate": {
                "schema": {
                  "type": "string"
                },
                "description": "Bearer authentication challenge.",
                "example": "Bearer"
              }
            }
          },
          "403": {
            "description": "api_disabled: API disabled by the system or clinic.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ApiDisabled": {
                    "$ref": "#/components/examples/ApiDisabled"
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "404": {
            "description": "not_found: missing, deleted, other-clinic record, or unknown path.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NotFound": {
                    "$ref": "#/components/examples/NotFound"
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "405": {
            "description": "method_not_allowed: only GET and HEAD are supported.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "MethodNotAllowed": {
                    "$ref": "#/components/examples/MethodNotAllowed"
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              },
              "Allow": {
                "schema": {
                  "type": "string"
                },
                "description": "Supported methods.",
                "example": "GET, HEAD"
              }
            }
          },
          "422": {
            "description": "invalid_parameters: invalid list query, unknown parameter, or reversed creation bounds. Unknown parameters may have empty details.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "InvalidParameters": {
                    "$ref": "#/components/examples/InvalidParameters"
                  },
                  "InvalidLimit": {
                    "$ref": "#/components/examples/InvalidLimit"
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "429": {
            "description": "rate_limited: clinic-wide shared rate limit exceeded; retry same request after Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "RateLimited": {
                    "$ref": "#/components/examples/RateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds before retrying.",
                "example": 60
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "503": {
            "description": "export_preparing: changes still preparing; retry same request after Retry-After without advancing checkpoint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ExportPreparing": {
                    "$ref": "#/components/examples/ExportPreparing"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds before retrying.",
                "example": 60
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "500": {
            "description": "internal_error: unexpected server failure. Retry with backoff and keep previous checkpoint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "InternalError": {
                    "$ref": "#/components/examples/InternalError"
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          }
        }
      },
      "head": {
        "operationId": "headListContracts",
        "summary": "Response headers for list current contracts or synchronize changes",
        "description": "Same authorization, query validation, publication and rate limits as GET. Returns status and headers without a body.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            },
            "description": "Page size.",
            "example": 100
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 1,
              "default": 1,
              "maximum": 18446744073709551
            },
            "description": "Page number, starting at 1. No preceding request is required. Keep other parameters fixed throughout a pass.",
            "example": 1
          },
          {
            "name": "created_from",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0,
              "maximum": 253402300799
            },
            "description": "Lower creation-time bound in Unix seconds, inclusive. The bounds refer to exact seconds, not whole calendar days. created_from must not exceed created_to. Excludes deletion markers; unsuitable for complete deletion synchronization.",
            "example": 1791972000
          },
          {
            "name": "created_to",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0,
              "maximum": 253402300799
            },
            "description": "Upper creation-time bound in Unix seconds, inclusive. The bounds refer to exact seconds, not whole calendar days. created_from must not exceed created_to. Excludes deletion markers; unsuitable for complete deletion synchronization.",
            "example": 1792058399
          },
          {
            "name": "updated_since",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0,
              "maximum": 253402300799
            },
            "description": "Inclusive lower bound on publication time of the latest exported change, in Unix seconds. Includes changes to payments, receipts and service completion. Without this parameter, no modification-time restriction applies. Use the previous completed pass first-page generated_at, without adding a second. Includes deletion markers absent status/payment/creation-date filters.",
            "example": 1791972000
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "waiting_activation",
                "active",
                "expired",
                "closed"
              ]
            },
            "description": "Filter by current resource status. Current state only; excludes deleted records and records that left this status. Filter locally for a complete replica.",
            "example": "closed"
          }
        ],
        "responses": {
          "200": {
            "description": "Page of current records or deletion markers",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "401": {
            "description": "unauthorized: missing, malformed, invalid or revoked Bearer key.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              },
              "WWW-Authenticate": {
                "schema": {
                  "type": "string"
                },
                "description": "Bearer authentication challenge.",
                "example": "Bearer"
              }
            }
          },
          "403": {
            "description": "api_disabled: API disabled by the system or clinic.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "404": {
            "description": "not_found: missing, deleted, other-clinic record, or unknown path.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "405": {
            "description": "method_not_allowed: only GET and HEAD are supported.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              },
              "Allow": {
                "schema": {
                  "type": "string"
                },
                "description": "Supported methods.",
                "example": "GET, HEAD"
              }
            }
          },
          "422": {
            "description": "invalid_parameters: invalid list query, unknown parameter, or reversed creation bounds. Unknown parameters may have empty details.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "429": {
            "description": "rate_limited: clinic-wide shared rate limit exceeded; retry same request after Retry-After.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds before retrying.",
                "example": 60
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "503": {
            "description": "export_preparing: changes still preparing; retry same request after Retry-After without advancing checkpoint.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds before retrying.",
                "example": 60
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "500": {
            "description": "internal_error: unexpected server failure. Retry with backoff and keep previous checkpoint.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          }
        }
      }
    },
    "/contracts/{id}": {
      "get": {
        "operationId": "getContract",
        "summary": "Get one current contract",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 1
            },
            "description": "Internal ID of the order or contract.",
            "example": 2001
          }
        ],
        "responses": {
          "200": {
            "description": "Current record",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Contract"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                },
                "examples": {
                  "ContractDetail": {
                    "$ref": "#/components/examples/ContractDetail"
                  },
                  "ContractWithoutPayments": {
                    "$ref": "#/components/examples/ContractWithoutPayments"
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "401": {
            "description": "unauthorized: missing, malformed, invalid or revoked Bearer key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "Unauthorized": {
                    "$ref": "#/components/examples/Unauthorized"
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              },
              "WWW-Authenticate": {
                "schema": {
                  "type": "string"
                },
                "description": "Bearer authentication challenge.",
                "example": "Bearer"
              }
            }
          },
          "403": {
            "description": "api_disabled: API disabled by the system or clinic.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ApiDisabled": {
                    "$ref": "#/components/examples/ApiDisabled"
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "404": {
            "description": "not_found: missing, deleted, other-clinic record, or unknown path.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NotFound": {
                    "$ref": "#/components/examples/NotFound"
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "405": {
            "description": "method_not_allowed: only GET and HEAD are supported.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "MethodNotAllowed": {
                    "$ref": "#/components/examples/MethodNotAllowed"
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              },
              "Allow": {
                "schema": {
                  "type": "string"
                },
                "description": "Supported methods.",
                "example": "GET, HEAD"
              }
            }
          },
          "422": {
            "description": "invalid_parameters: invalid list query, unknown parameter, or reversed creation bounds. Unknown parameters may have empty details.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "InvalidParameters": {
                    "$ref": "#/components/examples/InvalidParameters"
                  },
                  "InvalidLimit": {
                    "$ref": "#/components/examples/InvalidLimit"
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "429": {
            "description": "rate_limited: clinic-wide shared rate limit exceeded; retry same request after Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "RateLimited": {
                    "$ref": "#/components/examples/RateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds before retrying.",
                "example": 60
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "503": {
            "description": "export_preparing: changes still preparing; retry same request after Retry-After without advancing checkpoint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ExportPreparing": {
                    "$ref": "#/components/examples/ExportPreparing"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds before retrying.",
                "example": 60
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "500": {
            "description": "internal_error: unexpected server failure. Retry with backoff and keep previous checkpoint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "InternalError": {
                    "$ref": "#/components/examples/InternalError"
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          }
        },
        "description": "Get the current record for the Bearer clinic. Unknown, deleted and other-clinic IDs return the same 404. Response contains data only, no meta. May return 503 while changes are being published."
      },
      "head": {
        "operationId": "headGetContract",
        "summary": "Response headers for get one current contract",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 1
            },
            "description": "Internal ID of the order or contract.",
            "example": 2001
          }
        ],
        "responses": {
          "200": {
            "description": "Current record",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "401": {
            "description": "unauthorized: missing, malformed, invalid or revoked Bearer key.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              },
              "WWW-Authenticate": {
                "schema": {
                  "type": "string"
                },
                "description": "Bearer authentication challenge.",
                "example": "Bearer"
              }
            }
          },
          "403": {
            "description": "api_disabled: API disabled by the system or clinic.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "404": {
            "description": "not_found: missing, deleted, other-clinic record, or unknown path.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "405": {
            "description": "method_not_allowed: only GET and HEAD are supported.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              },
              "Allow": {
                "schema": {
                  "type": "string"
                },
                "description": "Supported methods.",
                "example": "GET, HEAD"
              }
            }
          },
          "422": {
            "description": "invalid_parameters: invalid list query, unknown parameter, or reversed creation bounds. Unknown parameters may have empty details.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "429": {
            "description": "rate_limited: clinic-wide shared rate limit exceeded; retry same request after Retry-After.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds before retrying.",
                "example": 60
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "503": {
            "description": "export_preparing: changes still preparing; retry same request after Retry-After without advancing checkpoint.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds before retrying.",
                "example": 60
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          },
          "500": {
            "description": "internal_error: unexpected server failure. Retry with backoff and keep previous checkpoint.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "API responses must not be cached.",
                "example": "no-store, private"
              }
            }
          }
        },
        "description": "Same authorization, query validation, publication and rate limits as GET. Returns status and headers without a body."
      }
    }
  },
  "components": {
    "securitySchemes": {
      "clinicApiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Single clinic Bearer key, managed by its main administrator. Requires system permission and clinic activation. Reissue immediately revokes the old key. Send in Authorization, not the URL."
      }
    },
    "schemas": {
      "Doctor": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Clinic doctor record ID, not the user account ID."
          },
          "name": {
            "type": "string",
            "nullable": true,
            "description": "Current doctor display name; null if unavailable."
          }
        },
        "required": [
          "id",
          "name"
        ],
        "additionalProperties": false,
        "nullable": true,
        "description": "Current clinic doctor identity, or null if unavailable.",
        "example": {
          "id": 31,
          "name": "Анна Примерова"
        }
      },
      "Service": {
        "type": "object",
        "properties": {
          "captured": {
            "type": "boolean",
            "description": "Whether original offer conditions were captured. False for legacy records without a snapshot; true does not guarantee all values are known."
          },
          "service_id": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "description": "Original service catalogue ID; null if unavailable or arranged without a catalogue service."
          },
          "name": {
            "type": "string",
            "nullable": true,
            "description": "Captured original service name; null if unknown. Later catalogue edits do not replace it."
          },
          "duration_days": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "description": "Captured offer duration in days. May differ from current order duration_days or contract dates; null if unknown."
          },
          "amount_minor": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "description": "Known original offer price in kopecks; null if unknown. payment.amount_minor is the invoice amount. 150000 means RUB 1500.00."
          },
          "currency": {
            "type": "string",
            "enum": [
              "RUB"
            ],
            "description": "Offer currency. Currently RUB."
          }
        },
        "required": [
          "captured",
          "service_id",
          "name",
          "duration_days",
          "amount_minor",
          "currency"
        ],
        "additionalProperties": false,
        "description": "Original offer snapshot retained after catalogue edits. Legacy records use captured=false; unknown historical values stay null.",
        "example": {
          "captured": true,
          "service_id": 12,
          "name": "Наблюдение в течение 7 дней",
          "duration_days": 7,
          "amount_minor": 150000,
          "currency": "RUB"
        }
      },
      "FiscalDocument": {
        "type": "object",
        "properties": {
          "fiscal_drive_number": {
            "type": "string",
            "nullable": true,
            "description": "Fiscal storage device number (FN). String preserving digits/leading zeroes; null if unknown."
          },
          "document_number": {
            "type": "string",
            "nullable": true,
            "description": "Fiscal document number (FDN), distinct from receipt id and provider external_id. String; null if unknown."
          },
          "fiscal_sign": {
            "type": "string",
            "nullable": true,
            "description": "Fiscal document signature (FPD). String; null if unknown."
          },
          "registered_at": {
            "type": "integer",
            "nullable": true,
            "format": "int64",
            "description": "Receipt registration time in Unix seconds, normalized from the provider timezone; null if missing or malformed. Ferma dates without an offset use Europe/Moscow."
          }
        },
        "required": [
          "fiscal_drive_number",
          "document_number",
          "fiscal_sign",
          "registered_at"
        ],
        "additionalProperties": false,
        "description": "Known fiscal requisites. Identifiers are strings and unknown values remain null.",
        "example": {
          "fiscal_drive_number": "9999078900000001",
          "document_number": "101",
          "fiscal_sign": "1234567890",
          "registered_at": 1791972090
        }
      },
      "Receipt": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Internal Medsenger fiscal receipt ID."
          },
          "kind": {
            "type": "string",
            "enum": [
              "full",
              "advance",
              "settlement"
            ],
            "description": "full = full settlement in on_contract mode; advance = advance payment; settlement = final settlement of an advance after explicit service completion."
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "submitting",
              "accepted",
              "processed",
              "confirmed",
              "failed"
            ],
            "description": "pending = waiting to submit; submitting = submission started, result being reconciled; accepted = provider accepted request; processed = receipt formed, awaiting OFD transfer; confirmed = OFD transfer confirmed; failed = terminal failure. Intermediate states may be skipped between polls."
          },
          "external_id": {
            "type": "string",
            "nullable": true,
            "description": "Fiscal provider receipt ID, distinct from payment external_id and fiscal document number; null if unknown."
          },
          "receipt_url": {
            "type": "string",
            "nullable": true,
            "description": "Known HTTPS receipt viewing link; null if unavailable. May appear after initial submission."
          },
          "error_code": {
            "type": "string",
            "nullable": true,
            "description": "Latest fiscalization error code, or null. Open set: transport_error, provider_unavailable, authentication_failed, invalid_provider_response, payment_requires_review, ferma_kkt_error, ferma_<number>, etc. Can be transient while status is not failed."
          },
          "fiscal_document": {
            "allOf": [
              {
                "$ref": "#/components/schemas/FiscalDocument"
              }
            ],
            "description": "Known fiscal requisites. Always an object; individual unknown fields are null."
          }
        },
        "required": [
          "id",
          "kind",
          "status",
          "external_id",
          "receipt_url",
          "error_code",
          "fiscal_document"
        ],
        "additionalProperties": false,
        "description": "Medsenger cloud receipt; can be incomplete while processing.",
        "example": {
          "id": 4001,
          "kind": "advance",
          "status": "confirmed",
          "external_id": "example-receipt-4001",
          "receipt_url": "https://example.com/receipts/4001",
          "error_code": null,
          "fiscal_document": {
            "fiscal_drive_number": "9999078900000001",
            "document_number": "101",
            "fiscal_sign": "1234567890",
            "registered_at": 1791972090
          }
        }
      },
      "Fiscalization": {
        "type": "object",
        "properties": {
          "enabled_for_order": {
            "type": "boolean",
            "description": "Whether saved Medsenger cloud fiscalization settings exist for this purchase. False is not an error and does not exclude receipts issued elsewhere."
          },
          "mode": {
            "type": "string",
            "nullable": true,
            "enum": [
              "on_contract",
              "advance",
              null
            ],
            "description": "Saved purchase mode: on_contract = full receipt when payment is confirmed and a contract is linked; advance = advance receipt after payment, then settlement after explicit service completion and advance receipt status=confirmed. Extra invoices may require their own completion confirmation. Null if unknown/disabled."
          },
          "provider": {
            "type": "string",
            "nullable": true,
            "description": "Saved fiscal provider identifier, currently ofd_ferma (OFD.ru Ferma). Open set; null if unknown/disabled."
          },
          "environment": {
            "type": "string",
            "nullable": true,
            "enum": [
              "test",
              "production",
              null
            ],
            "description": "Fiscal provider environment: test, production or null if unknown. Independent from payment environment; null does not mean production."
          },
          "receipts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Receipt"
            },
            "description": "Known Medsenger cloud receipts sorted by ascending internal ID. May be empty even when enabled, while lifecycle steps are pending. No receipt is scheduled for a zero amount or a payment requiring review. Additional invoices may follow their own completion, independently from the whole contract."
          }
        },
        "required": [
          "enabled_for_order",
          "mode",
          "provider",
          "environment",
          "receipts"
        ],
        "additionalProperties": false,
        "description": "Purchase-specific cloud settings retained after current clinic settings change.",
        "example": {
          "enabled_for_order": true,
          "mode": "advance",
          "provider": "ofd_ferma",
          "environment": "production",
          "receipts": [
            {
              "id": 4001,
              "kind": "advance",
              "status": "confirmed",
              "external_id": "example-receipt-4001",
              "receipt_url": "https://example.com/receipts/4001",
              "error_code": null,
              "fiscal_document": {
                "fiscal_drive_number": "9999078900000001",
                "document_number": "101",
                "fiscal_sign": "1234567890",
                "registered_at": 1791972090
              }
            },
            {
              "id": 4002,
              "kind": "settlement",
              "status": "confirmed",
              "external_id": "example-receipt-4002",
              "receipt_url": "https://example.com/receipts/4002",
              "error_code": null,
              "fiscal_document": {
                "fiscal_drive_number": "9999078900000001",
                "document_number": "102",
                "fiscal_sign": "1234567890",
                "registered_at": 1792577040
              }
            }
          ]
        }
      },
      "Payment": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Internal payment/invoice ID. The same ID identifies a payment in an order and contract.payments; avoid double counting."
          },
          "amount_minor": {
            "type": "integer",
            "format": "int64",
            "description": "Authoritative invoice amount in integer kopecks; 150000 means RUB 1500.00. May differ from service.amount_minor."
          },
          "currency": {
            "type": "string",
            "enum": [
              "RUB"
            ],
            "description": "Invoice currency. Currently RUB."
          },
          "provider": {
            "type": "string",
            "description": "Gateway identifier, currently robokassa, yookassa or sberpay. Open set; independent from the fiscalization provider."
          },
          "environment": {
            "type": "string",
            "nullable": true,
            "enum": [
              "test",
              "production",
              null
            ],
            "description": "Saved gateway environment: test, production or null if unknown. Null must not be treated as production."
          },
          "is_paid": {
            "type": "boolean",
            "description": "Whether payment was confirmed. Can remain true after refund/reversal; also inspect status and issue."
          },
          "paid_at": {
            "type": "integer",
            "nullable": true,
            "format": "int64",
            "description": "Time Medsenger confirmed payment, in Unix seconds; null if unknown, including historical paid invoices."
          },
          "status": {
            "type": "string",
            "enum": [
              "not_started",
              "registering",
              "pending",
              "paid",
              "canceled",
              "refunded",
              "requires_review"
            ],
            "description": "requires_review takes precedence when issue is set; otherwise paid if is_paid=true; otherwise latest attempt status, or not_started. not_started = no attempt; registering = gateway registration in progress; pending = awaiting outcome; paid = confirmed; canceled = attempt canceled; refunded = attempt refunded; requires_review = reconciliation required. A refund normally yields requires_review with issue=refund_requires_review."
          },
          "issue": {
            "type": "string",
            "nullable": true,
            "description": "Reconciliation reason or null. Known open set: amount_or_currency_mismatch = gateway amount/currency mismatch; invoice_amount_changed = paid amount differs from invoice; duplicate_payment = another payment confirmed; refund_requires_review = refund reported; payment_reversed = cancellation after confirmation; registration_requires_review = registration needs reconciliation and automatic re-registration is blocked. Unknown non-null codes also require review."
          },
          "fulfillment_status": {
            "type": "string",
            "nullable": true,
            "description": "Post-payment processing: pending = actions such as contract creation/agent notification await completion or retry; done = actions completed; null = not started or unknown. Does not confirm service delivery; use contract.service_completed_at.",
            "enum": [
              "pending",
              "done",
              null
            ]
          },
          "external_id": {
            "type": "string",
            "nullable": true,
            "description": "Gateway payment reference; null before registration or if unknown. Distinct from internal payment ID and receipt external_id."
          },
          "fiscalization": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Fiscalization"
              }
            ],
            "description": "Saved purchase-specific cloud fiscalization settings and known receipts."
          }
        },
        "required": [
          "id",
          "amount_minor",
          "currency",
          "provider",
          "environment",
          "is_paid",
          "paid_at",
          "status",
          "issue",
          "fulfillment_status",
          "external_id",
          "fiscalization"
        ],
        "additionalProperties": false,
        "description": "Invoice/payment state, gateway reference, post-payment processing and optional receipts.",
        "example": {
          "id": 3001,
          "amount_minor": 150000,
          "currency": "RUB",
          "provider": "sberpay",
          "environment": "production",
          "is_paid": true,
          "paid_at": 1791972060,
          "status": "paid",
          "issue": null,
          "fulfillment_status": "done",
          "external_id": "example-bank-order-3001",
          "fiscalization": {
            "enabled_for_order": true,
            "mode": "advance",
            "provider": "ofd_ferma",
            "environment": "production",
            "receipts": [
              {
                "id": 4001,
                "kind": "advance",
                "status": "confirmed",
                "external_id": "example-receipt-4001",
                "receipt_url": "https://example.com/receipts/4001",
                "error_code": null,
                "fiscal_document": {
                  "fiscal_drive_number": "9999078900000001",
                  "document_number": "101",
                  "fiscal_sign": "1234567890",
                  "registered_at": 1791972090
                }
              },
              {
                "id": 4002,
                "kind": "settlement",
                "status": "confirmed",
                "external_id": "example-receipt-4002",
                "receipt_url": "https://example.com/receipts/4002",
                "error_code": null,
                "fiscal_document": {
                  "fiscal_drive_number": "9999078900000001",
                  "document_number": "102",
                  "fiscal_sign": "1234567890",
                  "registered_at": 1792577040
                }
              }
            ]
          }
        }
      },
      "ContractProgress": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Internal contract ID; equals order.contract_id when embedded."
          },
          "status": {
            "type": "string",
            "enum": [
              "waiting_activation",
              "active",
              "expired",
              "closed"
            ],
            "description": "Computed with precedence: closed if manually closed; waiting_activation if delayed and not activated; expired if ends_at is in the past; active otherwise. Conclusion and service completion are separate."
          },
          "starts_at": {
            "type": "integer",
            "nullable": true,
            "format": "int64",
            "description": "Contract start in Unix seconds; null if unknown."
          },
          "ends_at": {
            "type": "integer",
            "nullable": true,
            "format": "int64",
            "description": "Contract end in Unix seconds; null if unknown. Expiry enters synchronization without a manual save."
          },
          "activated_at": {
            "type": "integer",
            "nullable": true,
            "format": "int64",
            "description": "Activation time in Unix seconds; null if not activated or unknown."
          },
          "is_delayed": {
            "type": "boolean",
            "description": "Whether delayed activation is configured. Can remain true after activation; inspect status and activated_at."
          },
          "awaiting_conclusion": {
            "type": "boolean",
            "description": "Whether doctor conclusion completion is awaited. Independent from status/payment."
          },
          "concluded_at": {
            "type": "integer",
            "nullable": true,
            "format": "int64",
            "description": "Conclusion completion time in Unix seconds; null if not completed or unknown."
          },
          "service_completed_at": {
            "type": "integer",
            "nullable": true,
            "format": "int64",
            "description": "Explicit service completion time in Unix seconds; null if not confirmed. Independent from expiry/payment/receipts. Reopening does not automatically erase prior confirmation."
          },
          "service_completed_by": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "nullable": true,
                "enum": [
                  "doctor",
                  "administrator",
                  null
                ],
                "description": "Confirming actor role: doctor, administrator, or null if unknown."
              },
              "id": {
                "type": "integer",
                "format": "int64",
                "nullable": true,
                "description": "Confirming account ID: users.id for type=doctor, registrators.id for type=administrator. This is not doctor.id (the clinic doctor record ID). Null if unknown."
              }
            },
            "required": [
              "type",
              "id"
            ],
            "additionalProperties": false,
            "nullable": true,
            "description": "Confirming actor, or null when no completion is recorded. Historical type/id may individually be null."
          }
        },
        "required": [
          "id",
          "status",
          "starts_at",
          "ends_at",
          "activated_at",
          "is_delayed",
          "awaiting_conclusion",
          "concluded_at",
          "service_completed_at",
          "service_completed_by"
        ],
        "additionalProperties": false,
        "nullable": true,
        "description": "Short contract state embedded in an order; null when no accessible linked contract exists.",
        "example": {
          "id": 2001,
          "status": "closed",
          "starts_at": 1791972120,
          "ends_at": 1792576920,
          "activated_at": 1791972120,
          "is_delayed": false,
          "awaiting_conclusion": false,
          "concluded_at": 1792576980,
          "service_completed_at": 1792576980,
          "service_completed_by": {
            "type": "doctor",
            "id": 131
          }
        }
      },
      "Order": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Internal consulting order ID."
          },
          "clinic_id": {
            "type": "integer",
            "format": "int64",
            "description": "Clinic selected by the Bearer key. A clinic_id query parameter cannot select a clinic."
          },
          "created_at": {
            "type": "integer",
            "nullable": true,
            "format": "int64",
            "description": "Record creation time in Unix seconds; null if unknown."
          },
          "revision": {
            "type": "integer",
            "format": "int64",
            "description": "Latest published change number, increasing across both resources within this clinic. Gaps are normal. Compare revisions for the same (clinic_id, resource, id). Not a query cursor."
          },
          "updated_at": {
            "type": "integer",
            "nullable": true,
            "format": "int64",
            "description": "Publication time of the latest exported change in Unix seconds, including nested payment/receipt changes; not merely the source model update time. Null if unknown."
          },
          "status": {
            "type": "string",
            "enum": [
              "created",
              "payment_required",
              "accepted",
              "declined"
            ],
            "description": "created = submitted; payment_required = payment stage; accepted = accepted with a linked contract; declined = rejected. Independent from payment.status."
          },
          "reviewed_at": {
            "type": "integer",
            "nullable": true,
            "format": "int64",
            "description": "Recorded review/acceptance/rejection time in Unix seconds; null if not reviewed or unknown."
          },
          "service": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Service"
              }
            ],
            "description": "Original offer including known historical conditions."
          },
          "duration_days": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "description": "Current requested duration in days, or null. service.duration_days is the captured duration and is not recomputed after edits."
          },
          "doctor": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Doctor"
              }
            ],
            "description": "Selected clinic doctor, or null if unavailable."
          },
          "customer": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "nullable": true,
                "description": "Customer name saved in the request; null if unknown."
              },
              "email": {
                "type": "string",
                "nullable": true,
                "description": "Customer email saved in the request; null if unknown."
              },
              "phone": {
                "type": "string",
                "nullable": true,
                "description": "Customer phone saved in the request; null if unknown. No normalized telephone format is guaranteed."
              }
            },
            "required": [
              "name",
              "email",
              "phone"
            ],
            "additionalProperties": false,
            "description": "Customer details saved in the request; may differ from the current patient profile."
          },
          "payment": {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer",
                "format": "int64",
                "description": "Internal payment/invoice ID. The same ID identifies a payment in an order and contract.payments; avoid double counting."
              },
              "amount_minor": {
                "type": "integer",
                "format": "int64",
                "description": "Authoritative invoice amount in integer kopecks; 150000 means RUB 1500.00. May differ from service.amount_minor."
              },
              "currency": {
                "type": "string",
                "enum": [
                  "RUB"
                ],
                "description": "Invoice currency. Currently RUB."
              },
              "provider": {
                "type": "string",
                "description": "Gateway identifier, currently robokassa, yookassa or sberpay. Open set; independent from the fiscalization provider."
              },
              "environment": {
                "type": "string",
                "nullable": true,
                "enum": [
                  "test",
                  "production",
                  null
                ],
                "description": "Saved gateway environment: test, production or null if unknown. Null must not be treated as production."
              },
              "is_paid": {
                "type": "boolean",
                "description": "Whether payment was confirmed. Can remain true after refund/reversal; also inspect status and issue."
              },
              "paid_at": {
                "type": "integer",
                "nullable": true,
                "format": "int64",
                "description": "Time Medsenger confirmed payment, in Unix seconds; null if unknown, including historical paid invoices."
              },
              "status": {
                "type": "string",
                "enum": [
                  "not_started",
                  "registering",
                  "pending",
                  "paid",
                  "canceled",
                  "refunded",
                  "requires_review"
                ],
                "description": "requires_review takes precedence when issue is set; otherwise paid if is_paid=true; otherwise latest attempt status, or not_started. not_started = no attempt; registering = gateway registration in progress; pending = awaiting outcome; paid = confirmed; canceled = attempt canceled; refunded = attempt refunded; requires_review = reconciliation required. A refund normally yields requires_review with issue=refund_requires_review."
              },
              "issue": {
                "type": "string",
                "nullable": true,
                "description": "Reconciliation reason or null. Known open set: amount_or_currency_mismatch = gateway amount/currency mismatch; invoice_amount_changed = paid amount differs from invoice; duplicate_payment = another payment confirmed; refund_requires_review = refund reported; payment_reversed = cancellation after confirmation; registration_requires_review = registration needs reconciliation and automatic re-registration is blocked. Unknown non-null codes also require review."
              },
              "fulfillment_status": {
                "type": "string",
                "nullable": true,
                "description": "Post-payment processing: pending = actions such as contract creation/agent notification await completion or retry; done = actions completed; null = not started or unknown. Does not confirm service delivery; use contract.service_completed_at.",
                "enum": [
                  "pending",
                  "done",
                  null
                ]
              },
              "external_id": {
                "type": "string",
                "nullable": true,
                "description": "Gateway payment reference; null before registration or if unknown. Distinct from internal payment ID and receipt external_id."
              },
              "fiscalization": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/Fiscalization"
                  }
                ],
                "description": "Saved purchase-specific cloud fiscalization settings and known receipts."
              }
            },
            "required": [
              "id",
              "amount_minor",
              "currency",
              "provider",
              "environment",
              "is_paid",
              "paid_at",
              "status",
              "issue",
              "fulfillment_status",
              "external_id",
              "fiscalization"
            ],
            "additionalProperties": false,
            "description": "Linked payment, or null if none. Null does not prove the service is free.",
            "nullable": true
          },
          "contract_id": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "description": "Linked contract ID, or null. Can be null after payment while contract creation is pending."
          },
          "contract": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ContractProgress"
              }
            ],
            "description": "Short linked contract state, or null. Omits patient, service, doctors, payments and export revision."
          }
        },
        "required": [
          "id",
          "clinic_id",
          "created_at",
          "revision",
          "updated_at",
          "status",
          "reviewed_at",
          "service",
          "duration_days",
          "doctor",
          "customer",
          "payment",
          "contract_id",
          "contract"
        ],
        "additionalProperties": false,
        "description": "Current consulting order. All listed properties are present, including nullable ones; deleted records have a separate reduced shape.",
        "example": {
          "id": 1001,
          "clinic_id": 7,
          "created_at": 1791972000,
          "revision": 41,
          "updated_at": 1792577100,
          "status": "accepted",
          "reviewed_at": 1791972120,
          "service": {
            "captured": true,
            "service_id": 12,
            "name": "Наблюдение в течение 7 дней",
            "duration_days": 7,
            "amount_minor": 150000,
            "currency": "RUB"
          },
          "duration_days": 7,
          "doctor": {
            "id": 31,
            "name": "Анна Примерова"
          },
          "customer": {
            "name": "Иван Примеров",
            "email": "patient@example.com",
            "phone": null
          },
          "payment": {
            "id": 3001,
            "amount_minor": 150000,
            "currency": "RUB",
            "provider": "sberpay",
            "environment": "production",
            "is_paid": true,
            "paid_at": 1791972060,
            "status": "paid",
            "issue": null,
            "fulfillment_status": "done",
            "external_id": "example-bank-order-3001",
            "fiscalization": {
              "enabled_for_order": true,
              "mode": "advance",
              "provider": "ofd_ferma",
              "environment": "production",
              "receipts": [
                {
                  "id": 4001,
                  "kind": "advance",
                  "status": "confirmed",
                  "external_id": "example-receipt-4001",
                  "receipt_url": "https://example.com/receipts/4001",
                  "error_code": null,
                  "fiscal_document": {
                    "fiscal_drive_number": "9999078900000001",
                    "document_number": "101",
                    "fiscal_sign": "1234567890",
                    "registered_at": 1791972090
                  }
                },
                {
                  "id": 4002,
                  "kind": "settlement",
                  "status": "confirmed",
                  "external_id": "example-receipt-4002",
                  "receipt_url": "https://example.com/receipts/4002",
                  "error_code": null,
                  "fiscal_document": {
                    "fiscal_drive_number": "9999078900000001",
                    "document_number": "102",
                    "fiscal_sign": "1234567890",
                    "registered_at": 1792577040
                  }
                }
              ]
            }
          },
          "contract_id": 2001,
          "contract": {
            "id": 2001,
            "status": "closed",
            "starts_at": 1791972120,
            "ends_at": 1792576920,
            "activated_at": 1791972120,
            "is_delayed": false,
            "awaiting_conclusion": false,
            "concluded_at": 1792576980,
            "service_completed_at": 1792576980,
            "service_completed_by": {
              "type": "doctor",
              "id": 131
            }
          }
        }
      },
      "Contract": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Internal contract ID."
          },
          "status": {
            "type": "string",
            "enum": [
              "waiting_activation",
              "active",
              "expired",
              "closed"
            ],
            "description": "Computed with precedence: closed if manually closed; waiting_activation if delayed and not activated; expired if ends_at is in the past; active otherwise. Conclusion and service completion are separate."
          },
          "starts_at": {
            "type": "integer",
            "nullable": true,
            "format": "int64",
            "description": "Contract start in Unix seconds; null if unknown."
          },
          "ends_at": {
            "type": "integer",
            "nullable": true,
            "format": "int64",
            "description": "Contract end in Unix seconds; null if unknown. Expiry enters synchronization without a manual save."
          },
          "activated_at": {
            "type": "integer",
            "nullable": true,
            "format": "int64",
            "description": "Activation time in Unix seconds; null if not activated or unknown."
          },
          "is_delayed": {
            "type": "boolean",
            "description": "Whether delayed activation is configured. Can remain true after activation; inspect status and activated_at."
          },
          "awaiting_conclusion": {
            "type": "boolean",
            "description": "Whether doctor conclusion completion is awaited. Independent from status/payment."
          },
          "concluded_at": {
            "type": "integer",
            "nullable": true,
            "format": "int64",
            "description": "Conclusion completion time in Unix seconds; null if not completed or unknown."
          },
          "service_completed_at": {
            "type": "integer",
            "nullable": true,
            "format": "int64",
            "description": "Explicit service completion time in Unix seconds; null if not confirmed. Independent from expiry/payment/receipts. Reopening does not automatically erase prior confirmation."
          },
          "service_completed_by": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "nullable": true,
                "enum": [
                  "doctor",
                  "administrator",
                  null
                ],
                "description": "Confirming actor role: doctor, administrator, or null if unknown."
              },
              "id": {
                "type": "integer",
                "format": "int64",
                "nullable": true,
                "description": "Confirming account ID: users.id for type=doctor, registrators.id for type=administrator. This is not doctor.id (the clinic doctor record ID). Null if unknown."
              }
            },
            "required": [
              "type",
              "id"
            ],
            "additionalProperties": false,
            "nullable": true,
            "description": "Confirming actor, or null when no completion is recorded. Historical type/id may individually be null."
          },
          "clinic_id": {
            "type": "integer",
            "format": "int64",
            "description": "Clinic selected by the Bearer key. A clinic_id query parameter cannot select a clinic."
          },
          "created_at": {
            "type": "integer",
            "nullable": true,
            "format": "int64",
            "description": "Record creation time in Unix seconds; null if unknown."
          },
          "revision": {
            "type": "integer",
            "format": "int64",
            "description": "Latest published change number, increasing across both resources within this clinic. Gaps are normal. Compare revisions for the same (clinic_id, resource, id). Not a query cursor."
          },
          "updated_at": {
            "type": "integer",
            "nullable": true,
            "format": "int64",
            "description": "Publication time of the latest exported change in Unix seconds, including nested payment/receipt changes; not merely the source model update time. Null if unknown."
          },
          "number": {
            "type": "string",
            "nullable": true,
            "description": "Human-readable contract number, or null. Use id as the stable key."
          },
          "consulting_order_id": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "description": "Related consulting order ID, or null. If several orders reference the contract, returns the smallest order ID."
          },
          "patient": {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer",
                "format": "int64",
                "description": "Clinic patient record ID, not user ID."
              },
              "name": {
                "type": "string",
                "nullable": true,
                "description": "Current patient name; null if unknown."
              },
              "email": {
                "type": "string",
                "nullable": true,
                "description": "Current patient email; null if unknown."
              },
              "phone": {
                "type": "string",
                "nullable": true,
                "description": "Current patient phone; null if unknown. No normalized telephone format is guaranteed."
              }
            },
            "required": [
              "id",
              "name",
              "email",
              "phone"
            ],
            "additionalProperties": false,
            "nullable": true,
            "description": "Current clinic patient profile, or null if unavailable. Patient ID differs from user account ID."
          },
          "service": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Service"
              }
            ],
            "description": "Original offer inherited from the order when available, otherwise captured for the contract."
          },
          "main_doctor": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Doctor"
              }
            ],
            "description": "Main clinic doctor, or null if unavailable."
          },
          "responsible_doctor": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Doctor"
              }
            ],
            "description": "Current responsible doctor, falling back to the main doctor when none is assigned; null if unavailable."
          },
          "contract_type": {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer",
                "format": "int64",
                "description": "Internal clinic contract classifier ID."
              },
              "name": {
                "type": "string",
                "nullable": true,
                "description": "Current classifier name; null if unavailable."
              }
            },
            "required": [
              "id",
              "name"
            ],
            "additionalProperties": false,
            "nullable": true,
            "description": "Clinic contract classifier ID/name, or null if unavailable."
          },
          "is_eternal": {
            "type": "boolean",
            "description": "Current clinic eternal_contracts setting, not a saved per-contract flag. Does not override computed status or imply ends_at=null."
          },
          "payments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Payment"
            },
            "description": "Linked clinic invoices sorted by ascending internal ID. Can be empty; includes unpaid invoices too."
          }
        },
        "required": [
          "id",
          "status",
          "starts_at",
          "ends_at",
          "activated_at",
          "is_delayed",
          "awaiting_conclusion",
          "concluded_at",
          "service_completed_at",
          "service_completed_by",
          "clinic_id",
          "created_at",
          "revision",
          "updated_at",
          "number",
          "consulting_order_id",
          "patient",
          "service",
          "main_doctor",
          "responsible_doctor",
          "contract_type",
          "is_eternal",
          "payments"
        ],
        "additionalProperties": false,
        "description": "Current clinic contract, including contracts without orders/payments. All listed properties are present, including nullable ones.",
        "example": {
          "id": 2001,
          "status": "closed",
          "starts_at": 1791972120,
          "ends_at": 1792576920,
          "activated_at": 1791972120,
          "is_delayed": false,
          "awaiting_conclusion": false,
          "concluded_at": 1792576980,
          "service_completed_at": 1792576980,
          "service_completed_by": {
            "type": "doctor",
            "id": 131
          },
          "clinic_id": 7,
          "number": "2026/2001",
          "created_at": 1791972120,
          "revision": 42,
          "updated_at": 1792577100,
          "consulting_order_id": 1001,
          "patient": {
            "id": 51,
            "name": "Иван Примеров",
            "email": "patient@example.com",
            "phone": null
          },
          "service": {
            "captured": true,
            "service_id": 12,
            "name": "Наблюдение в течение 7 дней",
            "duration_days": 7,
            "amount_minor": 150000,
            "currency": "RUB"
          },
          "main_doctor": {
            "id": 31,
            "name": "Анна Примерова"
          },
          "responsible_doctor": {
            "id": 31,
            "name": "Анна Примерова"
          },
          "contract_type": {
            "id": 9,
            "name": "Дистанционное наблюдение"
          },
          "is_eternal": false,
          "payments": [
            {
              "id": 3001,
              "amount_minor": 150000,
              "currency": "RUB",
              "provider": "sberpay",
              "environment": "production",
              "is_paid": true,
              "paid_at": 1791972060,
              "status": "paid",
              "issue": null,
              "fulfillment_status": "done",
              "external_id": "example-bank-order-3001",
              "fiscalization": {
                "enabled_for_order": true,
                "mode": "advance",
                "provider": "ofd_ferma",
                "environment": "production",
                "receipts": [
                  {
                    "id": 4001,
                    "kind": "advance",
                    "status": "confirmed",
                    "external_id": "example-receipt-4001",
                    "receipt_url": "https://example.com/receipts/4001",
                    "error_code": null,
                    "fiscal_document": {
                      "fiscal_drive_number": "9999078900000001",
                      "document_number": "101",
                      "fiscal_sign": "1234567890",
                      "registered_at": 1791972090
                    }
                  },
                  {
                    "id": 4002,
                    "kind": "settlement",
                    "status": "confirmed",
                    "external_id": "example-receipt-4002",
                    "receipt_url": "https://example.com/receipts/4002",
                    "error_code": null,
                    "fiscal_document": {
                      "fiscal_drive_number": "9999078900000001",
                      "document_number": "102",
                      "fiscal_sign": "1234567890",
                      "registered_at": 1792577040
                    }
                  }
                ]
              }
            },
            {
              "id": 3002,
              "amount_minor": 50000,
              "currency": "RUB",
              "provider": "sberpay",
              "environment": "production",
              "is_paid": true,
              "paid_at": 1791972300,
              "status": "paid",
              "issue": null,
              "fulfillment_status": "done",
              "external_id": "example-bank-order-3002",
              "fiscalization": {
                "enabled_for_order": false,
                "mode": null,
                "provider": null,
                "environment": null,
                "receipts": []
              }
            }
          ]
        }
      },
      "Deleted": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Deleted record ID in the resource being listed."
          },
          "clinic_id": {
            "type": "integer",
            "format": "int64",
            "description": "Clinic selected by the Bearer key. A clinic_id query parameter cannot select a clinic."
          },
          "deleted": {
            "type": "boolean",
            "enum": [
              true
            ],
            "description": "Always true. Live records omit this field; they do not return deleted=false."
          },
          "revision": {
            "type": "integer",
            "format": "int64",
            "description": "Latest published change number, increasing across both resources within this clinic. Gaps are normal. Compare revisions for the same (clinic_id, resource, id). Not a query cursor."
          },
          "updated_at": {
            "type": "integer",
            "nullable": true,
            "format": "int64",
            "description": "Publication time of the latest exported change in Unix seconds, including nested payment/receipt changes; not merely the source model update time. Null if unknown."
          }
        },
        "required": [
          "id",
          "clinic_id",
          "deleted",
          "revision",
          "updated_at"
        ],
        "additionalProperties": false,
        "description": "List-only deletion marker containing exactly id, clinic_id, deleted, revision, updated_at. Detail lookup returns 404. Status/payment/creation-date filters exclude markers.",
        "example": {
          "id": 1003,
          "clinic_id": 7,
          "deleted": true,
          "revision": 47,
          "updated_at": 1792577100
        }
      },
      "Meta": {
        "type": "object",
        "properties": {
          "has_more": {
            "type": "boolean",
            "description": "Whether more records match after this page. Continue with page+1 while true."
          },
          "page": {
            "type": "integer",
            "format": "int64",
            "minimum": 1,
            "description": "Requested page number, starting at 1."
          },
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 500,
            "description": "Requested page size, default 100; final page may contain fewer records."
          },
          "generated_at": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "description": "Server time at request start, in Unix seconds. Keep the FIRST successful page value; only after storing all pages commit it as next inclusive updated_since."
          }
        },
        "required": [
          "has_more",
          "page",
          "limit",
          "generated_at"
        ],
        "additionalProperties": false,
        "description": "Numbered page metadata. No total count, session token or continuation cursor.",
        "example": {
          "has_more": false,
          "page": 1,
          "limit": 100,
          "generated_at": 1792577160
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "description": "Stable machine error code.",
                "enum": [
                  "unauthorized",
                  "api_disabled",
                  "not_found",
                  "method_not_allowed",
                  "invalid_parameters",
                  "rate_limited",
                  "export_preparing",
                  "internal_error"
                ]
              },
              "message": {
                "type": "string",
                "description": "Localized explanation; wording/language may change."
              },
              "details": {
                "type": "object",
                "additionalProperties": true,
                "description": "Additional diagnostics. Validation field names map to arrays of localized messages. May be an empty object, including for unknown parameters."
              }
            },
            "required": [
              "code",
              "message",
              "details"
            ],
            "additionalProperties": false,
            "description": "Structured error. Branch on code; message is localized and is not a stable machine identifier."
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": false,
        "description": "Shared error envelope. details may be empty for unknown query parameters or inconsistent time bounds.",
        "example": {
          "error": {
            "code": "unauthorized",
            "message": "Необходим действующий ключ API.",
            "details": {}
          }
        }
      }
    },
    "examples": {
      "OrderList": {
        "summary": "Заявки с оплатой и без связанного платежа",
        "value": {
          "data": [
            {
              "id": 1001,
              "clinic_id": 7,
              "created_at": 1791972000,
              "revision": 41,
              "updated_at": 1792577100,
              "status": "accepted",
              "reviewed_at": 1791972120,
              "service": {
                "captured": true,
                "service_id": 12,
                "name": "Наблюдение в течение 7 дней",
                "duration_days": 7,
                "amount_minor": 150000,
                "currency": "RUB"
              },
              "duration_days": 7,
              "doctor": {
                "id": 31,
                "name": "Анна Примерова"
              },
              "customer": {
                "name": "Иван Примеров",
                "email": "patient@example.com",
                "phone": null
              },
              "payment": {
                "id": 3001,
                "amount_minor": 150000,
                "currency": "RUB",
                "provider": "sberpay",
                "environment": "production",
                "is_paid": true,
                "paid_at": 1791972060,
                "status": "paid",
                "issue": null,
                "fulfillment_status": "done",
                "external_id": "example-bank-order-3001",
                "fiscalization": {
                  "enabled_for_order": true,
                  "mode": "advance",
                  "provider": "ofd_ferma",
                  "environment": "production",
                  "receipts": [
                    {
                      "id": 4001,
                      "kind": "advance",
                      "status": "confirmed",
                      "external_id": "example-receipt-4001",
                      "receipt_url": "https://example.com/receipts/4001",
                      "error_code": null,
                      "fiscal_document": {
                        "fiscal_drive_number": "9999078900000001",
                        "document_number": "101",
                        "fiscal_sign": "1234567890",
                        "registered_at": 1791972090
                      }
                    },
                    {
                      "id": 4002,
                      "kind": "settlement",
                      "status": "confirmed",
                      "external_id": "example-receipt-4002",
                      "receipt_url": "https://example.com/receipts/4002",
                      "error_code": null,
                      "fiscal_document": {
                        "fiscal_drive_number": "9999078900000001",
                        "document_number": "102",
                        "fiscal_sign": "1234567890",
                        "registered_at": 1792577040
                      }
                    }
                  ]
                }
              },
              "contract_id": 2001,
              "contract": {
                "id": 2001,
                "status": "closed",
                "starts_at": 1791972120,
                "ends_at": 1792576920,
                "activated_at": 1791972120,
                "is_delayed": false,
                "awaiting_conclusion": false,
                "concluded_at": 1792576980,
                "service_completed_at": 1792576980,
                "service_completed_by": {
                  "type": "doctor",
                  "id": 131
                }
              }
            },
            {
              "id": 1002,
              "clinic_id": 7,
              "created_at": 1791972000,
              "revision": 43,
              "updated_at": 1792577100,
              "status": "created",
              "reviewed_at": null,
              "service": {
                "captured": false,
                "service_id": null,
                "name": null,
                "duration_days": 7,
                "amount_minor": null,
                "currency": "RUB"
              },
              "duration_days": 7,
              "doctor": {
                "id": 31,
                "name": "Анна Примерова"
              },
              "customer": {
                "name": "Иван Примеров",
                "email": "patient@example.com",
                "phone": null
              },
              "payment": null,
              "contract_id": null,
              "contract": null
            }
          ],
          "meta": {
            "has_more": false,
            "page": 1,
            "limit": 100,
            "generated_at": 1792577160
          }
        }
      },
      "UnpaidOrderList": {
        "summary": "Заявка без платежа; исторические условия неизвестны",
        "value": {
          "data": [
            {
              "id": 1002,
              "clinic_id": 7,
              "created_at": 1791972000,
              "revision": 43,
              "updated_at": 1792577100,
              "status": "created",
              "reviewed_at": null,
              "service": {
                "captured": false,
                "service_id": null,
                "name": null,
                "duration_days": 7,
                "amount_minor": null,
                "currency": "RUB"
              },
              "duration_days": 7,
              "doctor": {
                "id": 31,
                "name": "Анна Примерова"
              },
              "customer": {
                "name": "Иван Примеров",
                "email": "patient@example.com",
                "phone": null
              },
              "payment": null,
              "contract_id": null,
              "contract": null
            }
          ],
          "meta": {
            "has_more": false,
            "page": 1,
            "limit": 100,
            "generated_at": 1792577160
          }
        }
      },
      "OrderDetail": {
        "summary": "Оплаченная заявка с контрактом и двумя чеками",
        "value": {
          "data": {
            "id": 1001,
            "clinic_id": 7,
            "created_at": 1791972000,
            "revision": 41,
            "updated_at": 1792577100,
            "status": "accepted",
            "reviewed_at": 1791972120,
            "service": {
              "captured": true,
              "service_id": 12,
              "name": "Наблюдение в течение 7 дней",
              "duration_days": 7,
              "amount_minor": 150000,
              "currency": "RUB"
            },
            "duration_days": 7,
            "doctor": {
              "id": 31,
              "name": "Анна Примерова"
            },
            "customer": {
              "name": "Иван Примеров",
              "email": "patient@example.com",
              "phone": null
            },
            "payment": {
              "id": 3001,
              "amount_minor": 150000,
              "currency": "RUB",
              "provider": "sberpay",
              "environment": "production",
              "is_paid": true,
              "paid_at": 1791972060,
              "status": "paid",
              "issue": null,
              "fulfillment_status": "done",
              "external_id": "example-bank-order-3001",
              "fiscalization": {
                "enabled_for_order": true,
                "mode": "advance",
                "provider": "ofd_ferma",
                "environment": "production",
                "receipts": [
                  {
                    "id": 4001,
                    "kind": "advance",
                    "status": "confirmed",
                    "external_id": "example-receipt-4001",
                    "receipt_url": "https://example.com/receipts/4001",
                    "error_code": null,
                    "fiscal_document": {
                      "fiscal_drive_number": "9999078900000001",
                      "document_number": "101",
                      "fiscal_sign": "1234567890",
                      "registered_at": 1791972090
                    }
                  },
                  {
                    "id": 4002,
                    "kind": "settlement",
                    "status": "confirmed",
                    "external_id": "example-receipt-4002",
                    "receipt_url": "https://example.com/receipts/4002",
                    "error_code": null,
                    "fiscal_document": {
                      "fiscal_drive_number": "9999078900000001",
                      "document_number": "102",
                      "fiscal_sign": "1234567890",
                      "registered_at": 1792577040
                    }
                  }
                ]
              }
            },
            "contract_id": 2001,
            "contract": {
              "id": 2001,
              "status": "closed",
              "starts_at": 1791972120,
              "ends_at": 1792576920,
              "activated_at": 1791972120,
              "is_delayed": false,
              "awaiting_conclusion": false,
              "concluded_at": 1792576980,
              "service_completed_at": 1792576980,
              "service_completed_by": {
                "type": "doctor",
                "id": 131
              }
            }
          }
        }
      },
      "PaymentPendingOrder": {
        "summary": "Оплата подтверждена; создание контракта ещё не завершено",
        "value": {
          "data": {
            "id": 1001,
            "clinic_id": 7,
            "created_at": 1791972000,
            "revision": 45,
            "updated_at": 1792577100,
            "status": "payment_required",
            "reviewed_at": null,
            "service": {
              "captured": true,
              "service_id": 12,
              "name": "Наблюдение в течение 7 дней",
              "duration_days": 7,
              "amount_minor": 150000,
              "currency": "RUB"
            },
            "duration_days": 7,
            "doctor": {
              "id": 31,
              "name": "Анна Примерова"
            },
            "customer": {
              "name": "Иван Примеров",
              "email": "patient@example.com",
              "phone": null
            },
            "payment": {
              "id": 3001,
              "amount_minor": 150000,
              "currency": "RUB",
              "provider": "sberpay",
              "environment": "production",
              "is_paid": true,
              "paid_at": 1791972060,
              "status": "paid",
              "issue": null,
              "fulfillment_status": "pending",
              "external_id": "example-bank-order-3001",
              "fiscalization": {
                "enabled_for_order": false,
                "mode": null,
                "provider": null,
                "environment": null,
                "receipts": []
              }
            },
            "contract_id": null,
            "contract": null
          }
        }
      },
      "ReviewRequiredOrder": {
        "summary": "Возврат требует сверки при is_paid=true",
        "value": {
          "data": {
            "id": 1001,
            "clinic_id": 7,
            "created_at": 1791972000,
            "revision": 46,
            "updated_at": 1792577100,
            "status": "accepted",
            "reviewed_at": 1791972120,
            "service": {
              "captured": true,
              "service_id": 12,
              "name": "Наблюдение в течение 7 дней",
              "duration_days": 7,
              "amount_minor": 150000,
              "currency": "RUB"
            },
            "duration_days": 7,
            "doctor": {
              "id": 31,
              "name": "Анна Примерова"
            },
            "customer": {
              "name": "Иван Примеров",
              "email": "patient@example.com",
              "phone": null
            },
            "payment": {
              "id": 3001,
              "amount_minor": 150000,
              "currency": "RUB",
              "provider": "sberpay",
              "environment": "production",
              "is_paid": true,
              "paid_at": 1791972060,
              "status": "requires_review",
              "issue": "refund_requires_review",
              "fulfillment_status": "done",
              "external_id": "example-bank-order-3001",
              "fiscalization": {
                "enabled_for_order": true,
                "mode": "advance",
                "provider": "ofd_ferma",
                "environment": "production",
                "receipts": [
                  {
                    "id": 4001,
                    "kind": "advance",
                    "status": "confirmed",
                    "external_id": "example-receipt-4001",
                    "receipt_url": "https://example.com/receipts/4001",
                    "error_code": null,
                    "fiscal_document": {
                      "fiscal_drive_number": "9999078900000001",
                      "document_number": "101",
                      "fiscal_sign": "1234567890",
                      "registered_at": 1791972090
                    }
                  },
                  {
                    "id": 4002,
                    "kind": "settlement",
                    "status": "confirmed",
                    "external_id": "example-receipt-4002",
                    "receipt_url": "https://example.com/receipts/4002",
                    "error_code": null,
                    "fiscal_document": {
                      "fiscal_drive_number": "9999078900000001",
                      "document_number": "102",
                      "fiscal_sign": "1234567890",
                      "registered_at": 1792577040
                    }
                  }
                ]
              }
            },
            "contract_id": 2001,
            "contract": {
              "id": 2001,
              "status": "closed",
              "starts_at": 1791972120,
              "ends_at": 1792576920,
              "activated_at": 1791972120,
              "is_delayed": false,
              "awaiting_conclusion": false,
              "concluded_at": 1792576980,
              "service_completed_at": 1792576980,
              "service_completed_by": {
                "type": "doctor",
                "id": 131
              }
            }
          }
        }
      },
      "ContractList": {
        "summary": "Контракт с двумя платежами",
        "value": {
          "data": [
            {
              "id": 2001,
              "status": "closed",
              "starts_at": 1791972120,
              "ends_at": 1792576920,
              "activated_at": 1791972120,
              "is_delayed": false,
              "awaiting_conclusion": false,
              "concluded_at": 1792576980,
              "service_completed_at": 1792576980,
              "service_completed_by": {
                "type": "doctor",
                "id": 131
              },
              "clinic_id": 7,
              "number": "2026/2001",
              "created_at": 1791972120,
              "revision": 42,
              "updated_at": 1792577100,
              "consulting_order_id": 1001,
              "patient": {
                "id": 51,
                "name": "Иван Примеров",
                "email": "patient@example.com",
                "phone": null
              },
              "service": {
                "captured": true,
                "service_id": 12,
                "name": "Наблюдение в течение 7 дней",
                "duration_days": 7,
                "amount_minor": 150000,
                "currency": "RUB"
              },
              "main_doctor": {
                "id": 31,
                "name": "Анна Примерова"
              },
              "responsible_doctor": {
                "id": 31,
                "name": "Анна Примерова"
              },
              "contract_type": {
                "id": 9,
                "name": "Дистанционное наблюдение"
              },
              "is_eternal": false,
              "payments": [
                {
                  "id": 3001,
                  "amount_minor": 150000,
                  "currency": "RUB",
                  "provider": "sberpay",
                  "environment": "production",
                  "is_paid": true,
                  "paid_at": 1791972060,
                  "status": "paid",
                  "issue": null,
                  "fulfillment_status": "done",
                  "external_id": "example-bank-order-3001",
                  "fiscalization": {
                    "enabled_for_order": true,
                    "mode": "advance",
                    "provider": "ofd_ferma",
                    "environment": "production",
                    "receipts": [
                      {
                        "id": 4001,
                        "kind": "advance",
                        "status": "confirmed",
                        "external_id": "example-receipt-4001",
                        "receipt_url": "https://example.com/receipts/4001",
                        "error_code": null,
                        "fiscal_document": {
                          "fiscal_drive_number": "9999078900000001",
                          "document_number": "101",
                          "fiscal_sign": "1234567890",
                          "registered_at": 1791972090
                        }
                      },
                      {
                        "id": 4002,
                        "kind": "settlement",
                        "status": "confirmed",
                        "external_id": "example-receipt-4002",
                        "receipt_url": "https://example.com/receipts/4002",
                        "error_code": null,
                        "fiscal_document": {
                          "fiscal_drive_number": "9999078900000001",
                          "document_number": "102",
                          "fiscal_sign": "1234567890",
                          "registered_at": 1792577040
                        }
                      }
                    ]
                  }
                },
                {
                  "id": 3002,
                  "amount_minor": 50000,
                  "currency": "RUB",
                  "provider": "sberpay",
                  "environment": "production",
                  "is_paid": true,
                  "paid_at": 1791972300,
                  "status": "paid",
                  "issue": null,
                  "fulfillment_status": "done",
                  "external_id": "example-bank-order-3002",
                  "fiscalization": {
                    "enabled_for_order": false,
                    "mode": null,
                    "provider": null,
                    "environment": null,
                    "receipts": []
                  }
                }
              ]
            }
          ],
          "meta": {
            "has_more": false,
            "page": 1,
            "limit": 100,
            "generated_at": 1792577160
          }
        }
      },
      "ContractDetail": {
        "summary": "Контракт с авансовым и итоговым чеками",
        "value": {
          "data": {
            "id": 2001,
            "status": "closed",
            "starts_at": 1791972120,
            "ends_at": 1792576920,
            "activated_at": 1791972120,
            "is_delayed": false,
            "awaiting_conclusion": false,
            "concluded_at": 1792576980,
            "service_completed_at": 1792576980,
            "service_completed_by": {
              "type": "doctor",
              "id": 131
            },
            "clinic_id": 7,
            "number": "2026/2001",
            "created_at": 1791972120,
            "revision": 42,
            "updated_at": 1792577100,
            "consulting_order_id": 1001,
            "patient": {
              "id": 51,
              "name": "Иван Примеров",
              "email": "patient@example.com",
              "phone": null
            },
            "service": {
              "captured": true,
              "service_id": 12,
              "name": "Наблюдение в течение 7 дней",
              "duration_days": 7,
              "amount_minor": 150000,
              "currency": "RUB"
            },
            "main_doctor": {
              "id": 31,
              "name": "Анна Примерова"
            },
            "responsible_doctor": {
              "id": 31,
              "name": "Анна Примерова"
            },
            "contract_type": {
              "id": 9,
              "name": "Дистанционное наблюдение"
            },
            "is_eternal": false,
            "payments": [
              {
                "id": 3001,
                "amount_minor": 150000,
                "currency": "RUB",
                "provider": "sberpay",
                "environment": "production",
                "is_paid": true,
                "paid_at": 1791972060,
                "status": "paid",
                "issue": null,
                "fulfillment_status": "done",
                "external_id": "example-bank-order-3001",
                "fiscalization": {
                  "enabled_for_order": true,
                  "mode": "advance",
                  "provider": "ofd_ferma",
                  "environment": "production",
                  "receipts": [
                    {
                      "id": 4001,
                      "kind": "advance",
                      "status": "confirmed",
                      "external_id": "example-receipt-4001",
                      "receipt_url": "https://example.com/receipts/4001",
                      "error_code": null,
                      "fiscal_document": {
                        "fiscal_drive_number": "9999078900000001",
                        "document_number": "101",
                        "fiscal_sign": "1234567890",
                        "registered_at": 1791972090
                      }
                    },
                    {
                      "id": 4002,
                      "kind": "settlement",
                      "status": "confirmed",
                      "external_id": "example-receipt-4002",
                      "receipt_url": "https://example.com/receipts/4002",
                      "error_code": null,
                      "fiscal_document": {
                        "fiscal_drive_number": "9999078900000001",
                        "document_number": "102",
                        "fiscal_sign": "1234567890",
                        "registered_at": 1792577040
                      }
                    }
                  ]
                }
              },
              {
                "id": 3002,
                "amount_minor": 50000,
                "currency": "RUB",
                "provider": "sberpay",
                "environment": "production",
                "is_paid": true,
                "paid_at": 1791972300,
                "status": "paid",
                "issue": null,
                "fulfillment_status": "done",
                "external_id": "example-bank-order-3002",
                "fiscalization": {
                  "enabled_for_order": false,
                  "mode": null,
                  "provider": null,
                  "environment": null,
                  "receipts": []
                }
              }
            ]
          }
        }
      },
      "ContractWithoutPayments": {
        "summary": "Контракт без заявки и платежей ожидает активации",
        "value": {
          "data": {
            "id": 2002,
            "status": "waiting_activation",
            "starts_at": 1791972120,
            "ends_at": 1792576920,
            "activated_at": null,
            "is_delayed": true,
            "awaiting_conclusion": false,
            "concluded_at": null,
            "service_completed_at": null,
            "service_completed_by": null,
            "clinic_id": 7,
            "number": null,
            "created_at": 1791972120,
            "revision": 44,
            "updated_at": 1792577100,
            "consulting_order_id": null,
            "patient": null,
            "service": {
              "captured": true,
              "service_id": 12,
              "name": "Наблюдение в течение 7 дней",
              "duration_days": 7,
              "amount_minor": 150000,
              "currency": "RUB"
            },
            "main_doctor": null,
            "responsible_doctor": null,
            "contract_type": null,
            "is_eternal": false,
            "payments": []
          }
        }
      },
      "DeletedOrderList": {
        "summary": "Отметка об удалении заявки",
        "value": {
          "data": [
            {
              "id": 1003,
              "clinic_id": 7,
              "deleted": true,
              "revision": 47,
              "updated_at": 1792577160
            }
          ],
          "meta": {
            "has_more": false,
            "page": 1,
            "limit": 100,
            "generated_at": 1792577220
          }
        }
      },
      "DeletedContractList": {
        "summary": "Отметка об удалении контракта",
        "value": {
          "data": [
            {
              "id": 2003,
              "clinic_id": 7,
              "deleted": true,
              "revision": 47,
              "updated_at": 1792577100
            }
          ],
          "meta": {
            "has_more": false,
            "page": 1,
            "limit": 100,
            "generated_at": 1792577160
          }
        }
      },
      "EmptyList": {
        "summary": "Пустая страница",
        "value": {
          "data": [],
          "meta": {
            "has_more": false,
            "page": 1,
            "limit": 100,
            "generated_at": 1792577160
          }
        }
      },
      "Unauthorized": {
        "summary": "HTTP 401: unauthorized",
        "value": {
          "error": {
            "code": "unauthorized",
            "message": "Необходим действующий ключ API.",
            "details": {}
          }
        }
      },
      "ApiDisabled": {
        "summary": "HTTP 403: api_disabled",
        "value": {
          "error": {
            "code": "api_disabled",
            "message": "Доступ к API отключён.",
            "details": {}
          }
        }
      },
      "NotFound": {
        "summary": "HTTP 404: not_found",
        "value": {
          "error": {
            "code": "not_found",
            "message": "Запись не найдена.",
            "details": {}
          }
        }
      },
      "MethodNotAllowed": {
        "summary": "HTTP 405: method_not_allowed",
        "value": {
          "error": {
            "code": "method_not_allowed",
            "message": "Метод не поддерживается. API доступен только для чтения.",
            "details": {}
          }
        }
      },
      "InvalidParameters": {
        "summary": "HTTP 422: invalid_parameters",
        "value": {
          "error": {
            "code": "invalid_parameters",
            "message": "Некорректные параметры запроса.",
            "details": {}
          }
        }
      },
      "RateLimited": {
        "summary": "HTTP 429: rate_limited",
        "value": {
          "error": {
            "code": "rate_limited",
            "message": "Слишком много запросов. Повторите запрос позже.",
            "details": {}
          }
        }
      },
      "ExportPreparing": {
        "summary": "HTTP 503: export_preparing",
        "value": {
          "error": {
            "code": "export_preparing",
            "message": "Данные подготавливаются. Повторите запрос позже.",
            "details": {}
          }
        }
      },
      "InternalError": {
        "summary": "HTTP 500: internal_error",
        "value": {
          "error": {
            "code": "internal_error",
            "message": "Не удалось обработать запрос. Повторите его позже.",
            "details": {}
          }
        }
      },
      "InvalidLimit": {
        "summary": "Некорректный размер страницы",
        "value": {
          "error": {
            "code": "invalid_parameters",
            "message": "Некорректные параметры запроса.",
            "details": {
              "limit": [
                "Значение поля limit должно быть не больше 500."
              ]
            }
          }
        }
      },
      "FullReceiptOrder": {
        "summary": "Оплаченная заявка с чеком полного расчёта",
        "value": {
          "data": {
            "id": 1001,
            "clinic_id": 7,
            "created_at": 1791972000,
            "revision": 41,
            "updated_at": 1792577100,
            "status": "accepted",
            "reviewed_at": 1791972120,
            "service": {
              "captured": true,
              "service_id": 12,
              "name": "Наблюдение в течение 7 дней",
              "duration_days": 7,
              "amount_minor": 150000,
              "currency": "RUB"
            },
            "duration_days": 7,
            "doctor": {
              "id": 31,
              "name": "Анна Примерова"
            },
            "customer": {
              "name": "Иван Примеров",
              "email": "patient@example.com",
              "phone": null
            },
            "payment": {
              "id": 3001,
              "amount_minor": 150000,
              "currency": "RUB",
              "provider": "sberpay",
              "environment": "production",
              "is_paid": true,
              "paid_at": 1791972060,
              "status": "paid",
              "issue": null,
              "fulfillment_status": "done",
              "external_id": "example-bank-order-3001",
              "fiscalization": {
                "enabled_for_order": true,
                "mode": "on_contract",
                "provider": "ofd_ferma",
                "environment": "production",
                "receipts": [
                  {
                    "id": 4001,
                    "kind": "full",
                    "status": "confirmed",
                    "external_id": "example-receipt-4001",
                    "receipt_url": "https://example.com/receipts/4001",
                    "error_code": null,
                    "fiscal_document": {
                      "fiscal_drive_number": "9999078900000001",
                      "document_number": "101",
                      "fiscal_sign": "1234567890",
                      "registered_at": 1791972180
                    }
                  }
                ]
              }
            },
            "contract_id": 2001,
            "contract": {
              "id": 2001,
              "status": "closed",
              "starts_at": 1791972120,
              "ends_at": 1792576920,
              "activated_at": 1791972120,
              "is_delayed": false,
              "awaiting_conclusion": false,
              "concluded_at": 1792576980,
              "service_completed_at": 1792576980,
              "service_completed_by": {
                "type": "doctor",
                "id": 131
              }
            }
          }
        }
      },
      "FiscalizationRetryOrder": {
        "summary": "Временная ошибка отправки чека; результат ещё уточняется",
        "value": {
          "data": {
            "id": 1001,
            "clinic_id": 7,
            "created_at": 1791972000,
            "revision": 41,
            "updated_at": 1792577100,
            "status": "accepted",
            "reviewed_at": 1791972120,
            "service": {
              "captured": true,
              "service_id": 12,
              "name": "Наблюдение в течение 7 дней",
              "duration_days": 7,
              "amount_minor": 150000,
              "currency": "RUB"
            },
            "duration_days": 7,
            "doctor": {
              "id": 31,
              "name": "Анна Примерова"
            },
            "customer": {
              "name": "Иван Примеров",
              "email": "patient@example.com",
              "phone": null
            },
            "payment": {
              "id": 3001,
              "amount_minor": 150000,
              "currency": "RUB",
              "provider": "sberpay",
              "environment": "production",
              "is_paid": true,
              "paid_at": 1791972060,
              "status": "paid",
              "issue": null,
              "fulfillment_status": "done",
              "external_id": "example-bank-order-3001",
              "fiscalization": {
                "enabled_for_order": true,
                "mode": "advance",
                "provider": "ofd_ferma",
                "environment": "production",
                "receipts": [
                  {
                    "id": 4001,
                    "kind": "advance",
                    "status": "submitting",
                    "external_id": null,
                    "receipt_url": null,
                    "error_code": "transport_error",
                    "fiscal_document": {
                      "fiscal_drive_number": null,
                      "document_number": null,
                      "fiscal_sign": null,
                      "registered_at": null
                    }
                  }
                ]
              }
            },
            "contract_id": 2001,
            "contract": {
              "id": 2001,
              "status": "closed",
              "starts_at": 1791972120,
              "ends_at": 1792576920,
              "activated_at": 1791972120,
              "is_delayed": false,
              "awaiting_conclusion": false,
              "concluded_at": 1792576980,
              "service_completed_at": 1792576980,
              "service_completed_by": {
                "type": "doctor",
                "id": 131
              }
            }
          }
        }
      },
      "OrderFirstPage": {
        "summary": "Первая страница: сохранить generated_at",
        "value": {
          "data": [
            {
              "id": 1001,
              "clinic_id": 7,
              "created_at": 1791972000,
              "revision": 41,
              "updated_at": 1792577100,
              "status": "accepted",
              "reviewed_at": 1791972120,
              "service": {
                "captured": true,
                "service_id": 12,
                "name": "Наблюдение в течение 7 дней",
                "duration_days": 7,
                "amount_minor": 150000,
                "currency": "RUB"
              },
              "duration_days": 7,
              "doctor": {
                "id": 31,
                "name": "Анна Примерова"
              },
              "customer": {
                "name": "Иван Примеров",
                "email": "patient@example.com",
                "phone": null
              },
              "payment": {
                "id": 3001,
                "amount_minor": 150000,
                "currency": "RUB",
                "provider": "sberpay",
                "environment": "production",
                "is_paid": true,
                "paid_at": 1791972060,
                "status": "paid",
                "issue": null,
                "fulfillment_status": "done",
                "external_id": "example-bank-order-3001",
                "fiscalization": {
                  "enabled_for_order": true,
                  "mode": "advance",
                  "provider": "ofd_ferma",
                  "environment": "production",
                  "receipts": [
                    {
                      "id": 4001,
                      "kind": "advance",
                      "status": "confirmed",
                      "external_id": "example-receipt-4001",
                      "receipt_url": "https://example.com/receipts/4001",
                      "error_code": null,
                      "fiscal_document": {
                        "fiscal_drive_number": "9999078900000001",
                        "document_number": "101",
                        "fiscal_sign": "1234567890",
                        "registered_at": 1791972090
                      }
                    },
                    {
                      "id": 4002,
                      "kind": "settlement",
                      "status": "confirmed",
                      "external_id": "example-receipt-4002",
                      "receipt_url": "https://example.com/receipts/4002",
                      "error_code": null,
                      "fiscal_document": {
                        "fiscal_drive_number": "9999078900000001",
                        "document_number": "102",
                        "fiscal_sign": "1234567890",
                        "registered_at": 1792577040
                      }
                    }
                  ]
                }
              },
              "contract_id": 2001,
              "contract": {
                "id": 2001,
                "status": "closed",
                "starts_at": 1791972120,
                "ends_at": 1792576920,
                "activated_at": 1791972120,
                "is_delayed": false,
                "awaiting_conclusion": false,
                "concluded_at": 1792576980,
                "service_completed_at": 1792576980,
                "service_completed_by": {
                  "type": "doctor",
                  "id": 131
                }
              }
            }
          ],
          "meta": {
            "has_more": true,
            "page": 1,
            "limit": 1,
            "generated_at": 1792577160
          }
        }
      },
      "OrderSecondPage": {
        "summary": "Следующая страница: не заменять сохранённую границу её временем",
        "value": {
          "data": [
            {
              "id": 1002,
              "clinic_id": 7,
              "created_at": 1791972000,
              "revision": 43,
              "updated_at": 1792577100,
              "status": "created",
              "reviewed_at": null,
              "service": {
                "captured": false,
                "service_id": null,
                "name": null,
                "duration_days": 7,
                "amount_minor": null,
                "currency": "RUB"
              },
              "duration_days": 7,
              "doctor": {
                "id": 31,
                "name": "Анна Примерова"
              },
              "customer": {
                "name": "Иван Примеров",
                "email": "patient@example.com",
                "phone": null
              },
              "payment": null,
              "contract_id": null,
              "contract": null
            }
          ],
          "meta": {
            "has_more": false,
            "page": 2,
            "limit": 1,
            "generated_at": 1792577220
          }
        }
      }
    }
  },
  "externalDocs": {
    "description": "Russian integration guide with field reference and synchronization algorithm",
    "url": "https://docs.medsenger.ru/ru/registrar/settings/accounting-api"
  }
}
