{
  "openapi": "3.1.0",
  "jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
  "info": {"title": "AMG Data Manager API", "version": "1.0.0", "description": "Contract for src/server.mjs and src/services/reporting.mjs. Operator routes do not enforce session authentication or RBAC. X-Tenant-Id selects tenant context, not authorization. This specification describes handlers, not a certification that migrations match every handler. See documentation for schema mismatches, controlled delivery and unsupported writes."},
  "servers": [{"url": "/"}],
  "paths": {
    "/api/health": {"get": {"operationId": "health", "responses": {"200": {"$ref": "#/components/responses/Json"}}}},
    "/api/v1/bootstrap": {"get": {"operationId": "bootstrap", "description": "Workspace snapshot containing datasets, sources, suppression_lists, buyers, destinations, orders, integrations, data_report, email_domain_report, source_quality_report, analytics_report, posts_report, accounting_report, audit_events, filter_providers, users and lifecycle. Any failed constituent query fails the snapshot.", "responses": {"200": {"description": "Workspace", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Bootstrap"}}}}, "500": {"$ref": "#/components/responses/Error"}}}},
    "/api/v1/ingest": {"post": {"operationId": "ingest", "description": "Modern ingestion. Accepts campaign_id, campaign_uid or CampaignUid and record fields. API key can be X-Api-Key or Bearer token. Idempotency-Key can also be supplied as idempotency_key in the body.", "parameters": [{"$ref": "#/components/parameters/IdempotencyKey"}, {"name": "X-Api-Key", "in": "header", "schema": {"type": "string"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Ingest"}}}}, "responses": {"200": {"$ref": "#/components/responses/Json"}, "201": {"$ref": "#/components/responses/Json"}, "400": {"$ref": "#/components/responses/Error"}, "401": {"$ref": "#/components/responses/Error"}, "409": {"$ref": "#/components/responses/Error"}, "413": {"$ref": "#/components/responses/Error"}, "422": {"$ref": "#/components/responses/Error"}, "429": {"$ref": "#/components/responses/Error"}, "500": {"$ref": "#/components/responses/Error"}}}},
    "/api/record/{campaignUid}": {"parameters": [{"name": "campaignUid", "in": "path", "required": true, "schema": {"type": "string"}}, {"$ref": "#/components/parameters/IdempotencyKey"}], "get": {"operationId": "legacyQueryIngest", "description": "Mutating legacy ingestion through query-string fields. Not a read-only operation.", "parameters": [{"name": "record", "in": "query", "style": "form", "explode": true, "schema": {"type": "object", "additionalProperties": {"type": "string"}}}], "responses": {"200": {"$ref": "#/components/responses/Json"}, "default": {"$ref": "#/components/responses/Json"}}}, "post": {"operationId": "legacyPostIngest", "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Ingest"}}, "application/x-www-form-urlencoded": {"schema": {"$ref": "#/components/schemas/Ingest"}}}}, "responses": {"200": {"$ref": "#/components/responses/Json"}, "default": {"$ref": "#/components/responses/Json"}}}},
    "/api/v1/receipts/{id}": {"parameters": [{"$ref": "#/components/parameters/Id"}], "get": {"operationId": "getReceipt", "responses": {"200": {"$ref": "#/components/responses/Json"}, "404": {"$ref": "#/components/responses/Error"}}}},
    "/api/v1/datasets": {"get": {"operationId": "listDatasets", "responses": {"200": {"$ref": "#/components/responses/Array"}}}, "post": {"operationId": "createDataset", "requestBody": {"content": {"application/json": {"schema": {"type": "object", "required": ["dataset_key", "name"], "properties": {"dataset_key": {"type": "string"}, "name": {"type": "string"}, "description": {"type": "string"}}}}}}, "responses": {"201": {"$ref": "#/components/responses/Json"}, "500": {"$ref": "#/components/responses/Error"}}}},
    "/api/v1/datasets/{id}/versions": {"parameters": [{"$ref": "#/components/parameters/Id"}], "post": {"operationId": "createDraftVersion", "requestBody": {"content": {"application/json": {"schema": {"type": "object", "properties": {"description": {"type": "string"}, "cloneFromVersionId": {"type": ["string", "null"], "format": "uuid"}}}}}}, "responses": {"201": {"$ref": "#/components/responses/Json"}}}},
    "/api/v1/schema-versions/{id}/fields": {"parameters": [{"$ref": "#/components/parameters/Id"}], "post": {"operationId": "addSchemaField", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/SchemaField"}}}}, "responses": {"201": {"$ref": "#/components/responses/Json"}, "500": {"$ref": "#/components/responses/Error"}}}},
    "/api/v1/schema-fields/{id}": {"parameters": [{"$ref": "#/components/parameters/Id"}], "put": {"operationId": "updateSchemaField", "requestBody": {"$ref": "#/components/requestBodies/Object"}, "responses": {"200": {"$ref": "#/components/responses/Json"}}}, "patch": {"operationId": "patchSchemaField", "requestBody": {"$ref": "#/components/requestBodies/Object"}, "responses": {"200": {"$ref": "#/components/responses/Json"}}}, "delete": {"operationId": "deleteSchemaField", "responses": {"200": {"$ref": "#/components/responses/Json"}}}},
    "/api/v1/schema-versions/{id}/publish": {"parameters": [{"$ref": "#/components/parameters/Id"}], "post": {"operationId": "publishSchemaVersion", "responses": {"200": {"$ref": "#/components/responses/Json"}}}},
    "/api/v1/datasets/{id}/activate-version": {"parameters": [{"$ref": "#/components/parameters/Id"}], "post": {"operationId": "activateSchemaVersion", "requestBody": {"content": {"application/json": {"schema": {"type": "object", "required": ["schema_version_id"], "properties": {"schema_version_id": {"type": "string", "format": "uuid"}}}}}}, "responses": {"200": {"$ref": "#/components/responses/Json"}}}},
    "/api/v1/sources": {"get": {"operationId": "listSources", "responses": {"200": {"$ref": "#/components/responses/Array"}}}, "post": {"operationId": "createSource", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/SourceInput"}}}}, "responses": {"201": {"$ref": "#/components/responses/Json"}}}},
    "/api/v1/sources/{id}/sub-sources": {"parameters": [{"$ref": "#/components/parameters/Id"}], "post": {"operationId": "createSubSource", "description": "name, display_id, status, optional dataset_id and schema_version_id. Creates default campaign when dataset/version are available.", "requestBody": {"$ref": "#/components/requestBodies/Object"}, "responses": {"201": {"$ref": "#/components/responses/Json"}}}},
    "/api/v1/sources/{id}/configs": {"parameters": [{"$ref": "#/components/parameters/Id"}], "put": {"operationId": "updateSourceConfigs", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/SourceConfigs"}}}}, "responses": {"200": {"$ref": "#/components/responses/Json"}}}, "post": {"operationId": "postSourceConfigs", "requestBody": {"$ref": "#/components/requestBodies/Object"}, "responses": {"200": {"$ref": "#/components/responses/Json"}}}},
    "/api/v1/sources/{id}/quality-reset": {"parameters": [{"$ref": "#/components/parameters/Id"}], "post": {"operationId": "resetSourceQuality", "description": "Updates last_reset_at and increments reset_count; distinct from rejection configuration.", "responses": {"200": {"$ref": "#/components/responses/Json"}}}},
    "/api/v1/imports/preview": {"post": {"operationId": "previewCsv", "requestBody": {"content": {"application/json": {"schema": {"type": "object", "required": ["csv_text"], "properties": {"csv_text": {"type": "string"}}}}}}, "responses": {"200": {"description": "CSV headers, row count and first five rows", "content": {"application/json": {"schema": {"type": "object", "properties": {"headers": {"type": "array", "items": {"type": "string"}}, "total_rows": {"type": "integer"}, "sample_rows": {"type": "array", "items": {"type": "object"}}}}}}}}}},
    "/api/v1/imports/run": {"post": {"operationId": "runCsvImport", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/CsvImport"}}}}, "responses": {"201": {"$ref": "#/components/responses/Json"}, "500": {"$ref": "#/components/responses/Error"}}}},
    "/api/v1/schedules": {"post": {"operationId": "saveSchedule", "description": "Creates or updates sub-source schedule by id.", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/Schedule"}}}}, "responses": {"201": {"$ref": "#/components/responses/Json"}, "500": {"$ref": "#/components/responses/Error"}}}},
    "/api/v1/schedules/{id}/trigger": {"parameters": [{"$ref": "#/components/parameters/Id"}], "post": {"operationId": "triggerSchedule", "description": "Manual execution, capped to 100 selected records.", "responses": {"200": {"$ref": "#/components/responses/Json"}, "500": {"$ref": "#/components/responses/Error"}}}},
    "/api/v1/suppression-lists": {"get": {"operationId": "listSuppressionLists", "responses": {"200": {"$ref": "#/components/responses/Array"}}}, "post": {"operationId": "createSuppressionList", "description": "Creates a new list. Trims/lowercases inputs; MD5 preserves existing 32-character hex values.", "requestBody": {"content": {"application/json": {"schema": {"type": "object", "required": ["name"], "properties": {"name": {"type": "string"}, "match_field": {"type": "string", "default": "email"}, "value_encoding": {"enum": ["plain", "md5"]}, "values": {"type": "array", "items": {"type": "string"}}}}}}}, "responses": {"201": {"$ref": "#/components/responses/Json"}}}},
    "/api/v1/suppression-lists/{id}/entries": {"parameters": [{"$ref": "#/components/parameters/Id"}], "post": {"operationId": "appendSuppressionEntries", "description": "Appends entries to an existing suppression list.", "requestBody": {"content": {"application/json": {"schema": {"type": "object", "required": ["values"], "properties": {"values": {"type": "array", "items": {"type": "string"}}}}}}}, "responses": {"200": {"$ref": "#/components/responses/Json"}}}},
    "/api/v1/buyers-orders": {"get": {"operationId": "listBuyersOrders", "responses": {"200": {"$ref": "#/components/responses/Json"}}}},
    "/api/v1/buyers": {"post": {"operationId": "createBuyer", "description": "name, display_id and status (Active/Inactive).", "requestBody": {"$ref": "#/components/requestBodies/Object"}, "responses": {"201": {"$ref": "#/components/responses/Json"}}}},
    "/api/v1/destinations": {"post": {"operationId": "createDestination", "description": "buyer_id, name, optional default_integration_id and status.", "requestBody": {"$ref": "#/components/requestBodies/Object"}, "responses": {"201": {"$ref": "#/components/responses/Json"}}}},
    "/api/v1/destinations/{id}/advanced-settings": {"parameters": [{"$ref": "#/components/parameters/Id"}], "put": {"operationId": "updateAdvancedSettings", "description": "Handler field names differ from migration 0002. The UI submits handler names; backend alignment is required before successful saves can be claimed.", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/AdvancedSettings"}}}}, "responses": {"200": {"$ref": "#/components/responses/Json"}, "500": {"$ref": "#/components/responses/Error"}}}, "post": {"operationId": "postAdvancedSettings", "requestBody": {"$ref": "#/components/requestBodies/Object"}, "responses": {"200": {"$ref": "#/components/responses/Json"}, "500": {"$ref": "#/components/responses/Error"}}}},
    "/api/v1/orders": {"post": {"operationId": "saveOrder", "description": "Creates order or new sealed revision for existing id. Nested inputs, excluded_sub_sources, destinations, rules are written. Parameter definitions are not written by this handler.", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/OrderInput"}}}}, "responses": {"201": {"$ref": "#/components/responses/Json"}, "500": {"$ref": "#/components/responses/Error"}}}},
    "/api/v1/orders/{id}/copy": {"parameters": [{"$ref": "#/components/parameters/Id"}], "post": {"operationId": "copyOrder", "requestBody": {"content": {"application/json": {"schema": {"type": "object", "properties": {"name": {"type": "string"}}}}}}, "responses": {"201": {"$ref": "#/components/responses/Json"}}}},
    "/api/v1/orders/{id}/replay": {"parameters": [{"$ref": "#/components/parameters/Id"}], "post": {"operationId": "replayOrder", "description": "Evaluates existing records, not new ingestions. Selection limit is bounded by configured generation_rate_per_min or 50.", "requestBody": {"content": {"application/json": {"schema": {"type": "object", "properties": {"limit": {"type": "integer", "default": 25, "minimum": 1}}}}}}, "responses": {"200": {"$ref": "#/components/responses/Json"}}}},
    "/api/v1/integrations": {"get": {"operationId": "listIntegrations", "responses": {"200": {"$ref": "#/components/responses/Array"}}}, "post": {"operationId": "saveIntegration", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/IntegrationInput"}}}}, "responses": {"201": {"$ref": "#/components/responses/Json"}, "422": {"$ref": "#/components/responses/Json"}}}},
    "/api/v1/integrations/test": {"post": {"operationId": "testIntegration", "description": "Renders stored integration version and invokes the controlled receiver in-process; does not send arbitrary external HTTP requests.", "requestBody": {"content": {"application/json": {"schema": {"type": "object", "required": ["integration_version_id"], "properties": {"integration_version_id": {"type": "string", "format": "uuid"}, "test_record": {"type": "object"}, "order_params": {"type": "object"}, "simulate_outcome": {"type": ["string", "null"]}}}}}}, "responses": {"200": {"$ref": "#/components/responses/Json"}}}},
    "/api/v1/reports/data": {"get": {"operationId": "dataReport", "parameters": [{"$ref": "#/components/parameters/Search"}, {"name": "sub_source_id", "in": "query", "schema": {"type": "string"}}, {"name": "order_id", "in": "query", "schema": {"type": "string"}}, {"name": "group_by", "in": "query", "schema": {"enum": ["none", "source_sub_source", "buyer_order"]}}, {"name": "csv_timezone", "in": "query", "schema": {"type": "string", "default": "UTC"}}], "description": "Active lifecycle records only. Search/sub-source/order filters affect records. Invalid-request counter and outgoing summary are tenant-wide. No date-range parameters are implemented.", "responses": {"200": {"$ref": "#/components/responses/Json"}}}},
    "/api/v1/reports/data/csv": {"get": {"operationId": "downloadDataCsv", "description": "Same filtering as data report; columns is comma-separated record property names. Date range is not implemented.", "parameters": [{"$ref": "#/components/parameters/Search"}, {"name": "columns", "in": "query", "schema": {"type": "string"}}, {"name": "sub_source_id", "in": "query", "schema": {"type": "string"}}, {"name": "order_id", "in": "query", "schema": {"type": "string"}}, {"name": "csv_timezone", "in": "query", "schema": {"type": "string", "default": "UTC"}}], "responses": {"200": {"description": "CSV attachment", "content": {"text/csv": {"schema": {"type": "string"}}}}}}},
    "/api/v1/reports/email-domains": {"get": {"operationId": "emailDomainReport", "responses": {"200": {"$ref": "#/components/responses/Array"}}}},
    "/api/v1/reports/source-quality": {"get": {"operationId": "sourceQualityReport", "responses": {"200": {"$ref": "#/components/responses/Array"}}}},
    "/api/v1/reports/analytics": {"get": {"operationId": "analyticsReport", "description": "Buyer/order tree, pairwise overlaps and identity_formula_disclosure. Actual identity expression is lower(COALESCE(email, phone_cell, record UUID)).", "responses": {"200": {"$ref": "#/components/responses/Json"}}}},
    "/api/v1/reports/posts": {"get": {"operationId": "postsReport", "parameters": [{"name": "buyer_id", "in": "query", "schema": {"type": "string"}}, {"name": "order_id", "in": "query", "schema": {"type": "string"}}, {"name": "status", "in": "query", "description": "Case-insensitive substring of status badge", "schema": {"type": "string"}}], "responses": {"200": {"$ref": "#/components/responses/Json"}}}},
    "/api/v1/reports/accounting": {"get": {"operationId": "accountingReport", "parameters": [{"name": "year", "in": "query", "schema": {"type": "integer", "default": 2026}}, {"name": "month", "in": "query", "schema": {"type": "integer", "minimum": 1, "maximum": 12, "default": 10}}], "responses": {"200": {"$ref": "#/components/responses/Json"}}}},
    "/api/v1/reports/accounting/price-rules": {"post": {"operationId": "savePriceRule", "description": "Deactivates prior rules in category. Cost dollars = quantity * unit_price_mills / 100000, despite field name.", "requestBody": {"content": {"application/json": {"schema": {"type": "object", "required": ["direction", "category", "unit_price_mills"], "properties": {"direction": {"enum": ["ingress", "egress"]}, "category": {"enum": ["realtime_failed", "realtime_ok", "realtime_total", "offline_data_imports", "realtime_posts", "offline_data_posts", "historical_posts"]}, "counting_unit": {"type": "string", "default": "unit"}, "unit_price_mills": {"type": "number"}, "notes": {"type": "string"}}}}}}, "responses": {"201": {"$ref": "#/components/responses/Json"}}}},
    "/api/v1/reports/audit": {"get": {"operationId": "auditEvents", "description": "Latest 200 events; query arguments currently ignored.", "responses": {"200": {"$ref": "#/components/responses/Array"}}}},
    "/api/v1/settings/filters": {"get": {"operationId": "filterProviders", "responses": {"200": {"$ref": "#/components/responses/Json"}}}},
    "/api/v1/settings/filters/{providerKey}": {"parameters": [{"name": "providerKey", "in": "path", "required": true, "schema": {"enum": ["blacklist_alliance", "email_oversight_phone", "email_oversight_email", "list_certified", "brite_verify", "impression_wise", "zero_bounce"]}}], "put": {"operationId": "updateFilterProvider", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/FilterConfig"}}}}, "responses": {"200": {"$ref": "#/components/responses/Json"}}}, "post": {"operationId": "postFilterProvider", "requestBody": {"$ref": "#/components/requestBodies/Object"}, "responses": {"200": {"$ref": "#/components/responses/Json"}}}},
    "/api/v1/users": {"get": {"operationId": "listUsers", "responses": {"200": {"$ref": "#/components/responses/Array"}}}, "post": {"operationId": "saveUser", "description": "Upsert by tenant/email, not id. Existing password is not updated. No role authorization middleware is enforced by server.mjs.", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserInput"}}}}, "responses": {"201": {"$ref": "#/components/responses/Json"}, "500": {"$ref": "#/components/responses/Error"}}}},
    "/api/v1/lifecycle": {"get": {"operationId": "lifecycleOverview", "description": "policy, state_counts, archive_manifests, restore_events, and backup_snapshots.", "responses": {"200": {"$ref": "#/components/responses/Json"}}}},
    "/api/v1/lifecycle/policy": {"put": {"operationId": "updateRetentionPolicy", "requestBody": {"$ref": "#/components/requestBodies/Object"}, "responses": {"200": {"$ref": "#/components/responses/Json"}}}, "post": {"operationId": "postRetentionPolicy", "requestBody": {"$ref": "#/components/requestBodies/Object"}, "responses": {"200": {"$ref": "#/components/responses/Json"}}}},
    "/api/v1/lifecycle/archive": {"post": {"operationId": "archiveRecord", "requestBody": {"content": {"application/json": {"schema": {"type": "object", "required": ["lead_record_id"], "properties": {"lead_record_id": {"type": "string", "format": "uuid"}, "actor_label": {"type": "string"}}}}}}, "responses": {"201": {"$ref": "#/components/responses/Json"}, "500": {"$ref": "#/components/responses/Error"}}}},
    "/api/v1/lifecycle/restore": {"post": {"operationId": "restoreRecordHeld", "description": "Changes lifecycle to restored_held; does not rebuild deleted lead rows or send deliveries. Returns before/after attempt counts.", "requestBody": {"content": {"application/json": {"schema": {"type": "object", "required": ["manifest_id"], "properties": {"manifest_id": {"type": "string", "format": "uuid"}, "actor_label": {"type": "string"}}}}}}, "responses": {"200": {"$ref": "#/components/responses/Json"}, "500": {"$ref": "#/components/responses/Error"}}}}
  },
  "components": {
    "parameters": {
      "Id": {"name": "id", "in": "path", "required": true, "schema": {"type": "string", "format": "uuid"}},
      "Tenant": {"name": "X-Tenant-Id", "in": "header", "description": "Optional on API routes. Defaults to 11111111-1111-4111-8111-111111111111; not proof of authorization.", "schema": {"type": "string", "format": "uuid"}},
      "IdempotencyKey": {"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}},
      "Search": {"name": "search", "in": "query", "schema": {"type": "string"}}
    },
    "requestBodies": {"Object": {"content": {"application/json": {"schema": {"type": "object", "additionalProperties": true}}}}},
    "responses": {
      "Json": {"description": "Handler-specific persisted result", "content": {"application/json": {"schema": {"type": "object", "additionalProperties": true}}}},
      "Array": {"description": "Persisted rows with handler enrichment", "content": {"application/json": {"schema": {"type": "array", "items": {"type": "object", "additionalProperties": true}}}}},
      "Error": {"description": "Request failure; uncaught service/database exceptions return 500 InternalServerError with message", "content": {"application/json": {"schema": {"type": "object", "properties": {"error": {"type": "string"}, "message": {"type": "string"}}, "additionalProperties": true}}}}
    },
    "schemas": {
      "Bootstrap": {"type": "object", "required": ["datasets", "sources", "buyers", "orders", "data_report", "lifecycle"], "properties": {"datasets": {"type": "array", "items": {"type": "object"}}, "sources": {"type": "array", "items": {"type": "object"}}, "suppression_lists": {"type": "array", "items": {"type": "object"}}, "buyers": {"type": "array", "items": {"type": "object"}}, "destinations": {"type": "array", "items": {"type": "object"}}, "orders": {"type": "array", "items": {"type": "object"}}, "integrations": {"type": "array", "items": {"type": "object"}}, "data_report": {"type": "object"}, "email_domain_report": {"type": "array", "items": {"type": "object"}}, "source_quality_report": {"type": "array", "items": {"type": "object"}}, "analytics_report": {"type": "object"}, "posts_report": {"type": "object"}, "accounting_report": {"type": "object"}, "audit_events": {"type": "array", "items": {"type": "object"}}, "filter_providers": {"type": "object"}, "users": {"type": "array", "items": {"type": "object"}}, "lifecycle": {"type": "object"}}},
      "Ingest": {"type": "object", "properties": {"campaign_id": {"type": "string", "format": "uuid"}, "campaign_uid": {"type": "string"}, "CampaignUid": {"type": "string"}, "idempotency_key": {"type": "string"}, "FirstName": {"type": "string"}, "LastName": {"type": "string"}, "Email": {"type": "string"}, "PhoneCell": {"type": "string"}, "LeadUid": {"type": ["string", "number"]}, "custom_fields": {"type": "object"}}, "additionalProperties": true},
      "SchemaField": {"type": "object", "required": ["field_key"], "properties": {"field_key": {"type": "string"}, "display_name": {"type": "string"}, "storage_location": {"enum": ["core", "custom"]}, "value_type": {"enum": ["text", "number", "integer", "boolean", "date", "timestamp", "object", "array"]}, "is_required": {"type": "boolean", "default": false}, "description": {"type": "string"}}},
      "SourceInput": {"type": "object", "required": ["name"], "properties": {"name": {"type": "string"}, "display_id": {"type": "string"}, "status": {"enum": ["Active", "Inactive"]}, "default_dataset_id": {"type": "string", "format": "uuid"}, "default_schema_version_id": {"type": "string", "format": "uuid"}}},
      "SourceConfigs": {"type": "object", "properties": {"rejection_config": {"type": "object", "properties": {"exists_in_list_enabled": {"type": "boolean"}, "duplicated_enabled": {"type": "boolean"}, "duplicate_scope": {"enum": ["in_system", "in_source", "in_sub_source"]}, "match_by": {"enum": ["email", "phone"]}, "interval_value": {"type": "integer"}, "interval_type": {"type": "string"}}}, "quality_config": {"type": "object", "properties": {"dups_depth_value": {"type": "integer"}, "dups_depth_type": {"type": "string"}}}}},
      "CsvImport": {"type": "object", "required": ["source_id", "sub_source_id", "csv_text"], "properties": {"source_id": {"type": "string"}, "sub_source_id": {"type": "string"}, "dataset_id": {"type": ["string", "null"]}, "schema_version_id": {"type": ["string", "null"]}, "file_name": {"type": "string"}, "uploaded_by": {"type": "string"}, "csv_text": {"type": "string"}, "field_mapping": {"type": "object", "additionalProperties": {"type": "string"}}, "resume_job_id": {"type": ["string", "null"]}, "simulate_interrupt_at_row": {"type": ["integer", "null"]}}},
      "Schedule": {"type": "object", "required": ["source_id", "sub_source_id"], "properties": {"id": {"type": "string"}, "source_id": {"type": "string"}, "sub_source_id": {"type": "string"}, "name": {"type": "string"}, "daily_amount": {"type": "integer", "minimum": 1}, "deviation": {"type": "integer", "minimum": 0}, "recurrence": {"type": "string"}, "start_date": {"type": "string", "format": "date"}, "weekdays": {"type": "array", "items": {"type": "integer", "minimum": 0, "maximum": 6}}, "ends_mode": {"type": "string", "description": "Handler branches on never/after; migration enum is never/on_date/after_occurrences."}, "ends_on_date": {"type": ["string", "null"]}, "ends_after_occurrences": {"type": ["integer", "null"]}, "status": {"type": "string"}}},
      "AdvancedSettings": {"type": "object", "properties": {"max_posts_per_second": {"type": "integer"}, "rate_limiter_buffer_size": {"type": ["number", "string"]}, "can_be_suspended": {"type": "boolean"}, "consecutive_failures_limit": {"type": "integer"}, "failure_pct_timeframe_value": {"type": "number"}, "failure_pct_timeframe_unit": {"type": "string"}, "min_requests_for_pct": {"type": "integer"}, "failure_pct_threshold": {"type": "number"}, "initial_suspension_value": {"type": "number"}, "initial_suspension_unit": {"type": "string"}, "suspension_window_multiplier": {"type": "number"}, "max_suspension_value": {"type": "number"}, "max_suspension_unit": {"type": "string"}, "resume_successes_count": {"type": "integer"}, "circuit_state": {"enum": ["closed", "open", "half_open"]}, "suspended_until": {"type": ["string", "null"]}}},
      "OrderInput": {"type": "object", "properties": {"id": {"type": "string"}, "buyer_id": {"type": "string"}, "name": {"type": "string"}, "display_id": {"type": "string"}, "status": {"type": "string"}, "processing_mode": {"type": "string"}, "distribution_strategy": {"type": "string"}, "cap_limit": {"type": "integer"}, "cap_period": {"type": "string"}, "cap_basis": {"type": "string"}, "cap_timezone": {"type": "string"}, "price_cents": {"type": "integer"}, "condition_label": {"type": "string"}, "delay_value": {"type": "number"}, "delay_unit": {"type": "string"}, "delay_type": {"type": "string"}, "is_exclusive": {"type": "boolean"}, "input_selection_mode": {"enum": ["include", "exclude"]}, "generation_rate_per_min": {"type": ["integer", "null"]}, "weekday_caps_config": {"type": "array", "items": {"type": "object"}}, "inputs": {"type": "array", "items": {"type": "object", "properties": {"source_id": {"type": "string"}, "sub_source_id": {"type": ["string", "null"]}}}}, "excluded_sub_sources": {"type": "array", "items": {"type": "object"}}, "destinations": {"type": "array", "items": {"type": "object", "properties": {"destination_id": {"type": "string"}, "integration_version_id": {"type": "string"}, "non_secret_parameters": {"type": "object"}}}}, "rules": {"type": "array", "items": {"type": "object", "properties": {"name": {"type": "string"}, "kind": {"type": "string"}, "non_secret_config": {"type": "object"}, "failure_action": {"type": "string"}}}}}},
      "IntegrationInput": {"type": "object", "required": ["endpoint_template"], "properties": {"integration_id": {"type": "string"}, "name": {"type": "string"}, "http_method": {"type": "string"}, "endpoint_template": {"type": "string"}, "non_secret_headers": {"type": "object"}, "body_template": {"type": ["string", "null"]}, "credential_ref": {"type": ["string", "null"]}, "response_rules": {"type": "object"}, "body_format": {"enum": ["JSON", "XML", "Form-UrlEncoded"]}, "content_type": {"type": "string"}, "required_data_params": {"type": "array"}, "order_param_defs": {"type": "array"}, "used_fields_summary": {"type": "array"}, "created_at_format": {"type": "string"}, "created_at_timezone": {"type": "string"}, "unsubscribe_mode": {"enum": ["none", "unsubscribe_params", "default_unsubscribe_params"]}, "unsubscribe_params": {"type": "object"}}},
      "FilterConfig": {"type": "object", "properties": {"enabled": {"type": "boolean"}, "use_cache": {"type": "boolean"}, "cache_ttl_value": {"type": "integer"}, "cache_ttl_unit": {"enum": ["Minutes", "Hours", "Days"]}, "failure_behavior": {"enum": ["pass", "skip"]}, "enable_notifications": {"type": "boolean"}, "min_failure_pct": {"type": "number"}, "min_failure_count": {"type": "integer"}, "failure_window_minutes": {"type": "integer"}, "suppress_repeat_hours": {"type": "integer"}, "credential_mode": {"enum": ["my_credentials", "system_credentials"]}, "adapter_mode": {"enum": ["unconfigured", "controlled_adapter", "live_configured"]}}},
      "UserInput": {"type": "object", "required": ["email", "full_name"], "properties": {"id": {"type": "string"}, "email": {"type": "string", "format": "email"}, "full_name": {"type": "string"}, "password": {"type": "string", "writeOnly": true}, "role": {"enum": ["owner", "admin", "operator", "read_only"]}, "status": {"enum": ["Active", "Inactive"]}, "timezone": {"type": "string"}}}
    }
  }
}
