{
  "components": {
    "schemas": {
      "ActiveMeterResponse": {
        "properties": {
          "balance": {
            "example": 111111,
            "type": "number"
          },
          "consumed_units": {
            "example": 0,
            "type": "number"
          },
          "credited_units": {
            "example": 111111,
            "type": "number"
          },
          "id": {
            "example": "089ca13b-ea12-48a2-89de-eebea2d43ef5",
            "type": "string"
          },
          "meter_id": {
            "example": "9c3cd7d2-2f1e-4a32-910d-17b55fe4a6f2",
            "type": "string"
          },
          "meter_name": {
            "example": "OCR Credits",
            "type": "string"
          }
        },
        "type": "object"
      },
      "ActiveSubscriptionResponse": {
        "properties": {
          "discount_id": {
            "type": "string"
          },
          "ends_at": {
            "example": "2025-11-06T17:24:23.883522Z",
            "type": "string"
          },
          "id": {
            "example": "8ce40958-f3a0-4b5d-98b6-aa283ebf91e7",
            "type": "string"
          },
          "metadata": {
            "additionalProperties": {},
            "type": "object"
          },
          "meters": {
            "items": {},
            "type": "array",
            "uniqueItems": false
          },
          "price_id": {
            "example": "4fd5d081-732c-4f7e-bfbf-54c1e17ea622",
            "type": "string"
          },
          "product_id": {
            "example": "e1ae6cb1-547b-4c0e-a530-92a2e5b09d77",
            "type": "string"
          },
          "product_name": {
            "example": "Growth Plan",
            "type": "string"
          },
          "started_at": {
            "example": "2025-10-06T17:24:23.883522Z",
            "type": "string"
          }
        },
        "type": "object"
      },
      "CreditBalanceResponse": {
        "properties": {
          "active_meters": {
            "items": {
              "$ref": "#/components/schemas/ActiveMeterResponse"
            },
            "type": "array",
            "uniqueItems": false
          },
          "active_subscriptions": {
            "items": {
              "$ref": "#/components/schemas/ActiveSubscriptionResponse"
            },
            "type": "array",
            "uniqueItems": false
          },
          "credits_consumed": {
            "example": 125,
            "type": "integer"
          },
          "credits_granted": {
            "example": 500,
            "type": "integer"
          },
          "credits_remaining": {
            "example": 375,
            "type": "integer"
          },
          "granted_benefits": {
            "items": {
              "$ref": "#/components/schemas/GrantedBenefitResponse"
            },
            "type": "array",
            "uniqueItems": false
          },
          "plan_name": {
            "example": "Free",
            "type": "string"
          },
          "team_id": {
            "example": "550e8400-e29b-41d4-a716-446655440000",
            "type": "string"
          },
          "trial_active": {
            "example": true,
            "type": "boolean"
          },
          "trial_credits_granted": {
            "example": 100,
            "type": "integer"
          },
          "trial_credits_remaining": {
            "example": 50,
            "type": "integer"
          },
          "trial_days_remaining": {
            "example": 14,
            "type": "integer"
          },
          "trial_ends_at": {
            "example": "2025-03-03T13:37:00Z",
            "type": "string"
          }
        },
        "type": "object"
      },
      "GrantedBenefitResponse": {
        "properties": {
          "benefit_id": {
            "example": "a5d7da4a-5c80-4c51-a6bc-d7118b03f27e",
            "type": "string"
          },
          "benefit_metadata": {
            "additionalProperties": {},
            "type": "object"
          },
          "benefit_type": {
            "example": "meter_credit",
            "type": "string"
          },
          "granted_at": {
            "example": "2025-10-06T17:24:25.620964Z",
            "type": "string"
          },
          "id": {
            "example": "2e2b4669-dcfc-44dd-9845-6f306f978abf",
            "type": "string"
          },
          "properties": {
            "additionalProperties": {},
            "type": "object"
          }
        },
        "type": "object"
      },
      "ProductCatalog": {
        "properties": {
          "credit_packs": {
            "items": {
              "$ref": "#/components/schemas/credits.CatalogProduct"
            },
            "type": "array",
            "uniqueItems": false
          },
          "subscriptions": {
            "items": {
              "$ref": "#/components/schemas/credits.CatalogProduct"
            },
            "type": "array",
            "uniqueItems": false
          }
        },
        "type": "object"
      },
      "analytics.ConfidenceDistribution": {
        "properties": {
          "high": {
            "description": "0.7-0.9",
            "type": "integer"
          },
          "low": {
            "description": "0-0.5",
            "type": "integer"
          },
          "medium": {
            "description": "0.5-0.7",
            "type": "integer"
          },
          "very_high": {
            "description": "0.9-1.0",
            "type": "integer"
          }
        },
        "type": "object"
      },
      "analytics.ConfidenceMetricsResponse": {
        "properties": {
          "distribution": {
            "$ref": "#/components/schemas/analytics.ConfidenceDistribution"
          },
          "range": {
            "$ref": "#/components/schemas/analytics.Range"
          },
          "summary": {
            "$ref": "#/components/schemas/analytics.ConfidenceSummary"
          }
        },
        "type": "object"
      },
      "analytics.ConfidenceSummary": {
        "properties": {
          "avg_confidence": {
            "type": "number"
          },
          "max_confidence": {
            "type": "number"
          },
          "min_confidence": {
            "type": "number"
          },
          "total_pages": {
            "type": "integer"
          },
          "unscored_count": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "analytics.ConfidenceTimeseriesPoint": {
        "properties": {
          "avg_confidence": {
            "type": "number"
          },
          "bucket": {
            "type": "string"
          },
          "high_confidence_count": {
            "type": "integer"
          },
          "low_confidence_count": {
            "type": "integer"
          },
          "total_pages": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "analytics.ConfidenceTimeseriesResponse": {
        "properties": {
          "range": {
            "$ref": "#/components/schemas/analytics.Range"
          },
          "timeseries": {
            "items": {
              "$ref": "#/components/schemas/analytics.ConfidenceTimeseriesPoint"
            },
            "type": "array",
            "uniqueItems": false
          }
        },
        "type": "object"
      },
      "analytics.CreditsOverview": {
        "properties": {
          "adjusted": {
            "type": "integer"
          },
          "balance": {
            "type": "integer"
          },
          "consumed": {
            "type": "integer"
          },
          "granted": {
            "type": "integer"
          },
          "net": {
            "type": "integer"
          },
          "refunded": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "analytics.CreditsTimeseriesPoint": {
        "properties": {
          "adjusted": {
            "type": "integer"
          },
          "bucket": {
            "type": "string"
          },
          "consumed": {
            "type": "integer"
          },
          "granted": {
            "type": "integer"
          },
          "net_change": {
            "type": "integer"
          },
          "refunded": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "analytics.CreditsUsageResponse": {
        "properties": {
          "model_breakdown": {
            "items": {
              "$ref": "#/components/schemas/analytics.ModelUsageStat"
            },
            "type": "array",
            "uniqueItems": false
          },
          "range": {
            "$ref": "#/components/schemas/analytics.Range"
          },
          "snapshot": {
            "$ref": "#/components/schemas/analytics.CreditsOverview"
          },
          "timeseries": {
            "items": {
              "$ref": "#/components/schemas/analytics.CreditsTimeseriesPoint"
            },
            "type": "array",
            "uniqueItems": false
          }
        },
        "type": "object"
      },
      "analytics.DocumentDistribution": {
        "properties": {
          "large_docs": {
            "description": "21-100 pages",
            "type": "integer"
          },
          "medium_docs": {
            "description": "6-20 pages",
            "type": "integer"
          },
          "small_docs": {
            "description": "1-5 pages",
            "type": "integer"
          },
          "very_large_docs": {
            "description": "100+ pages",
            "type": "integer"
          }
        },
        "type": "object"
      },
      "analytics.DocumentStatsResponse": {
        "properties": {
          "distribution": {
            "$ref": "#/components/schemas/analytics.DocumentDistribution"
          },
          "range": {
            "$ref": "#/components/schemas/analytics.Range"
          },
          "summary": {
            "$ref": "#/components/schemas/analytics.DocumentSummary"
          }
        },
        "type": "object"
      },
      "analytics.DocumentSummary": {
        "properties": {
          "avg_file_size": {
            "type": "number"
          },
          "avg_pages_per_doc": {
            "type": "number"
          },
          "max_file_size": {
            "type": "integer"
          },
          "min_file_size": {
            "type": "integer"
          },
          "total_documents": {
            "type": "integer"
          },
          "total_file_size": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "analytics.ErrorAnalysisResponse": {
        "properties": {
          "patterns": {
            "items": {
              "$ref": "#/components/schemas/analytics.ErrorPattern"
            },
            "type": "array",
            "uniqueItems": false
          },
          "range": {
            "$ref": "#/components/schemas/analytics.Range"
          },
          "summary": {
            "$ref": "#/components/schemas/analytics.ErrorSummary"
          }
        },
        "type": "object"
      },
      "analytics.ErrorPattern": {
        "properties": {
          "category": {
            "type": "string"
          },
          "count": {
            "type": "integer"
          },
          "percentage": {
            "type": "number"
          }
        },
        "type": "object"
      },
      "analytics.ErrorSummary": {
        "properties": {
          "completed_jobs": {
            "type": "integer"
          },
          "failed_jobs": {
            "type": "integer"
          },
          "failure_rate_percent": {
            "type": "number"
          },
          "jobs_with_errors": {
            "type": "integer"
          },
          "total_jobs": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "analytics.ErrorTimeseriesPoint": {
        "properties": {
          "bucket": {
            "type": "string"
          },
          "completed_jobs": {
            "type": "integer"
          },
          "failed_jobs": {
            "type": "integer"
          },
          "failure_rate": {
            "type": "number"
          },
          "total_jobs": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "analytics.ErrorTimeseriesResponse": {
        "properties": {
          "range": {
            "$ref": "#/components/schemas/analytics.Range"
          },
          "timeseries": {
            "items": {
              "$ref": "#/components/schemas/analytics.ErrorTimeseriesPoint"
            },
            "type": "array",
            "uniqueItems": false
          }
        },
        "type": "object"
      },
      "analytics.FileTypeBreakdownResponse": {
        "properties": {
          "file_types": {
            "items": {
              "$ref": "#/components/schemas/analytics.FileTypeStats"
            },
            "type": "array",
            "uniqueItems": false
          },
          "range": {
            "$ref": "#/components/schemas/analytics.Range"
          }
        },
        "type": "object"
      },
      "analytics.FileTypeStats": {
        "properties": {
          "document_count": {
            "type": "integer"
          },
          "extension": {
            "type": "string"
          },
          "total_pages": {
            "type": "integer"
          },
          "total_size": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "analytics.JobOverview": {
        "properties": {
          "active_jobs": {
            "type": "integer"
          },
          "avg_active_seconds": {
            "type": "number"
          },
          "avg_completion_seconds": {
            "type": "number"
          },
          "cancelled_jobs": {
            "type": "integer"
          },
          "completed_jobs": {
            "type": "integer"
          },
          "credits_consumed": {
            "type": "integer"
          },
          "failed_jobs": {
            "type": "integer"
          },
          "processed_pages": {
            "type": "integer"
          },
          "success_rate": {
            "type": "number"
          },
          "throughput_jobs_per_second": {
            "type": "number"
          },
          "total_jobs": {
            "type": "integer"
          },
          "total_pages": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "analytics.JobTimeseriesPoint": {
        "properties": {
          "active_jobs": {
            "type": "integer"
          },
          "avg_completion_seconds": {
            "type": "number"
          },
          "bucket": {
            "type": "string"
          },
          "completed_jobs": {
            "type": "integer"
          },
          "credits_consumed": {
            "type": "integer"
          },
          "failed_jobs": {
            "type": "integer"
          },
          "processed_pages": {
            "type": "integer"
          },
          "total_jobs": {
            "type": "integer"
          },
          "total_pages": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "analytics.ModelUsageStat": {
        "properties": {
          "credits_consumed": {
            "type": "integer"
          },
          "jobs_processed": {
            "type": "integer"
          },
          "model": {
            "type": "string"
          },
          "transactions": {
            "type": "integer"
          },
          "user_id": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "analytics.OverviewResponse": {
        "properties": {
          "credits": {
            "$ref": "#/components/schemas/analytics.CreditsOverview"
          },
          "jobs": {
            "$ref": "#/components/schemas/analytics.JobOverview"
          },
          "pages": {
            "$ref": "#/components/schemas/analytics.PageOverview"
          },
          "range": {
            "$ref": "#/components/schemas/analytics.Range"
          },
          "webhooks": {
            "$ref": "#/components/schemas/analytics.WebhookSummary"
          }
        },
        "type": "object"
      },
      "analytics.PageOverview": {
        "properties": {
          "completed_pages": {
            "type": "integer"
          },
          "empty_pages": {
            "type": "integer"
          },
          "failed_pages": {
            "type": "integer"
          },
          "hard_failure_pages": {
            "type": "integer"
          },
          "total_pages": {
            "type": "integer"
          },
          "total_tokens": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "analytics.PageTimeseriesPoint": {
        "properties": {
          "bucket": {
            "type": "string"
          },
          "completed_pages": {
            "type": "integer"
          },
          "empty_pages": {
            "type": "integer"
          },
          "failed_pages": {
            "type": "integer"
          },
          "hard_failure_pages": {
            "type": "integer"
          },
          "total_pages": {
            "type": "integer"
          },
          "total_tokens": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "analytics.PeriodComparisonResponse": {
        "properties": {
          "credits_used": {
            "$ref": "#/components/schemas/analytics.PeriodDelta"
          },
          "current_range": {
            "$ref": "#/components/schemas/analytics.Range"
          },
          "failure_rate": {
            "$ref": "#/components/schemas/analytics.PeriodDelta"
          },
          "jobs": {
            "$ref": "#/components/schemas/analytics.PeriodDelta"
          },
          "pages": {
            "$ref": "#/components/schemas/analytics.PeriodDelta"
          },
          "previous_range": {
            "$ref": "#/components/schemas/analytics.Range"
          }
        },
        "type": "object"
      },
      "analytics.PeriodDelta": {
        "properties": {
          "change": {
            "type": "integer"
          },
          "change_rate": {
            "description": "percentage",
            "type": "number"
          },
          "current": {
            "type": "integer"
          },
          "previous": {
            "type": "integer"
          },
          "trend": {
            "description": "\"up\", \"down\", \"stable\"",
            "type": "string"
          }
        },
        "type": "object"
      },
      "analytics.Range": {
        "properties": {
          "bucket": {
            "type": "string"
          },
          "end": {
            "type": "string"
          },
          "requested_range": {
            "type": "string"
          },
          "start": {
            "type": "string"
          },
          "team_id": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "analytics.TemplateStat": {
        "properties": {
          "credits_consumed": {
            "type": "integer"
          },
          "id": {
            "type": "string"
          },
          "job_count": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "total_pages": {
            "type": "integer"
          },
          "usage_count": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "analytics.TopTemplatesResponse": {
        "properties": {
          "range": {
            "$ref": "#/components/schemas/analytics.Range"
          },
          "templates": {
            "items": {
              "$ref": "#/components/schemas/analytics.TemplateStat"
            },
            "type": "array",
            "uniqueItems": false
          }
        },
        "type": "object"
      },
      "analytics.TopUserStats": {
        "properties": {
          "completed_jobs": {
            "type": "integer"
          },
          "credits_consumed": {
            "type": "integer"
          },
          "failed_jobs": {
            "type": "integer"
          },
          "job_count": {
            "type": "integer"
          },
          "success_rate": {
            "type": "number"
          },
          "total_pages": {
            "type": "integer"
          },
          "user_id": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "analytics.TopUsersResponse": {
        "properties": {
          "range": {
            "$ref": "#/components/schemas/analytics.Range"
          },
          "users": {
            "items": {
              "$ref": "#/components/schemas/analytics.TopUserStats"
            },
            "type": "array",
            "uniqueItems": false
          }
        },
        "type": "object"
      },
      "analytics.UserActivityResponse": {
        "properties": {
          "range": {
            "$ref": "#/components/schemas/analytics.Range"
          },
          "users": {
            "items": {
              "$ref": "#/components/schemas/analytics.UserStats"
            },
            "type": "array",
            "uniqueItems": false
          }
        },
        "type": "object"
      },
      "analytics.UserStats": {
        "properties": {
          "active_days": {
            "type": "integer"
          },
          "credits_consumed": {
            "type": "integer"
          },
          "first_activity": {
            "type": "string"
          },
          "job_count": {
            "type": "integer"
          },
          "last_activity": {
            "type": "string"
          },
          "total_pages": {
            "type": "integer"
          },
          "user_id": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "analytics.WebhookSummary": {
        "properties": {
          "avg_processing_seconds": {
            "type": "number"
          },
          "failed_events": {
            "type": "integer"
          },
          "pending_events": {
            "type": "integer"
          },
          "processed_events": {
            "type": "integer"
          },
          "success_rate": {
            "type": "number"
          },
          "total_events": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "auth.AuthResponse": {
        "properties": {
          "message": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "user": {}
        },
        "type": "object"
      },
      "credits.CatalogBenefit": {
        "properties": {
          "description": {
            "type": "string"
          },
          "units": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "credits.CatalogPrice": {
        "properties": {
          "amount": {
            "type": "integer"
          },
          "currency": {
            "type": "string"
          },
          "formatted": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "credits.CatalogProduct": {
        "properties": {
          "benefits": {
            "items": {
              "$ref": "#/components/schemas/credits.CatalogBenefit"
            },
            "type": "array",
            "uniqueItems": false
          },
          "billing_interval": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "price": {
            "$ref": "#/components/schemas/credits.CatalogPrice"
          },
          "type": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "credits.CreditTransactionOrganizationResponse": {
        "properties": {
          "amount": {
            "example": 50,
            "type": "integer"
          },
          "balance_after": {
            "example": 950,
            "type": "integer"
          },
          "created_at": {
            "example": "2024-01-15T10:30:00Z",
            "type": "string"
          },
          "description": {
            "example": "OCR processing for document.pdf",
            "type": "string"
          },
          "expires_at": {
            "example": "2024-12-31T23:59:59Z",
            "type": "string"
          },
          "id": {
            "example": "550e8400-e29b-41d4-a716-446655440000",
            "type": "string"
          },
          "idempotency_key": {
            "example": "job_550e8400-e29b-41d4-a716-446655440000_consumed",
            "type": "string"
          },
          "job_id": {
            "example": "550e8400-e29b-41d4-a716-446655440000",
            "type": "string"
          },
          "metadata": {
            "type": "object"
          },
          "organization_id": {
            "example": "550e8400-e29b-41d4-a716-446655440000",
            "type": "string"
          },
          "transaction_type": {
            "enum": [
              "credit",
              "consumed",
              "refunded",
              "adjustment",
              "expiration"
            ],
            "example": "consumed",
            "type": "string"
          }
        },
        "type": "object"
      },
      "credits.CreditTransactionProjectResponse": {
        "properties": {
          "amount": {
            "example": 50,
            "type": "integer"
          },
          "balance_after": {
            "example": 950,
            "type": "integer"
          },
          "created_at": {
            "example": "2024-01-15T10:30:00Z",
            "type": "string"
          },
          "description": {
            "example": "OCR processing for document.pdf",
            "type": "string"
          },
          "expires_at": {
            "example": "2024-12-31T23:59:59Z",
            "type": "string"
          },
          "id": {
            "example": "550e8400-e29b-41d4-a716-446655440000",
            "type": "string"
          },
          "idempotency_key": {
            "example": "job_550e8400-e29b-41d4-a716-446655440000_consumed",
            "type": "string"
          },
          "job_id": {
            "example": "550e8400-e29b-41d4-a716-446655440000",
            "type": "string"
          },
          "metadata": {
            "type": "object"
          },
          "project_id": {
            "example": "550e8400-e29b-41d4-a716-446655440000",
            "type": "string"
          },
          "transaction_type": {
            "enum": [
              "credit",
              "consumed",
              "refunded",
              "adjustment",
              "expiration"
            ],
            "example": "consumed",
            "type": "string"
          }
        },
        "type": "object"
      },
      "credits.CreditTransactionsListCursorResponse": {
        "properties": {
          "data": {
            "items": {
              "$ref": "#/components/schemas/credits.CreditTransactionProjectResponse"
            },
            "type": "array",
            "uniqueItems": false
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "type": "string"
          },
          "total_count": {
            "type": "integer"
          },
          "total_pages": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "credits.OrgCreditTransactionsListCursorResponse": {
        "properties": {
          "data": {
            "items": {
              "$ref": "#/components/schemas/credits.CreditTransactionOrganizationResponse"
            },
            "type": "array",
            "uniqueItems": false
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "type": "string"
          },
          "total_count": {
            "type": "integer"
          },
          "total_pages": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "events.WebhookEventPayloadResponse": {
        "properties": {
          "enriched": {
            "description": "Whether payload was enriched with current data",
            "type": "boolean"
          },
          "event_id": {
            "type": "string"
          },
          "event_type": {
            "type": "string"
          },
          "note": {
            "description": "Optional note about enrichment status",
            "type": "string"
          },
          "payload": {
            "additionalProperties": {},
            "type": "object"
          }
        },
        "type": "object"
      },
      "events.WebhookEventResponse": {
        "properties": {
          "created_at": {
            "type": "string"
          },
          "event_id": {
            "type": "string"
          },
          "event_type": {
            "type": "string"
          },
          "http_status": {
            "type": "integer"
          },
          "id": {
            "type": "string"
          },
          "payload": {
            "additionalProperties": {},
            "type": "object"
          },
          "processing_attempts": {
            "type": "integer"
          },
          "processing_error": {
            "type": "string"
          },
          "processing_status": {
            "type": "string"
          },
          "updated_at": {
            "type": "string"
          },
          "webhook_url": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "events.WebhookEventsListCursorResponse": {
        "properties": {
          "data": {
            "items": {
              "$ref": "#/components/schemas/events.WebhookEventResponse"
            },
            "type": "array",
            "uniqueItems": false
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "type": "string"
          },
          "total_count": {
            "type": "integer"
          },
          "total_pages": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "health.HealthCheck": {
        "properties": {
          "details": {
            "description": "Additional health check details",
            "type": "object"
          },
          "message": {
            "example": "Database connection successful",
            "type": "string"
          },
          "response_time": {
            "example": "5ms",
            "type": "string"
          },
          "status": {
            "example": "healthy",
            "type": "string"
          }
        },
        "type": "object"
      },
      "health.HealthStatus": {
        "properties": {
          "checks": {
            "additionalProperties": {
              "$ref": "#/components/schemas/health.HealthCheck"
            },
            "type": "object"
          },
          "service": {
            "example": "api",
            "type": "string"
          },
          "status": {
            "example": "healthy",
            "type": "string"
          },
          "summary": {
            "$ref": "#/components/schemas/health.HealthSummary"
          },
          "timestamp": {
            "example": "2023-12-25T10:30:00Z",
            "format": "date-time",
            "type": "string"
          },
          "version": {
            "example": "1.0.0",
            "type": "string"
          }
        },
        "type": "object"
      },
      "health.HealthSummary": {
        "properties": {
          "degraded": {
            "example": 1,
            "minimum": 0,
            "type": "integer"
          },
          "down": {
            "example": 0,
            "minimum": 0,
            "type": "integer"
          },
          "healthy": {
            "example": 2,
            "minimum": 0,
            "type": "integer"
          },
          "total": {
            "example": 3,
            "minimum": 0,
            "type": "integer"
          }
        },
        "type": "object"
      },
      "jobs.JobListItem": {
        "properties": {
          "base_credits": {
            "type": "integer"
          },
          "category": {
            "type": "string"
          },
          "completed_at": {
            "type": "string"
          },
          "confidence": {
            "description": "Average confidence score across all pages (0.0-1.0)",
            "type": "number"
          },
          "created_at": {
            "type": "string"
          },
          "credits_used": {
            "type": "integer"
          },
          "deleted_at": {
            "type": "string"
          },
          "duration_seconds": {
            "type": "number"
          },
          "file_name": {
            "type": "string"
          },
          "id": {
            "type": "string"
          },
          "is_deleted": {
            "description": "Computed field for API convenience: true if DeletedAt != nil",
            "type": "boolean"
          },
          "model": {
            "type": "string"
          },
          "processed_pages": {
            "type": "integer"
          },
          "processing_time": {
            "type": "number"
          },
          "result_format": {
            "type": "string"
          },
          "stage": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "surcharge_credits": {
            "type": "integer"
          },
          "template_id": {
            "type": "string"
          },
          "template_internal": {
            "type": "boolean"
          },
          "template_name": {
            "type": "string"
          },
          "total_pages": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "jobs.JobManagementResponse": {
        "properties": {
          "action": {
            "example": "retry",
            "type": "string"
          },
          "job": {
            "$ref": "#/components/schemas/jobs.JobResponse"
          },
          "message": {
            "example": "Job retry initiated successfully",
            "type": "string"
          },
          "success": {
            "example": true,
            "type": "boolean"
          }
        },
        "type": "object"
      },
      "jobs.JobResponse": {
        "properties": {
          "completed_at": {
            "type": "string"
          },
          "created_at": {
            "type": "string"
          },
          "credits_used": {
            "type": "integer"
          },
          "deleted_at": {
            "type": "string"
          },
          "error_message": {
            "type": "string"
          },
          "file_name": {
            "type": "string"
          },
          "file_size": {
            "type": "integer"
          },
          "id": {
            "type": "string"
          },
          "metadata": {
            "additionalProperties": {},
            "type": "object"
          },
          "processed_pages": {
            "type": "integer"
          },
          "status": {
            "type": "string"
          },
          "team_id": {
            "type": "string"
          },
          "template_id": {
            "type": "string"
          },
          "template_internal": {
            "type": "boolean"
          },
          "template_name": {
            "type": "string"
          },
          "total_pages": {
            "type": "integer"
          },
          "updated_at": {
            "type": "string"
          },
          "user_id": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "jobs.JobStatusResponse": {
        "properties": {
          "estimated_stuck": {
            "example": false,
            "type": "boolean"
          },
          "is_retryable": {
            "example": true,
            "type": "boolean"
          },
          "job": {
            "$ref": "#/components/schemas/jobs.JobResponse"
          },
          "last_activity": {
            "format": "date-time",
            "type": "string"
          },
          "workflow_status": {
            "$ref": "#/components/schemas/jobs.WorkflowStatusInfo"
          }
        },
        "type": "object"
      },
      "jobs.JobsListCursorResponse": {
        "properties": {
          "data": {
            "items": {
              "$ref": "#/components/schemas/jobs.JobListItem"
            },
            "type": "array",
            "uniqueItems": false
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "type": "string"
          },
          "total_count": {
            "type": "integer"
          },
          "total_pages": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "jobs.WorkflowJobStatusInfo": {
        "properties": {
          "job_id": {
            "type": "string"
          },
          "progress": {
            "$ref": "#/components/schemas/jobs.WorkflowProgressInfo"
          },
          "status": {
            "example": "page_processing",
            "type": "string"
          }
        },
        "type": "object"
      },
      "jobs.WorkflowProgressInfo": {
        "properties": {
          "job_id": {
            "type": "string"
          },
          "message": {
            "example": "Processing page 5 of 10",
            "type": "string"
          },
          "percentage": {
            "example": 50,
            "maximum": 100,
            "minimum": 0,
            "type": "integer"
          },
          "stage": {
            "example": "page_processing",
            "type": "string"
          },
          "timestamp": {
            "format": "date-time",
            "type": "string"
          }
        },
        "type": "object"
      },
      "jobs.WorkflowStatusInfo": {
        "properties": {
          "close_time": {
            "format": "date-time",
            "type": "string"
          },
          "error": {
            "type": "string"
          },
          "job_status": {
            "$ref": "#/components/schemas/jobs.WorkflowJobStatusInfo"
          },
          "progress": {
            "$ref": "#/components/schemas/jobs.WorkflowProgressInfo"
          },
          "run_id": {
            "example": "abc123-def456-ghi789",
            "type": "string"
          },
          "start_time": {
            "format": "date-time",
            "type": "string"
          },
          "status": {
            "enum": [
              "RUNNING",
              "COMPLETED",
              "FAILED",
              "CANCELED",
              "TERMINATED",
              "CONTINUED_AS_NEW",
              "TIMED_OUT"
            ],
            "example": "RUNNING",
            "type": "string"
          },
          "workflow_id": {
            "example": "ocr-job-123e4567-e89b-12d3-a456-426614174000",
            "type": "string"
          }
        },
        "type": "object"
      },
      "models.BoundingBox": {
        "properties": {
          "bounds": {
            "$ref": "#/components/schemas/models.BoxBounds"
          },
          "metadata": {
            "description": "Optional metadata (e.g., heading level, table structure)"
          },
          "text": {
            "description": "Text content of the block",
            "type": "string"
          },
          "type": {
            "description": "Block type: paragraph, heading, table, figure, caption, list, footer, header",
            "type": "string"
          }
        },
        "type": "object"
      },
      "models.BoxBounds": {
        "description": "Bounding box coordinates in pixels",
        "properties": {
          "height": {
            "description": "Height in pixels",
            "type": "integer"
          },
          "width": {
            "description": "Width in pixels",
            "type": "integer"
          },
          "x": {
            "description": "Left edge X coordinate",
            "type": "integer"
          },
          "y": {
            "description": "Top edge Y coordinate",
            "type": "integer"
          }
        },
        "type": "object"
      },
      "models.JobStatus": {
        "description": "The current status of the job\nexample: completed",
        "enum": [
          "pending",
          "processing",
          "completed",
          "partially_done",
          "failed"
        ],
        "example": "pending",
        "type": "string",
        "x-enum-varnames": [
          "JobStatusPending",
          "JobStatusProcessing",
          "JobStatusCompleted",
          "JobStatusPartiallyDone",
          "JobStatusFailed"
        ]
      },
      "models.OCRResultResponse": {
        "properties": {
          "completed_at": {
            "type": "string"
          },
          "credits_used": {
            "type": "integer"
          },
          "file_name": {
            "type": "string"
          },
          "job_id": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "pages": {
            "items": {
              "$ref": "#/components/schemas/models.PageResponse"
            },
            "type": "array",
            "uniqueItems": false
          },
          "pagination": {
            "$ref": "#/components/schemas/models.PaginationResponse"
          },
          "processed_pages": {
            "type": "integer"
          },
          "result_format": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/models.JobStatus"
          },
          "total_pages": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "models.OCRStatusResponse": {
        "properties": {
          "completed_at": {
            "type": "string"
          },
          "error_message": {
            "type": "string"
          },
          "job_id": {
            "type": "string"
          },
          "processed_pages": {
            "type": "integer"
          },
          "result_format": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/models.JobStatus"
          },
          "total_pages": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "models.PageDims": {
        "description": "Page dimensions in pixels. Present when available.",
        "properties": {
          "height": {
            "type": "integer"
          },
          "width": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "models.PageResponse": {
        "properties": {
          "bounding_boxes": {
            "description": "Semantic blocks with locations. Automatically included when available.",
            "items": {
              "$ref": "#/components/schemas/models.BoundingBox"
            },
            "type": "array",
            "uniqueItems": false
          },
          "confidence": {
            "description": "Confidence score from quality check (0.0-1.0). Present when quality assessment is enabled.",
            "type": "number"
          },
          "dimensions": {
            "$ref": "#/components/schemas/models.PageDims"
          },
          "has_bounding_boxes": {
            "description": "Whether bounding box data is available. True if bbox extraction was performed.",
            "type": "boolean"
          },
          "id": {
            "type": "string"
          },
          "page_number": {
            "type": "integer"
          },
          "result": {
            "description": "String for markdown, Object for structured formats. Type varies by job result_format."
          }
        },
        "type": "object"
      },
      "models.PaginationResponse": {
        "properties": {
          "limit": {
            "type": "integer"
          },
          "page": {
            "type": "integer"
          },
          "total": {
            "type": "integer"
          },
          "total_pages": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "models_list.ModelResponse": {
        "properties": {
          "credits_per_page": {
            "type": "integer"
          },
          "description": {
            "type": "string"
          },
          "display_name": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "priority": {
            "type": "integer"
          },
          "surcharge_per_page": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "models_list.ModelsListResponse": {
        "properties": {
          "count": {
            "type": "integer"
          },
          "models": {
            "items": {
              "$ref": "#/components/schemas/models_list.ModelResponse"
            },
            "type": "array",
            "uniqueItems": false
          }
        },
        "type": "object"
      },
      "onboarding.CreateOnboardingRequest": {
        "properties": {
          "entity_type": {
            "type": "string"
          },
          "external_id": {
            "type": "string"
          },
          "metadata": {},
          "steps_completed": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "uniqueItems": false
          }
        },
        "type": "object"
      },
      "onboarding.OnboardingStatus": {
        "properties": {
          "completed_at": {
            "type": "string"
          },
          "created_at": {
            "type": "string"
          },
          "entity_type": {
            "type": "string"
          },
          "external_id": {
            "type": "string"
          },
          "metadata": {},
          "steps_completed": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "uniqueItems": false
          },
          "updated_at": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "onboarding.UpdateOnboardingRequest": {
        "properties": {
          "completed_at": {
            "type": "string"
          },
          "metadata": {},
          "steps_completed": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "uniqueItems": false
          }
        },
        "type": "object"
      },
      "response.ErrorCode": {
        "enum": [
          "VALIDATION_ERROR",
          "NOT_FOUND",
          "AUTHENTICATION_ERROR",
          "FORBIDDEN",
          "SYSTEM_ERROR",
          "BAD_REQUEST",
          "CONFLICT",
          "TOO_MANY_REQUESTS",
          "LESS_CREDITS"
        ],
        "type": "string",
        "x-enum-varnames": [
          "ErrCodeValidation",
          "ErrCodeNotFound",
          "ErrCodeUnauthorized",
          "ErrCodeForbidden",
          "ErrCodeInternal",
          "ErrCodeBadRequest",
          "ErrCodeConflict",
          "ErrCodeTooManyReqs",
          "ErrLessCredits"
        ]
      },
      "response.ErrorMessage": {
        "properties": {
          "message": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "response.ErrorResponse": {
        "properties": {
          "code": {
            "$ref": "#/components/schemas/response.ErrorCode"
          },
          "details": {},
          "error": {
            "$ref": "#/components/schemas/response.ErrorMessage"
          }
        },
        "type": "object"
      },
      "sqlc.ResultFormatEnum": {
        "enum": [
          "markdown",
          "structured"
        ],
        "example": "structured",
        "type": "string",
        "x-enum-varnames": [
          "ResultFormatEnumMarkdown",
          "ResultFormatEnumStructured"
        ]
      },
      "status.Response": {
        "properties": {
          "created_at": {
            "description": "When the job was created",
            "type": "string"
          },
          "error_message": {
            "description": "Error message if job failed\nexample: Failed to process page 5",
            "type": "string"
          },
          "file_name": {
            "description": "The name of the file being processed\nexample: quarterly_financial_report_q4.pdf",
            "type": "string"
          },
          "id": {
            "description": "The unique identifier of the job\nexample: 123e4567-e89b-12d3-a456-426614174000",
            "type": "string"
          },
          "processed_pages": {
            "description": "Number of pages processed so far\nexample: 24",
            "type": "integer"
          },
          "processing_time": {
            "description": "Total processing time in seconds\nexample: 156",
            "type": "integer"
          },
          "result_format": {
            "description": "The result format type of the job\nexample: structured",
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/models.JobStatus"
          },
          "total_pages": {
            "description": "Total number of pages in the document\nexample: 24",
            "type": "integer"
          }
        },
        "type": "object"
      },
      "subscriptions.CreateWebhookSubscriptionRequest": {
        "properties": {
          "description": {
            "maxLength": 500,
            "type": "string"
          },
          "enabled": {
            "type": "boolean"
          },
          "events": {
            "items": {
              "type": "string"
            },
            "minItems": 1,
            "type": "array",
            "uniqueItems": false
          },
          "url": {
            "type": "string"
          }
        },
        "required": [
          "events",
          "url"
        ],
        "type": "object"
      },
      "subscriptions.UpdateWebhookSubscriptionRequest": {
        "properties": {
          "description": {
            "maxLength": 500,
            "type": "string"
          },
          "enabled": {
            "type": "boolean"
          },
          "events": {
            "items": {
              "type": "string"
            },
            "minItems": 1,
            "type": "array",
            "uniqueItems": false
          },
          "url": {
            "type": "string"
          }
        },
        "required": [
          "events"
        ],
        "type": "object"
      },
      "subscriptions.WebhookEventTypesResponse": {
        "properties": {
          "event_types": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "uniqueItems": false
          }
        },
        "type": "object"
      },
      "subscriptions.WebhookSubscriptionResponse": {
        "properties": {
          "created_at": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "enabled": {
            "type": "boolean"
          },
          "events": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "uniqueItems": false
          },
          "failure_count": {
            "type": "integer"
          },
          "id": {
            "type": "string"
          },
          "last_triggered_at": {
            "type": "string"
          },
          "organization_id": {
            "type": "string"
          },
          "secret": {
            "description": "Always included - users need it to verify signatures",
            "type": "string"
          },
          "team_id": {
            "type": "string"
          },
          "updated_at": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "user_id": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "subscriptions.WebhooksListCursorResponse": {
        "properties": {
          "data": {
            "items": {
              "$ref": "#/components/schemas/subscriptions.WebhookSubscriptionResponse"
            },
            "type": "array",
            "uniqueItems": false
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "type": "string"
          },
          "total_count": {
            "type": "integer"
          },
          "total_pages": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "team_settings.TeamSettingsConfig": {
        "properties": {
          "auto_delete_enabled": {
            "example": true,
            "type": "boolean"
          },
          "retention_period_days": {
            "example": 7,
            "maximum": 365,
            "minimum": 0,
            "type": "integer"
          }
        },
        "type": "object"
      },
      "team_settings.TeamSettingsResponse": {
        "properties": {
          "config": {
            "$ref": "#/components/schemas/team_settings.TeamSettingsConfig"
          },
          "created_at": {
            "example": "2023-12-25T10:30:00Z",
            "format": "date-time",
            "type": "string"
          },
          "team_id": {
            "example": "123e4567-e89b-12d3-a456-426614174000",
            "format": "string",
            "type": "string"
          },
          "updated_at": {
            "example": "2023-12-25T10:30:00Z",
            "format": "date-time",
            "type": "string"
          }
        },
        "type": "object"
      },
      "team_settings.UpdateTeamSettingsRequest": {
        "properties": {
          "auto_delete_enabled": {
            "example": true,
            "type": "boolean"
          },
          "retention_period_days": {
            "example": 30,
            "maximum": 365,
            "minimum": 0,
            "type": "integer"
          }
        },
        "type": "object"
      },
      "templates.CreateTemplateRequest": {
        "properties": {
          "color": {
            "example": "#FF5733",
            "type": "string"
          },
          "description": {
            "example": "Template for processing invoice documents",
            "maxLength": 1000,
            "type": "string"
          },
          "enabled": {
            "example": true,
            "type": "boolean"
          },
          "extract_bounding_boxes": {
            "example": false,
            "type": "boolean"
          },
          "favorite": {
            "example": true,
            "type": "boolean"
          },
          "format": {
            "$ref": "#/components/schemas/sqlc.ResultFormatEnum"
          },
          "instructions": {
            "example": "Extract key financial information from invoices",
            "maxLength": 2000,
            "type": "string"
          },
          "model": {
            "example": "standard-v2",
            "type": "string"
          },
          "name": {
            "example": "Invoice Template",
            "maxLength": 255,
            "minLength": 1,
            "type": "string"
          },
          "schema": {
            "type": "object"
          },
          "tags": {
            "example": [
              "financial",
              "invoice",
              "processing"
            ],
            "items": {
              "type": "string"
            },
            "type": "array",
            "uniqueItems": false
          }
        },
        "required": [
          "format",
          "model",
          "name"
        ],
        "type": "object"
      },
      "templates.TemplateResponse": {
        "properties": {
          "checksum": {
            "example": "abc123def456",
            "type": "string"
          },
          "color": {
            "example": "#FF5733",
            "type": "string"
          },
          "created_at": {
            "example": "2023-12-25T10:30:00Z",
            "format": "date-time",
            "type": "string"
          },
          "description": {
            "example": "Template for processing invoice documents",
            "type": "string"
          },
          "enabled": {
            "example": true,
            "type": "boolean"
          },
          "ephemeral": {
            "example": false,
            "type": "boolean"
          },
          "extract_bounding_boxes": {
            "example": false,
            "type": "boolean"
          },
          "favorite": {
            "example": true,
            "type": "boolean"
          },
          "format": {
            "$ref": "#/components/schemas/sqlc.ResultFormatEnum"
          },
          "id": {
            "example": "123e4567-e89b-12d3-a456-426614174000",
            "format": "uuid",
            "type": "string"
          },
          "instructions": {
            "example": "Extract key financial information from invoices",
            "type": "string"
          },
          "internal": {
            "example": false,
            "type": "boolean"
          },
          "last_used": {
            "example": "2023-12-25T10:30:00Z",
            "format": "date-time",
            "type": "string"
          },
          "model": {
            "example": "standard-v2",
            "type": "string"
          },
          "name": {
            "example": "Invoice Template",
            "type": "string"
          },
          "schema": {
            "description": "JSON schema definition",
            "type": "object"
          },
          "slug": {
            "example": "invoice-template",
            "type": "string"
          },
          "tags": {
            "example": [
              "financial",
              "invoice",
              "processing"
            ],
            "items": {
              "type": "string"
            },
            "type": "array",
            "uniqueItems": false
          },
          "team_id": {
            "example": "123e4567-e89b-12d3-a456-426614174002",
            "format": "uuid",
            "type": "string"
          },
          "updated_at": {
            "example": "2023-12-25T10:30:00Z",
            "format": "date-time",
            "type": "string"
          },
          "usage_count": {
            "example": 5,
            "minimum": 0,
            "type": "integer"
          },
          "user_id": {
            "example": "123e4567-e89b-12d3-a456-426614174001",
            "format": "uuid",
            "type": "string"
          }
        },
        "type": "object"
      },
      "templates.TemplateStatsResponse": {
        "properties": {
          "average_usage_per_template": {
            "example": 6,
            "type": "number"
          },
          "favorite_templates": {
            "example": 5,
            "type": "integer"
          },
          "markdown_templates": {
            "example": 10,
            "type": "integer"
          },
          "max_usage": {
            "example": 25,
            "type": "integer"
          },
          "min_usage": {
            "example": 0,
            "type": "integer"
          },
          "structured_templates": {
            "example": 12,
            "type": "integer"
          },
          "total_templates": {
            "example": 25,
            "type": "integer"
          },
          "total_usage": {
            "example": 150,
            "type": "integer"
          }
        },
        "type": "object"
      },
      "templates.TemplatesListCursorResponse": {
        "properties": {
          "data": {
            "items": {
              "$ref": "#/components/schemas/templates.TemplateResponse"
            },
            "type": "array",
            "uniqueItems": false
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "type": "string"
          },
          "total_count": {
            "type": "integer"
          },
          "total_pages": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "templates.UpdateTemplateRequest": {
        "properties": {
          "color": {
            "example": "#FF5733",
            "type": "string"
          },
          "description": {
            "example": "Updated template for processing invoice documents",
            "maxLength": 1000,
            "type": "string"
          },
          "enabled": {
            "example": true,
            "type": "boolean"
          },
          "extract_bounding_boxes": {
            "example": false,
            "type": "boolean"
          },
          "favorite": {
            "example": true,
            "type": "boolean"
          },
          "format": {
            "$ref": "#/components/schemas/sqlc.ResultFormatEnum"
          },
          "instructions": {
            "example": "Extract key financial information from invoices",
            "maxLength": 2000,
            "type": "string"
          },
          "model": {
            "example": "standard-v2",
            "type": "string"
          },
          "name": {
            "example": "Updated Invoice Template",
            "maxLength": 255,
            "minLength": 1,
            "type": "string"
          },
          "schema": {
            "description": "JSON schema definition",
            "type": "object"
          },
          "tags": {
            "example": [
              "financial",
              "invoice",
              "processing"
            ],
            "items": {
              "type": "string"
            },
            "type": "array",
            "uniqueItems": false
          }
        },
        "required": [
          "format",
          "name"
        ],
        "type": "object"
      },
      "upload.CompletedPart": {
        "properties": {
          "etag": {
            "example": "\"9bb58f26192e4ba00f01e2e7b136bbd8\"",
            "minLength": 1,
            "type": "string"
          },
          "part_number": {
            "example": 1,
            "minimum": 1,
            "type": "integer"
          }
        },
        "required": [
          "etag",
          "part_number"
        ],
        "type": "object"
      },
      "upload.DirectUploadCompleteRequest": {
        "properties": {
          "parts": {
            "items": {
              "$ref": "#/components/schemas/upload.CompletedPart"
            },
            "minItems": 1,
            "type": "array",
            "uniqueItems": false
          }
        },
        "required": [
          "parts"
        ],
        "type": "object"
      },
      "upload.DirectUploadCompleteResponse": {
        "properties": {
          "created_at": {
            "example": "2023-12-25T10:30:00Z",
            "format": "date-time",
            "type": "string"
          },
          "job_id": {
            "example": "123e4567-e89b-12d3-a456-426614174000",
            "format": "uuid",
            "type": "string"
          },
          "message": {
            "example": "Upload completed successfully, processing started",
            "type": "string"
          },
          "status": {
            "example": "pending",
            "type": "string"
          }
        },
        "type": "object"
      },
      "upload.DirectUploadResponse": {
        "properties": {
          "chunk_size": {
            "example": 5242880,
            "type": "integer"
          },
          "complete_url": {
            "example": "/api/v1/ocr/uploads/123e4567-e89b-12d3-a456-426614174000/complete",
            "type": "string"
          },
          "expires_at": {
            "example": "2023-12-25T10:45:00Z",
            "format": "date-time",
            "type": "string"
          },
          "job_id": {
            "example": "123e4567-e89b-12d3-a456-426614174000",
            "format": "uuid",
            "type": "string"
          },
          "parts": {
            "items": {
              "$ref": "#/components/schemas/upload.MultipartPart"
            },
            "type": "array",
            "uniqueItems": false
          },
          "total_chunks": {
            "example": 1,
            "type": "integer"
          },
          "upload_id": {
            "example": "550e8400-e29b-41d4-a716-446655440000",
            "type": "string"
          },
          "upload_type": {
            "example": "multipart",
            "type": "string"
          }
        },
        "type": "object"
      },
      "upload.InitiateDirectUploadRequest": {
        "properties": {
          "content_type": {
            "example": "application/pdf",
            "type": "string"
          },
          "extract_bounding_boxes": {
            "description": "Pipeline enhancement: bounding box extraction",
            "example": false,
            "type": "boolean"
          },
          "file_name": {
            "example": "document.pdf",
            "maxLength": 255,
            "minLength": 1,
            "type": "string"
          },
          "file_size": {
            "example": 1048576,
            "maximum": 1073741824,
            "minimum": 1,
            "type": "integer"
          },
          "format": {
            "enum": [
              "markdown",
              "structured"
            ],
            "example": "markdown",
            "type": "string"
          },
          "instructions": {
            "example": "Extract key information",
            "maxLength": 100,
            "type": "string"
          },
          "model": {
            "example": "standard-v2",
            "type": "string"
          },
          "save_as_template": {
            "example": false,
            "type": "boolean"
          },
          "schema": {
            "additionalProperties": {},
            "type": "object"
          },
          "template_slug": {
            "example": "invoice-template",
            "type": "string"
          }
        },
        "required": [
          "content_type",
          "file_name",
          "file_size"
        ],
        "type": "object"
      },
      "upload.MultipartPart": {
        "properties": {
          "end_byte": {
            "example": 5242879,
            "type": "integer"
          },
          "part_number": {
            "example": 1,
            "type": "integer"
          },
          "start_byte": {
            "example": 0,
            "type": "integer"
          },
          "upload_url": {
            "example": "https://r2.example.com/bucket/file.pdf?partNumber=1&uploadId=abc123",
            "type": "string"
          }
        },
        "type": "object"
      },
      "upload.RemoteURLUploadRequest": {
        "properties": {
          "extract_bounding_boxes": {
            "description": "Pipeline enhancement: bounding box extraction",
            "example": false,
            "type": "boolean"
          },
          "file_name": {
            "example": "document.pdf",
            "maxLength": 255,
            "minLength": 1,
            "type": "string"
          },
          "format": {
            "description": "Option 2: Direct specification (will create template on-the-fly)",
            "enum": [
              "markdown",
              "structured"
            ],
            "example": "markdown",
            "type": "string"
          },
          "instructions": {
            "example": "Extract key information",
            "maxLength": 100,
            "type": "string"
          },
          "model": {
            "example": "standard-v2",
            "type": "string"
          },
          "save_as_template": {
            "example": false,
            "type": "boolean"
          },
          "schema": {
            "additionalProperties": {},
            "type": "object"
          },
          "template_slug": {
            "description": "Option 1: Use existing template by slug",
            "example": "invoice-template",
            "type": "string"
          },
          "url": {
            "example": "https://example.com/document.pdf",
            "maxLength": 2000,
            "type": "string"
          }
        },
        "required": [
          "url"
        ],
        "type": "object"
      },
      "upload.RemoteURLUploadResponse": {
        "properties": {
          "created_at": {
            "example": "2023-12-25T10:30:00Z",
            "format": "date-time",
            "type": "string"
          },
          "job_id": {
            "example": "123e4567-e89b-12d3-a456-426614174000",
            "format": "uuid",
            "type": "string"
          },
          "source_url": {
            "example": "https://example.com/document.pdf",
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/models.JobStatus"
          }
        },
        "type": "object"
      },
      "webhooks.R2UploadNotification": {
        "properties": {
          "object_key": {
            "example": "uploads/document.pdf",
            "maxLength": 255,
            "minLength": 1,
            "type": "string"
          },
          "size": {
            "example": 1024,
            "minimum": 1,
            "type": "integer"
          },
          "timestamp": {
            "example": "2024-01-01T00:00:00Z",
            "type": "string"
          }
        },
        "required": [
          "object_key",
          "size",
          "timestamp"
        ],
        "type": "object"
      }
    },
    "securitySchemes": {
      "ApiKeyAuth": {
        "description": "Provide your LeapOCR API key via the `X-API-KEY` header. Example: X-API-KEY: YOUR_API_KEY",
        "in": "header",
        "name": "X-API-KEY",
        "type": "apiKey"
      },
      "BearerAuth": {
        "description": "Provide your JWT token via the `Authorization` header. Example: Authorization: Bearer <token>",
        "scheme": "bearer",
        "type": "http"
      }
    }
  },
  "info": {
    "contact": {
      "email": "support@leapocr.com",
      "name": "LeapOCR Support",
      "url": "http://leapocr.com/support"
    },
    "description": "Advanced OCR API for processing PDF documents with AI-powered text extraction using Gemini LLM integration. Supports structured data extraction, template-based processing, and real-time job management.",
    "license": {
      "name": "LeapOCR License",
      "url": "http://leapocr.com/license"
    },
    "termsOfService": "http://leapocr.com/terms/",
    "title": "LeapOCR API",
    "version": "v1"
  },
  "externalDocs": {
    "description": "OpenAPI Specification",
    "url": "https://swagger.io/resources/open-api/"
  },
  "paths": {
    "/auth/verify": {
      "get": {
        "description": "Verify JWT token from Authorization header and return complete user information including all claims and authentication details",
        "operationId": "verifyAuthToken",
        "parameters": [
          {
            "description": "Bearer JWT token",
            "example": "\"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...\"",
            "in": "header",
            "name": "Authorization",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/auth.AuthResponse"
                }
              }
            },
            "description": "Token verified successfully - user authenticated"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized - invalid or expired token"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error during token verification"
          }
        },
        "summary": "Verify authentication token",
        "tags": [
          "Authentication"
        ]
      }
    },
    "/credits/polar/products/catalog": {
      "get": {
        "description": "Retrieve list of all available products from Polar with caching",
        "operationId": "getPolarProductsCatalog",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductCatalog"
                }
              }
            },
            "description": "Products retrieved successfully"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized - authentication required"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Get Polar products catalog",
        "tags": [
          "Credits"
        ]
      }
    },
    "/health": {
      "get": {
        "description": "Retrieve comprehensive system health information including database connectivity, Gemini API service status, and application performance metrics. Performs active health checks on critical system components and returns detailed status information with response times for monitoring and diagnostics purposes.",
        "operationId": "getHealthStatus",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/health.HealthStatus"
                }
              }
            },
            "description": "System health status retrieved successfully - all components are healthy"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error during health check execution"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/health.HealthStatus"
                }
              }
            },
            "description": "Service unavailable - one or more critical system components are down or degraded"
          }
        },
        "summary": "Get system health status",
        "tags": [
          "Health"
        ]
      }
    },
    "/ocr/delete/{job_id}": {
      "delete": {
        "description": "Permanently delete an OCR job and all associated data including pages, results, and metadata. This action cannot be undone",
        "operationId": "deleteJob",
        "parameters": [
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "OCR job ID to delete",
            "in": "path",
            "name": "job_id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Job deleted successfully"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad request - invalid job ID"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized - authentication required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Not found - job does not exist or already deleted"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Delete OCR job",
        "tags": [
          "Jobs"
        ]
      }
    },
    "/ocr/models": {
      "get": {
        "description": "Retrieve a list of all enabled OCR models with their configurations, pricing, and capabilities",
        "operationId": "listOCRModels",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/models_list.ModelsListResponse"
                }
              }
            },
            "description": "Models retrieved successfully"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized - authentication required"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "summary": "List available OCR models",
        "tags": [
          "OCR",
          "Models"
        ]
      }
    },
    "/ocr/result/{job_id}": {
      "get": {
        "description": "Retrieve OCR processing results for a completed job with extracted text and structured data. Returns job status if processing is still in progress. Supports pagination",
        "operationId": "getJobResult",
        "parameters": [
          {
            "description": "OCR job ID",
            "in": "path",
            "name": "job_id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Page number for result pagination",
            "in": "query",
            "name": "page",
            "schema": {
              "default": 1,
              "minimum": 1,
              "type": "integer"
            }
          },
          {
            "description": "Number of items per page",
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 100,
              "maximum": 1000,
              "minimum": 1,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/models.OCRResultResponse"
                }
              }
            },
            "description": "OCR processing completed, results available"
          },
          "202": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/models.OCRStatusResponse"
                }
              }
            },
            "description": "OCR processing in progress, status returned"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad request - invalid job ID or parameters"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized - authentication required"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Forbidden - job belongs to different user"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Not found - job does not exist"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Get OCR job result",
        "tags": [
          "OCR",
          "SDK"
        ]
      }
    },
    "/ocr/status/{job_id}": {
      "get": {
        "description": "Retrieve current processing status and progress information for an OCR job. Shows completion status, progress percentage, and any error details",
        "operationId": "getJobStatus",
        "parameters": [
          {
            "description": "OCR job ID",
            "in": "path",
            "name": "job_id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/status.Response"
                }
              }
            },
            "description": "Job status retrieved successfully"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad request - invalid job ID format"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized - authentication required"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Forbidden - job belongs to different user"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Not found - job does not exist"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Get OCR job status",
        "tags": [
          "OCR",
          "SDK"
        ]
      }
    },
    "/ocr/uploads/direct": {
      "post": {
        "description": "Create a job and generate presigned URLs for direct file upload to S3. Uses multipart upload for all files (1 part for small files, multiple parts for large files ≥50MB).\n**Output Types:**\n- `structured`: Structured data extraction. Requires either template_slug OR format (with schema)\n- `markdown`: Page-by-page OCR. Requires either template_slug or format. When using format directly, model is required; other fields remain optional unless structured schema rules apply\n**Note:** Only one of template_slug or format can be provided per request",
        "operationId": "directUpload",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/upload.InitiateDirectUploadRequest",
                    "summary": "request",
                    "description": "Upload initiation request"
                  }
                ]
              }
            }
          },
          "description": "Upload initiation request",
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/upload.DirectUploadResponse"
                }
              }
            },
            "description": "OK"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad Request"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "402": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Insufficient credits"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal Server Error"
          }
        },
        "summary": "Direct upload",
        "tags": [
          "OCR",
          "Upload",
          "SDK"
        ]
      }
    },
    "/ocr/uploads/url": {
      "post": {
        "description": "Create a job and start processing from a remote URL that serves a supported document or image type.\n**Output Types:**\n- `structured`: Structured data extraction. Requires either template_slug OR format (with schema)\n- `markdown`: Page-by-page OCR. Requires either template_slug or format. When using format directly, model is required; other fields remain optional unless structured schema rules apply\n**Note:** Only one of template_slug or format can be provided per request",
        "operationId": "uploadFromRemoteURL",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/upload.RemoteURLUploadRequest",
                    "summary": "request",
                    "description": "Remote URL upload request"
                  }
                ]
              }
            }
          },
          "description": "Remote URL upload request",
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/upload.RemoteURLUploadResponse"
                }
              }
            },
            "description": "OK"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad Request"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "402": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Insufficient credits"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal Server Error"
          }
        },
        "summary": "Remote URL upload",
        "tags": [
          "OCR",
          "Upload",
          "SDK"
        ]
      }
    },
    "/ocr/uploads/{job_id}/complete": {
      "post": {
        "description": "Complete a direct upload by providing all uploaded part ETags",
        "operationId": "completeDirectUpload",
        "parameters": [
          {
            "description": "Job ID",
            "in": "path",
            "name": "job_id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/upload.DirectUploadCompleteRequest",
                    "summary": "request",
                    "description": "Completion request with part ETags"
                  }
                ]
              }
            }
          },
          "description": "Completion request with part ETags",
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/upload.DirectUploadCompleteResponse"
                }
              }
            },
            "description": "OK"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad Request"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal Server Error"
          }
        },
        "summary": "Complete direct upload",
        "tags": [
          "OCR",
          "Upload",
          "SDK"
        ]
      }
    },
    "/onboarding": {
      "post": {
        "description": "Create onboarding status for an entity",
        "operationId": "createOnboarding",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/onboarding.CreateOnboardingRequest",
                    "summary": "request",
                    "description": "Onboarding request"
                  }
                ]
              }
            }
          },
          "description": "Onboarding request",
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/onboarding.OnboardingStatus"
                }
              }
            },
            "description": "Created"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad Request"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Conflict"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal Server Error"
          }
        },
        "security": [
          {
            "Bearer": []
          }
        ],
        "summary": "Create onboarding status",
        "tags": [
          "onboarding"
        ]
      }
    },
    "/onboarding/{external_id}": {
      "delete": {
        "description": "Permanently delete onboarding status for an entity",
        "operationId": "deleteOnboarding",
        "parameters": [
          {
            "description": "External ID",
            "in": "path",
            "name": "external_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal Server Error"
          }
        },
        "security": [
          {
            "Bearer": []
          }
        ],
        "summary": "Delete onboarding status",
        "tags": [
          "onboarding"
        ]
      },
      "get": {
        "description": "Get onboarding status for an entity by external ID",
        "operationId": "getOnboarding",
        "parameters": [
          {
            "description": "External ID",
            "in": "path",
            "name": "external_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/onboarding.OnboardingStatus"
                }
              }
            },
            "description": "OK"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal Server Error"
          }
        },
        "security": [
          {
            "Bearer": []
          }
        ],
        "summary": "Get onboarding status",
        "tags": [
          "onboarding"
        ]
      },
      "put": {
        "description": "Update onboarding steps and metadata for an entity",
        "operationId": "updateOnboarding",
        "parameters": [
          {
            "description": "External ID",
            "in": "path",
            "name": "external_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/onboarding.UpdateOnboardingRequest",
                    "summary": "request",
                    "description": "Update request"
                  }
                ]
              }
            }
          },
          "description": "Update request",
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/onboarding.OnboardingStatus"
                }
              }
            },
            "description": "OK"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad Request"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal Server Error"
          }
        },
        "security": [
          {
            "Bearer": []
          }
        ],
        "summary": "Update onboarding status",
        "tags": [
          "onboarding"
        ]
      }
    },
    "/organizations/{organization_id}/credits/balance": {
      "get": {
        "description": "Retrieve current credit balance, consumption, trial status, active subscriptions, granted benefits, and active meters for the authenticated user's organization from the JWT token.",
        "operationId": "getOrganizationCreditsBalance",
        "parameters": [
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreditBalanceResponse"
                }
              }
            },
            "description": "Organization credits and billing details retrieved successfully"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized - authentication required"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Get organization credits balance",
        "tags": [
          "Credits"
        ]
      }
    },
    "/organizations/{organization_id}/credits/transactions": {
      "get": {
        "description": "Retrieve a cursor-paginated list of credit transactions for an organization",
        "operationId": "listOrgCreditTransactionsCursor",
        "parameters": [
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Cursor for pagination",
            "in": "query",
            "name": "cursor",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Number of items per page",
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 20,
              "maximum": 100,
              "minimum": 1,
              "type": "integer"
            }
          },
          {
            "description": "Search by job ID or file name",
            "in": "query",
            "name": "search",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Filter by OCR model",
            "in": "query",
            "name": "model",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Filter by creation date (ISO 8601, inclusive)",
            "in": "query",
            "name": "created_from",
            "schema": {
              "format": "date-time",
              "type": "string"
            }
          },
          {
            "description": "Filter by creation date (ISO 8601, inclusive)",
            "in": "query",
            "name": "created_to",
            "schema": {
              "format": "date-time",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/credits.OrgCreditTransactionsListCursorResponse"
                }
              }
            },
            "description": "Organization credit transactions list retrieved successfully"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad request"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "List organization credit transactions with cursor pagination",
        "tags": [
          "Credits"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/analytics/compare": {
      "get": {
        "description": "Returns comparison between current period and previous period of equal duration with change percentages",
        "operationId": "getPeriodComparison",
        "parameters": [
          {
            "description": "Time range preset",
            "in": "query",
            "name": "range",
            "schema": {
              "enum": [
                "24h",
                "1d",
                "day",
                "7d",
                "week",
                "14d",
                "30d",
                "month",
                "90d",
                "quarter",
                "180d",
                "6m",
                "365d",
                "year"
              ],
              "type": "string"
            }
          },
          {
            "description": "Start date (RFC3339 or YYYY-MM-DD format)",
            "in": "query",
            "name": "start",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "End date (RFC3339 or YYYY-MM-DD format)",
            "in": "query",
            "name": "end",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/analytics.PeriodComparisonResponse"
                }
              }
            },
            "description": "Period comparison data"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Invalid request parameters"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "summary": "Get period comparison analytics",
        "tags": [
          "Analytics"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/analytics/confidence": {
      "get": {
        "description": "Returns confidence score analytics including confidence distribution and summary statistics",
        "operationId": "getConfidenceMetrics",
        "parameters": [
          {
            "description": "Time range preset",
            "in": "query",
            "name": "range",
            "schema": {
              "enum": [
                "24h",
                "1d",
                "day",
                "7d",
                "week",
                "14d",
                "30d",
                "month",
                "90d",
                "quarter",
                "180d",
                "6m",
                "365d",
                "year"
              ],
              "type": "string"
            }
          },
          {
            "description": "Start date (RFC3339 or YYYY-MM-DD format)",
            "in": "query",
            "name": "start",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "End date (RFC3339 or YYYY-MM-DD format)",
            "in": "query",
            "name": "end",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/analytics.ConfidenceMetricsResponse"
                }
              }
            },
            "description": "Confidence metrics analytics data"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Invalid request parameters"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "summary": "Get confidence metrics analytics",
        "tags": [
          "Analytics"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/analytics/confidence/timeseries": {
      "get": {
        "description": "Returns confidence score trends aggregated by time buckets",
        "operationId": "getConfidenceTimeseries",
        "parameters": [
          {
            "description": "Time range preset",
            "in": "query",
            "name": "range",
            "schema": {
              "enum": [
                "24h",
                "1d",
                "day",
                "7d",
                "week",
                "14d",
                "30d",
                "month",
                "90d",
                "quarter",
                "180d",
                "6m",
                "365d",
                "year"
              ],
              "type": "string"
            }
          },
          {
            "description": "Start date (RFC3339 or YYYY-MM-DD format)",
            "in": "query",
            "name": "start",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "End date (RFC3339 or YYYY-MM-DD format)",
            "in": "query",
            "name": "end",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Time bucket granularity",
            "in": "query",
            "name": "bucket",
            "schema": {
              "enum": [
                "hour",
                "day",
                "week",
                "month"
              ],
              "type": "string"
            }
          },
          {
            "description": "Alias for bucket parameter",
            "in": "query",
            "name": "granularity",
            "schema": {
              "enum": [
                "hour",
                "day",
                "week",
                "month"
              ],
              "type": "string"
            }
          },
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/analytics.ConfidenceTimeseriesResponse"
                }
              }
            },
            "description": "Confidence timeseries data"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Invalid request parameters"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "summary": "Get confidence metrics timeseries",
        "tags": [
          "Analytics"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/analytics/credits/usage": {
      "get": {
        "description": "Returns comprehensive credit analytics including snapshot data, timeseries trends, and model usage breakdown",
        "operationId": "getCreditUsage",
        "parameters": [
          {
            "description": "Time range preset",
            "in": "query",
            "name": "range",
            "schema": {
              "enum": [
                "24h",
                "1d",
                "day",
                "7d",
                "week",
                "14d",
                "30d",
                "month",
                "90d",
                "quarter",
                "180d",
                "6m",
                "365d",
                "year"
              ],
              "type": "string"
            }
          },
          {
            "description": "Start date (RFC3339 or YYYY-MM-DD format)",
            "in": "query",
            "name": "start",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "End date (RFC3339 or YYYY-MM-DD format)",
            "in": "query",
            "name": "end",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Time bucket granularity",
            "in": "query",
            "name": "bucket",
            "schema": {
              "enum": [
                "hour",
                "day",
                "week",
                "month"
              ],
              "type": "string"
            }
          },
          {
            "description": "Alias for bucket parameter",
            "in": "query",
            "name": "granularity",
            "schema": {
              "enum": [
                "hour",
                "day",
                "week",
                "month"
              ],
              "type": "string"
            }
          },
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/analytics.CreditsUsageResponse"
                }
              }
            },
            "description": "Credit usage analytics data"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Invalid request parameters"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "summary": "Get credit usage analytics",
        "tags": [
          "Analytics"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/analytics/documents": {
      "get": {
        "description": "Returns document-level analytics including file size statistics and page count distribution",
        "operationId": "getDocumentStats",
        "parameters": [
          {
            "description": "Time range preset",
            "in": "query",
            "name": "range",
            "schema": {
              "enum": [
                "24h",
                "1d",
                "day",
                "7d",
                "week",
                "14d",
                "30d",
                "month",
                "90d",
                "quarter",
                "180d",
                "6m",
                "365d",
                "year"
              ],
              "type": "string"
            }
          },
          {
            "description": "Start date (RFC3339 or YYYY-MM-DD format)",
            "in": "query",
            "name": "start",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "End date (RFC3339 or YYYY-MM-DD format)",
            "in": "query",
            "name": "end",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/analytics.DocumentStatsResponse"
                }
              }
            },
            "description": "Document analytics data"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Invalid request parameters"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "summary": "Get document analytics",
        "tags": [
          "Analytics"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/analytics/documents/filetypes": {
      "get": {
        "description": "Returns document type distribution by file extension",
        "operationId": "getFileTypeBreakdown",
        "parameters": [
          {
            "description": "Time range preset",
            "in": "query",
            "name": "range",
            "schema": {
              "enum": [
                "24h",
                "1d",
                "day",
                "7d",
                "week",
                "14d",
                "30d",
                "month",
                "90d",
                "quarter",
                "180d",
                "6m",
                "365d",
                "year"
              ],
              "type": "string"
            }
          },
          {
            "description": "Start date (RFC3339 or YYYY-MM-DD format)",
            "in": "query",
            "name": "start",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "End date (RFC3339 or YYYY-MM-DD format)",
            "in": "query",
            "name": "end",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Maximum number of file types to return (default: 50, max: 100)",
            "in": "query",
            "name": "limit",
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/analytics.FileTypeBreakdownResponse"
                }
              }
            },
            "description": "File type breakdown data"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Invalid request parameters"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "summary": "Get file type breakdown",
        "tags": [
          "Analytics"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/analytics/errors": {
      "get": {
        "description": "Returns error analysis including failure rates and error patterns",
        "operationId": "getErrorAnalysis",
        "parameters": [
          {
            "description": "Time range preset",
            "in": "query",
            "name": "range",
            "schema": {
              "enum": [
                "24h",
                "1d",
                "day",
                "7d",
                "week",
                "14d",
                "30d",
                "month",
                "90d",
                "quarter",
                "180d",
                "6m",
                "365d",
                "year"
              ],
              "type": "string"
            }
          },
          {
            "description": "Start date (RFC3339 or YYYY-MM-DD format)",
            "in": "query",
            "name": "start",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "End date (RFC3339 or YYYY-MM-DD format)",
            "in": "query",
            "name": "end",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/analytics.ErrorAnalysisResponse"
                }
              }
            },
            "description": "Error analytics data"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Invalid request parameters"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "summary": "Get error analytics",
        "tags": [
          "Analytics"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/analytics/errors/timeseries": {
      "get": {
        "description": "Returns error trends aggregated by time buckets including failure rates",
        "operationId": "getErrorTimeseries",
        "parameters": [
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Time range preset",
            "in": "query",
            "name": "range",
            "schema": {
              "enum": [
                "24h",
                "1d",
                "day",
                "7d",
                "week",
                "14d",
                "30d",
                "month",
                "90d",
                "quarter",
                "180d",
                "6m",
                "365d",
                "year"
              ],
              "type": "string"
            }
          },
          {
            "description": "Start date (RFC3339 or YYYY-MM-DD format)",
            "in": "query",
            "name": "start",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "End date (RFC3339 or YYYY-MM-DD format)",
            "in": "query",
            "name": "end",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Time bucket granularity",
            "in": "query",
            "name": "bucket",
            "schema": {
              "enum": [
                "hour",
                "day",
                "week",
                "month"
              ],
              "type": "string"
            }
          },
          {
            "description": "Alias for bucket parameter",
            "in": "query",
            "name": "granularity",
            "schema": {
              "enum": [
                "hour",
                "day",
                "week",
                "month"
              ],
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/analytics.ErrorTimeseriesResponse"
                }
              }
            },
            "description": "Error timeseries data"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Invalid request parameters"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "summary": "Get error analytics timeseries",
        "tags": [
          "Analytics"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/analytics/jobs/timeseries": {
      "get": {
        "description": "Returns job metrics aggregated by time buckets including total jobs, completed jobs, failed jobs, active jobs, pages processed, and credits consumed",
        "operationId": "getJobTimeseries",
        "parameters": [
          {
            "description": "Time range preset",
            "in": "query",
            "name": "range",
            "schema": {
              "enum": [
                "24h",
                "1d",
                "day",
                "7d",
                "week",
                "14d",
                "30d",
                "month",
                "90d",
                "quarter",
                "180d",
                "6m",
                "365d",
                "year"
              ],
              "type": "string"
            }
          },
          {
            "description": "Start date (RFC3339 or YYYY-MM-DD format)",
            "in": "query",
            "name": "start",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "End date (RFC3339 or YYYY-MM-DD format)",
            "in": "query",
            "name": "end",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Time bucket granularity",
            "in": "query",
            "name": "bucket",
            "schema": {
              "enum": [
                "hour",
                "day",
                "week",
                "month"
              ],
              "type": "string"
            }
          },
          {
            "description": "Alias for bucket parameter",
            "in": "query",
            "name": "granularity",
            "schema": {
              "enum": [
                "hour",
                "day",
                "week",
                "month"
              ],
              "type": "string"
            }
          },
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "range": {
                      "$ref": "#/components/schemas/analytics.Range"
                    },
                    "timeseries": {
                      "items": {
                        "$ref": "#/components/schemas/analytics.JobTimeseriesPoint"
                      },
                      "type": "array"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Job timeseries data"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Invalid request parameters"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "summary": "Get job analytics timeseries",
        "tags": [
          "Analytics"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/analytics/overview": {
      "get": {
        "description": "Returns high-level analytics insights including job statistics, page outcomes, credit usage, and webhook metrics for the specified time range",
        "operationId": "getOverview",
        "parameters": [
          {
            "description": "Time range preset",
            "in": "query",
            "name": "range",
            "schema": {
              "enum": [
                "24h",
                "1d",
                "day",
                "7d",
                "week",
                "14d",
                "30d",
                "month",
                "90d",
                "quarter",
                "180d",
                "6m",
                "365d",
                "year"
              ],
              "type": "string"
            }
          },
          {
            "description": "Start date (RFC3339 or YYYY-MM-DD format)",
            "in": "query",
            "name": "start",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "End date (RFC3339 or YYYY-MM-DD format)",
            "in": "query",
            "name": "end",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/analytics.OverviewResponse"
                }
              }
            },
            "description": "Analytics overview data"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Invalid request parameters"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "summary": "Get analytics overview",
        "tags": [
          "Analytics"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/analytics/pages/timeseries": {
      "get": {
        "description": "Returns page outcomes aggregated by time buckets including totals, completion, failure, and token counts",
        "operationId": "getPageTimeseries",
        "parameters": [
          {
            "description": "Time range preset",
            "in": "query",
            "name": "range",
            "schema": {
              "enum": [
                "24h",
                "1d",
                "day",
                "7d",
                "week",
                "14d",
                "30d",
                "month",
                "90d",
                "quarter",
                "180d",
                "6m",
                "365d",
                "year"
              ],
              "type": "string"
            }
          },
          {
            "description": "Start date (RFC3339 or YYYY-MM-DD format)",
            "in": "query",
            "name": "start",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "End date (RFC3339 or YYYY-MM-DD format)",
            "in": "query",
            "name": "end",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Time bucket granularity",
            "in": "query",
            "name": "bucket",
            "schema": {
              "enum": [
                "hour",
                "day",
                "week",
                "month"
              ],
              "type": "string"
            }
          },
          {
            "description": "Alias for bucket parameter",
            "in": "query",
            "name": "granularity",
            "schema": {
              "enum": [
                "hour",
                "day",
                "week",
                "month"
              ],
              "type": "string"
            }
          },
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "range": {
                      "$ref": "#/components/schemas/analytics.Range"
                    },
                    "timeseries": {
                      "items": {
                        "$ref": "#/components/schemas/analytics.PageTimeseriesPoint"
                      },
                      "type": "array"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Page timeseries data"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Invalid request parameters"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "summary": "Get page analytics timeseries",
        "tags": [
          "Analytics"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/analytics/templates/top": {
      "get": {
        "description": "Returns the most frequently used templates ranked by job count, usage count, and credits consumed",
        "operationId": "getTopTemplates",
        "parameters": [
          {
            "description": "Time range preset",
            "in": "query",
            "name": "range",
            "schema": {
              "enum": [
                "24h",
                "1d",
                "day",
                "7d",
                "week",
                "14d",
                "30d",
                "month",
                "90d",
                "quarter",
                "180d",
                "6m",
                "365d",
                "year"
              ],
              "type": "string"
            }
          },
          {
            "description": "Start date (RFC3339 or YYYY-MM-DD format)",
            "in": "query",
            "name": "start",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "End date (RFC3339 or YYYY-MM-DD format)",
            "in": "query",
            "name": "end",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Maximum number of templates to return (default: 10, max: 100)",
            "in": "query",
            "name": "limit",
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/analytics.TopTemplatesResponse"
                }
              }
            },
            "description": "Top templates analytics data"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Invalid request parameters"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "summary": "Get top templates analytics",
        "tags": [
          "Analytics"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/analytics/users/activity": {
      "get": {
        "description": "Returns per-user usage patterns including jobs, pages, credits consumed, and activity metrics",
        "operationId": "getUserActivity",
        "parameters": [
          {
            "description": "Time range preset",
            "in": "query",
            "name": "range",
            "schema": {
              "enum": [
                "24h",
                "1d",
                "day",
                "7d",
                "week",
                "14d",
                "30d",
                "month",
                "90d",
                "quarter",
                "180d",
                "6m",
                "365d",
                "year"
              ],
              "type": "string"
            }
          },
          {
            "description": "Start date (RFC3339 or YYYY-MM-DD format)",
            "in": "query",
            "name": "start",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "End date (RFC3339 or YYYY-MM-DD format)",
            "in": "query",
            "name": "end",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/analytics.UserActivityResponse"
                }
              }
            },
            "description": "User activity analytics data"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Invalid request parameters"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "summary": "Get user activity analytics",
        "tags": [
          "Analytics"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/analytics/users/top": {
      "get": {
        "description": "Returns ranked users by job count and credits consumed",
        "operationId": "getTopUsers",
        "parameters": [
          {
            "description": "Time range preset",
            "in": "query",
            "name": "range",
            "schema": {
              "enum": [
                "24h",
                "1d",
                "day",
                "7d",
                "week",
                "14d",
                "30d",
                "month",
                "90d",
                "quarter",
                "180d",
                "6m",
                "365d",
                "year"
              ],
              "type": "string"
            }
          },
          {
            "description": "Start date (RFC3339 or YYYY-MM-DD format)",
            "in": "query",
            "name": "start",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "End date (RFC3339 or YYYY-MM-DD format)",
            "in": "query",
            "name": "end",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Maximum number of users to return (default: 10, max: 100)",
            "in": "query",
            "name": "limit",
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/analytics.TopUsersResponse"
                }
              }
            },
            "description": "Top users analytics data"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Invalid request parameters"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "summary": "Get top users analytics",
        "tags": [
          "Analytics"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/credits/transactions": {
      "get": {
        "description": "Retrieve a cursor-paginated list of credit transactions for a team",
        "operationId": "listCreditTransactionsCursor",
        "parameters": [
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Cursor for pagination",
            "in": "query",
            "name": "cursor",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Number of items per page",
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 20,
              "maximum": 100,
              "minimum": 1,
              "type": "integer"
            }
          },
          {
            "description": "Search by job ID or file name",
            "in": "query",
            "name": "search",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Filter by OCR model",
            "in": "query",
            "name": "model",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Filter by creation date (ISO 8601, inclusive)",
            "in": "query",
            "name": "created_from",
            "schema": {
              "format": "date-time",
              "type": "string"
            }
          },
          {
            "description": "Filter by creation date (ISO 8601, inclusive)",
            "in": "query",
            "name": "created_to",
            "schema": {
              "format": "date-time",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/credits.CreditTransactionsListCursorResponse"
                }
              }
            },
            "description": "Credit transactions list retrieved successfully"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad request"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "List credit transactions with cursor pagination",
        "tags": [
          "Credits"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/jobs": {
      "get": {
        "description": "Retrieve a cursor-paginated list of OCR jobs for a team",
        "operationId": "listJobsCursor",
        "parameters": [
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Cursor for pagination",
            "in": "query",
            "name": "cursor",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Number of items per page",
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 20,
              "maximum": 100,
              "minimum": 1,
              "type": "integer"
            }
          },
          {
            "description": "Filter by job status",
            "in": "query",
            "name": "status",
            "schema": {
              "enum": [
                "pending",
                "processing",
                "completed",
                "partially_done",
                "failed"
              ],
              "type": "string"
            }
          },
          {
            "description": "Filter by OCR model",
            "in": "query",
            "name": "model",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Filter by result format",
            "in": "query",
            "name": "result_format",
            "schema": {
              "enum": [
                "structured",
                "markdown"
              ],
              "type": "string"
            }
          },
          {
            "description": "Filter by template UUID",
            "in": "query",
            "name": "template_id",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Include soft-deleted jobs",
            "in": "query",
            "name": "include_deleted",
            "schema": {
              "default": false,
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/jobs.JobsListCursorResponse"
                }
              }
            },
            "description": "Jobs list retrieved successfully"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad request"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "List jobs with cursor pagination",
        "tags": [
          "Jobs"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/jobs/{job_id}": {
      "delete": {
        "description": "Permanently delete an OCR job and all associated data including pages, results, and metadata. This action cannot be undone",
        "operationId": "deleteJob",
        "parameters": [
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "OCR job ID to delete",
            "in": "path",
            "name": "job_id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Job deleted successfully"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad request - invalid job ID"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized - authentication required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Not found - job does not exist or already deleted"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Delete OCR job",
        "tags": [
          "Jobs"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/jobs/{job_id}/retry": {
      "post": {
        "description": "Retry a failed OCR job using the original file. Only jobs with status 'failed' can be retried",
        "operationId": "retryJob",
        "parameters": [
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "OCR job ID to retry",
            "in": "path",
            "name": "job_id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/jobs.JobManagementResponse"
                }
              }
            },
            "description": "Job retry initiated successfully"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad request - invalid job ID"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized - authentication required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Not found - job does not exist"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Conflict - job is not in failed state"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Retry failed OCR job",
        "tags": [
          "Jobs"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/jobs/{job_id}/status": {
      "get": {
        "description": "Get comprehensive job status including database state and Temporal workflow progress information",
        "operationId": "getTeamJobStatus",
        "parameters": [
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "OCR job ID",
            "in": "path",
            "name": "job_id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Include Temporal workflow details",
            "in": "query",
            "name": "include_workflow",
            "schema": {
              "default": false,
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/jobs.JobStatusResponse"
                }
              }
            },
            "description": "Job status retrieved successfully"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad request - invalid job ID"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized - authentication required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Not found - job does not exist"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Get job status with workflow details",
        "tags": [
          "Jobs"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/settings": {
      "get": {
        "description": "Retrieve auto-delete and retention settings for a team",
        "operationId": "getTeamSettings",
        "parameters": [
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "example": "\"123e4567-e89b-12d3-a456-426614174000\"",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/team_settings.TeamSettingsResponse"
                }
              }
            },
            "description": "Team settings retrieved successfully"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad request - invalid parameters"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized - authentication required"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Forbidden - not a member of this team"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Team settings not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Get team settings",
        "tags": [
          "Team Settings"
        ]
      },
      "put": {
        "description": "Update auto-delete and retention settings for a team",
        "operationId": "updateTeamSettings",
        "parameters": [
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "example": "\"123e4567-e89b-12d3-a456-426614174000\"",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/team_settings.UpdateTeamSettingsRequest",
                    "summary": "settings",
                    "description": "Updated settings"
                  }
                ]
              }
            }
          },
          "description": "Updated settings",
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/team_settings.TeamSettingsResponse"
                }
              }
            },
            "description": "Team settings updated successfully"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad request - invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized - authentication required"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Forbidden - not a member of this team"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Update team settings",
        "tags": [
          "Team Settings"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/templates": {
      "get": {
        "description": "Retrieve a paginated list of templates using cursor-based pagination with filtering support",
        "operationId": "listTemplatesCursor",
        "parameters": [
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Cursor for pagination",
            "in": "query",
            "name": "cursor",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Number of items per page",
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 20,
              "maximum": 100,
              "minimum": 1,
              "type": "integer"
            }
          },
          {
            "description": "Filter by template format",
            "in": "query",
            "name": "format",
            "schema": {
              "enum": [
                "markdown",
                "structured"
              ],
              "type": "string"
            }
          },
          {
            "description": "Filter by favorite status",
            "in": "query",
            "name": "favorite",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "description": "Search by template name",
            "in": "query",
            "name": "search",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/templates.TemplatesListCursorResponse"
                }
              }
            },
            "description": "Templates list retrieved successfully"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad request"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "List templates with cursor-based pagination",
        "tags": [
          "Templates"
        ]
      },
      "post": {
        "description": "Create a new template for OCR processing with format, instructions, and schema configuration. Templates provide reusable configurations for document processing with consistent output formatting and validation rules",
        "operationId": "createTemplate",
        "parameters": [
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/templates.CreateTemplateRequest",
                    "summary": "request",
                    "description": "Template creation details including name, format, instructions, and schema"
                  }
                ]
              }
            }
          },
          "description": "Template creation details including name, format, instructions, and schema",
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/templates.TemplateResponse"
                }
              }
            },
            "description": "Template created successfully"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad request - invalid template data or validation failed"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized - authentication required"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Forbidden - insufficient project permissions"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Create OCR processing template",
        "tags": [
          "Templates"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/templates/stats": {
      "get": {
        "description": "Retrieve usage statistics for templates in a specific project",
        "operationId": "getTemplateStats",
        "parameters": [
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/templates.TemplateStatsResponse"
                }
              }
            },
            "description": "Template statistics"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad request"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized - authentication required"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Forbidden - user doesn't have access to the project"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Get template statistics",
        "tags": [
          "Templates"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/templates/{id}": {
      "delete": {
        "description": "Permanently delete a template by its unique identifier",
        "operationId": "deleteTemplate",
        "parameters": [
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Template ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Template deleted successfully"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad request - invalid template ID format"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized - authentication required"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Forbidden - insufficient permissions to delete template"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Template not found or access denied"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Delete OCR processing template",
        "tags": [
          "Templates"
        ]
      },
      "get": {
        "description": "Retrieve a specific template by its unique identifier with complete configuration details",
        "operationId": "getTemplate",
        "parameters": [
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Template ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/templates.TemplateResponse"
                }
              }
            },
            "description": "Template retrieved successfully"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad request - invalid template ID format"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized - authentication required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Template not found or access denied"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Get OCR processing template",
        "tags": [
          "Templates"
        ]
      },
      "put": {
        "description": "Update an existing template configuration including format, instructions, and schema",
        "operationId": "updateTemplate",
        "parameters": [
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Template ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/templates.UpdateTemplateRequest",
                    "summary": "request",
                    "description": "Updated template configuration"
                  }
                ]
              }
            }
          },
          "description": "Updated template configuration",
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/templates.TemplateResponse"
                }
              }
            },
            "description": "Template updated successfully"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad request - invalid template ID format, template data, or validation failed"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized - authentication required"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Forbidden - insufficient permissions to update template"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Template not found or access denied"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Update OCR processing template",
        "tags": [
          "Templates"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/templates/{id}/favorite": {
      "post": {
        "description": "Add or remove a template from favorites. Toggles the current favorite status",
        "operationId": "toggleTemplateFavorite",
        "parameters": [
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Template ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/templates.TemplateResponse"
                }
              }
            },
            "description": "Updated template with toggled favorite status"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad request - invalid template ID format"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized - authentication required"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Forbidden - insufficient permissions"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Template not found or access denied"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Toggle template favorite status",
        "tags": [
          "Templates"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/webhooks": {
      "get": {
        "description": "Retrieve a cursor-paginated list of webhook subscriptions for a team",
        "operationId": "listWebhooksCursor",
        "parameters": [
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Cursor for pagination",
            "in": "query",
            "name": "cursor",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Number of items per page",
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 20,
              "maximum": 100,
              "minimum": 1,
              "type": "integer"
            }
          },
          {
            "description": "Filter by enabled status",
            "in": "query",
            "name": "enabled",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/subscriptions.WebhooksListCursorResponse"
                }
              }
            },
            "description": "Webhook subscriptions list retrieved successfully"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad request"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "List webhook subscriptions with cursor pagination",
        "tags": [
          "Webhooks"
        ]
      },
      "post": {
        "description": "Create a new webhook subscription to receive job events",
        "operationId": "createWebhook",
        "parameters": [
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/subscriptions.CreateWebhookSubscriptionRequest",
                    "summary": "request",
                    "description": "Webhook subscription details"
                  }
                ]
              }
            }
          },
          "description": "Webhook subscription details",
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/subscriptions.WebhookSubscriptionResponse"
                }
              }
            },
            "description": "Webhook subscription created successfully"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad request - invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized - authentication required"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Create webhook subscription",
        "tags": [
          "Webhooks"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/webhooks/events": {
      "get": {
        "description": "Retrieve a cursor-paginated list of webhook delivery events for a team",
        "operationId": "listWebhookEventsCursor",
        "parameters": [
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Cursor for pagination",
            "in": "query",
            "name": "cursor",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Number of items per page",
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 20,
              "maximum": 100,
              "minimum": 1,
              "type": "integer"
            }
          },
          {
            "description": "Filter by subscription ID",
            "in": "query",
            "name": "subscription_id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Filter by event type",
            "in": "query",
            "name": "event_type",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Filter by processing status",
            "in": "query",
            "name": "processing_status",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/events.WebhookEventsListCursorResponse"
                }
              }
            },
            "description": "Webhook events list retrieved successfully"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad request"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "List webhook events with cursor pagination",
        "tags": [
          "Webhooks"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/webhooks/events/{event_id}/payload": {
      "get": {
        "description": "Get enriched payload data for an internal webhook event. For job events, includes current job data if available. Handles deleted resources gracefully.",
        "operationId": "getWebhookEventPayload",
        "parameters": [
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Webhook event ID",
            "in": "path",
            "name": "event_id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/events.WebhookEventPayloadResponse"
                }
              }
            },
            "description": "Enriched webhook event payload"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad request - invalid event ID or not an internal event"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized - authentication required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Not found - webhook event does not exist or access denied"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Get webhook event payload",
        "tags": [
          "Webhooks"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/webhooks/{id}": {
      "delete": {
        "description": "Permanently delete a webhook subscription. This will stop all webhook deliveries to the endpoint",
        "operationId": "deleteWebhook",
        "parameters": [
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Webhook subscription ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Webhook subscription deleted successfully"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized - authentication required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Not found - webhook subscription does not exist"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Delete webhook subscription",
        "tags": [
          "Webhooks"
        ]
      },
      "get": {
        "description": "Get details of a specific webhook subscription",
        "operationId": "getWebhook",
        "parameters": [
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Webhook subscription ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/subscriptions.WebhookSubscriptionResponse"
                }
              }
            },
            "description": "Webhook subscription details"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized - authentication required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Not found - webhook subscription does not exist"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Get webhook subscription",
        "tags": [
          "Webhooks"
        ]
      },
      "put": {
        "description": "Update an existing webhook subscription",
        "operationId": "updateWebhook",
        "parameters": [
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Webhook subscription ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/subscriptions.UpdateWebhookSubscriptionRequest",
                    "summary": "request",
                    "description": "Webhook subscription updates"
                  }
                ]
              }
            }
          },
          "description": "Webhook subscription updates",
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/subscriptions.WebhookSubscriptionResponse"
                }
              }
            },
            "description": "Webhook subscription updated successfully"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad request - invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized - authentication required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Not found - webhook subscription does not exist"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Update webhook subscription",
        "tags": [
          "Webhooks"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/webhooks/{id}/health": {
      "get": {
        "description": "Check if a webhook subscription endpoint is reachable and responding",
        "operationId": "healthCheckWebhook",
        "parameters": [
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Webhook subscription ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": {},
                  "type": "object"
                }
              }
            },
            "description": "Health check result"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized - authentication required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Not found - webhook subscription does not exist"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Health check webhook subscription",
        "tags": [
          "Webhooks"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/webhooks/{id}/regenerate-secret": {
      "post": {
        "description": "Generate a new secret for a webhook subscription. The old secret will immediately stop working",
        "operationId": "regenerateWebhookSecret",
        "parameters": [
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Webhook subscription ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/subscriptions.WebhookSubscriptionResponse"
                }
              }
            },
            "description": "Webhook subscription with new secret"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized - authentication required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Not found - webhook subscription does not exist"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Regenerate webhook secret",
        "tags": [
          "Webhooks"
        ]
      }
    },
    "/organizations/{organization_id}/teams/{team_id}/webhooks/{id}/test": {
      "post": {
        "description": "Send a test webhook event to verify the webhook endpoint is working correctly",
        "operationId": "testWebhook",
        "parameters": [
          {
            "description": "Organization ID",
            "in": "path",
            "name": "organization_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Team ID",
            "in": "path",
            "name": "team_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Webhook subscription ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "Test webhook sent successfully"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized - authentication required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Not found - webhook subscription does not exist"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Test webhook subscription",
        "tags": [
          "Webhooks"
        ]
      }
    },
    "/webhooks/event-types": {
      "get": {
        "description": "Get a list of all supported webhook event types that can be subscribed to",
        "operationId": "getWebhookEventTypes",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/subscriptions.WebhookEventTypesResponse"
                }
              }
            },
            "description": "List of supported webhook event types"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized - authentication required"
          }
        },
        "summary": "Get webhook event types",
        "tags": [
          "Webhooks"
        ]
      }
    },
    "/webhooks/polar": {
      "post": {
        "description": "Process webhook events from Polar billing system with signature verification",
        "operationId": "handlePolarWebhook",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "Webhook processed successfully"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad request - invalid payload or timestamp"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized - signature verification failed"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Handle Polar webhooks",
        "tags": [
          "Webhooks"
        ]
      }
    },
    "/webhooks/r2-upload-notification": {
      "post": {
        "description": "Receive notification from Cloudflare R2 when file upload is complete",
        "parameters": [
          {
            "description": "R2 webhook signature",
            "in": "header",
            "name": "X-R2-Signature",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/webhooks.R2UploadNotification",
                    "summary": "notification",
                    "description": "R2 upload notification"
                  }
                ]
              }
            }
          },
          "description": "R2 upload notification",
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": {
                    "type": "string"
                  },
                  "type": "object"
                }
              }
            },
            "description": "OK"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Bad Request"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/response.ErrorResponse"
                }
              }
            },
            "description": "Internal Server Error"
          }
        },
        "summary": "Handle R2 upload notification",
        "tags": [
          "Webhooks"
        ]
      }
    }
  },
  "openapi": "3.1.0",
  "security": [
    {
      "ApiKeyAuth": []
    },
    {
      "BearerAuth": []
    }
  ],
  "tags": [
    {
      "description": "Authentication and authorization endpoints",
      "name": "Authentication"
    },
    {
      "description": "Core OCR processing endpoints for document text extraction",
      "name": "OCR"
    },
    {
      "description": "Job management and monitoring endpoints",
      "name": "Jobs"
    },
    {
      "description": "Template management for structured data extraction",
      "name": "Templates"
    },
    {
      "description": "Usage analytics and reporting endpoints",
      "name": "Analytics​"
    },
    {
      "description": "Credit management and billing endpoints",
      "name": "Credits"
    },
    {
      "description": "Webhook management and event handling",
      "name": "Webhooks"
    },
    {
      "description": "System health and status endpoints",
      "name": "Health"
    },
    {
      "description": "Demo OCR endpoints for testing without authentication",
      "name": "Demo"
    },
    {
      "description": "File upload endpoints for OCR processing",
      "name": "Upload"
    },
    {
      "description": "SDK-specific endpoints for client libraries",
      "name": "SDK"
    },
    {
      "description": "User onboarding and setup endpoints",
      "name": "onboarding"
    },
    {
      "description": "Team configuration and settings management",
      "name": "Team Settings"
    },
    {
      "description": "API documentation and reference endpoints",
      "name": "Documentation"
    },
    {
      "description": "OCR model information and configuration",
      "name": "Models"
    }
  ],
  "servers": [
    {
      "url": "api.leapocr.com/api/v1"
    },
    {
      "description": "Local development server",
      "url": "http://localhost:8443/api/v1"
    },
    {
      "description": "Production server",
      "url": "https://api.leapocr.com/api/v1"
    }
  ]
}