{"openapi":"3.1.0","info":{"title":"Baugesuche platform","description":"Lead intelligence: Zefix ingest, enrichment, canonical Postgres storage, exports. ``GET /`` is HTML or JSON (see root description); ``GET /health`` (liveness) and ``GET /ready`` (DB readiness) are unauthenticated; all other routes require ``X-API-Key`` (except OpenAPI static routes ``/docs``, ``/redoc``, ``/openapi.json``). ``POST /runs`` requires a JSON body with ``source_type`` (e.g. ``zefix_sogc``); see the ``RunCreate`` schema in ``/docs`` for optional canton / lookback fields. Run‑scoped resources: ``GET /runs/{run_id}/leads`` (leads for one run), ``GET /runs/{run_id}/artifacts`` (export file rows), and ``GET /runs/{run_id}`` includes ``lead_counts``, ``drop_reason_counts``, and ``links`` (including ``/exclusions``). ``GET /dashboard/`` serves a static **operator dashboard** (tables + charts; optional ``X-API-Key`` in page).","version":"0.2.0"},"paths":{"/":{"get":{"summary":"Root","description":"API root: **HTML** for typical browser clients (``text/html`` or ``*/*`` in ``Accept``); **JSON** when\n``?format=json``, ``Accept`` is empty (common curl default), or the client clearly asks for\n``application/json`` first.","operationId":"root__get","parameters":[{"name":"format","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Format"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/health":{"get":{"tags":["health"],"summary":"Health","description":"Liveness: process is up (no dependency checks).","operationId":"health_health_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":{"type":"string"},"type":"object","title":"Response Health Health Get"}}}}}}},"/ready":{"get":{"tags":["health"],"summary":"Ready","description":"Readiness: PostgreSQL is reachable (``SELECT 1``).\n\nUse for Kubernetes **readinessProbe** / load-balancer health that should fail when the DB is down.\nDoes **not** verify Redis or the worker (see ``docs/PRODUCTION.md``).","operationId":"ready_ready_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/feedback/{token}":{"get":{"tags":["feedback"],"summary":"Record Lead Feedback","operationId":"record_lead_feedback_feedback__token__get","parameters":[{"name":"token","in":"path","required":true,"schema":{"type":"string","title":"Token"}},{"name":"json","in":"query","required":false,"schema":{"type":"integer","maximum":1,"minimum":0,"default":0,"title":"Json"}},{"name":"inline","in":"query","required":false,"schema":{"type":"integer","maximum":1,"minimum":0,"default":0,"title":"Inline"}}],"responses":{"200":{"description":"Successful Response","content":{"text/html":{"schema":{"type":"string"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/runs":{"get":{"tags":["runs"],"summary":"List Runs","operationId":"list_runs_runs_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"limit","in":"query","required":false,"schema":{"type":"integer","default":50,"title":"Limit"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/RunOut"},"title":"Response List Runs Runs Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"post":{"tags":["runs"],"summary":"Create a pipeline run","description":"Requires a JSON body with **``source_type``** (see ``RunCreate``). Supported ingest values: **``zefix_sogc``**. Optional fields **``canton``**, **``cantons``**, **``lookback_days``**, **``legal_form``** are merged into **``config_snapshot``**.\n\nMissing or invalid fields yield **422** (validation). Unsupported **``source_type``** yields **400**.\n\nOn success: **201** with the run row. If **``RUN_SYNC_IN_API``** is true and the pipeline fails (e.g. Zefix credentials), the response is still **201** with **``status``** often **``failed``** and **``error_summary``** set — check the run object rather than HTTP 5xx.","operationId":"create_run_runs_post","security":[{"APIKeyHeader":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RunCreate"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RunOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/runs/{run_id}/execute":{"post":{"tags":["runs"],"summary":"Execute Run","description":"Run or re-queue the pipeline for a **pending** or **failed** run.\n\n\n\nIf ``RUN_SYNC_IN_API`` is true (default for local dev), runs synchronously.\n\nIf false, enqueues Redis/RQ — a **worker process** must be running (`python -m app.workers.cli`).\n\n\n\n**409** if status is ``running`` and ``force`` is false — use **``?force=true``** or **POST /runs/{id}/execute-force**.","operationId":"execute_run_runs__run_id__execute_post","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"run_id","in":"path","required":true,"schema":{"type":"integer","title":"Run Id"}},{"name":"force","in":"query","required":false,"schema":{"type":"boolean","description":"If true and status is `running`, reset the run to `failed` first (use when a previous execution crashed, you restarted Uvicorn, or the run is stuck in `running`). In Swagger UI, set this field to `true` (or use POST /runs/{id}/execute-force).","default":false,"title":"Force"},"description":"If true and status is `running`, reset the run to `failed` first (use when a previous execution crashed, you restarted Uvicorn, or the run is stuck in `running`). In Swagger UI, set this field to `true` (or use POST /runs/{id}/execute-force)."}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RunOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/runs/{run_id}/execute-force":{"post":{"tags":["runs"],"summary":"Execute Run Force Stuck","description":"Same as ``POST /runs/{id}/execute?force=true`` — no query parameters.\n\n\n\nUse when a run is stuck in ``running`` after a crash or Ctrl+C; avoids toggling ``force`` in Swagger.","operationId":"execute_run_force_stuck_runs__run_id__execute_force_post","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"run_id","in":"path","required":true,"schema":{"type":"integer","title":"Run Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RunOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/runs/{run_id}/leads":{"get":{"tags":["runs"],"summary":"List leads for this run","description":"List leads for a single pipeline run (run‑scoped alias of ``GET /leads?run_id=…``).\n\nReturns the same ``LeadOut`` list as the top‑level leads collection; query parameters\nmatch ``GET /leads`` except ``run_id`` is taken from the path. **404** if the run id\ndoes not exist.","operationId":"runs_list_leads_runs__run_id__leads_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"run_id","in":"path","required":true,"schema":{"type":"integer","title":"Run Id"}},{"name":"status","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Status"}},{"name":"canton","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Canton"}},{"name":"suppressed","in":"query","required":false,"schema":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Suppressed"}},{"name":"source_type","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source Type"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":2000,"default":200,"title":"Limit"}},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"default":0,"title":"Offset"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/LeadOut"},"title":"Response Runs List Leads Runs  Run Id  Leads Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/runs/{run_id}/artifacts":{"get":{"tags":["runs"],"summary":"List export artifacts for this run","description":"Export artifacts (CSV/CRM paths) for this run.\n\nSame ``ExportArtifactOut`` rows as the ``export_artifacts`` field on ``GET /runs/{run_id}``,\nexposed as a dedicated resource for navigation. **404** if the run id does not exist.","operationId":"runs_list_artifacts_runs__run_id__artifacts_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"run_id","in":"path","required":true,"schema":{"type":"integer","title":"Run Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ExportArtifactOut"},"title":"Response Runs List Artifacts Runs  Run Id  Artifacts Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/runs/{run_id}/exclusions":{"get":{"tags":["runs"],"summary":"List dropped leads (exclusions) for this run","description":"Leads with ``status == 'dropped'`` for this run, including ``drop_reason`` for audits.\nSame filtering as ``GET /leads?run_id=&status=dropped`` but scoped to the path. **404** if the run does not exist.","operationId":"runs_list_exclusions_runs__run_id__exclusions_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"run_id","in":"path","required":true,"schema":{"type":"integer","title":"Run Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ExcludedLeadOut"},"title":"Response Runs List Exclusions Runs  Run Id  Exclusions Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/runs/{run_id}":{"get":{"tags":["runs"],"summary":"Get Run","description":"Run detail: status, timing, ``metrics_json``, ``error_summary``, ``config_snapshot``,\n``export_artifacts``, **``lead_counts``** (status breakdown + ``total``), **``drop_reason_counts``**\n(dropped leads by ``drop_reason``), and **``links``** (paths to nested ``/leads``, ``/artifacts``, ``/exclusions``).","operationId":"get_run_runs__run_id__get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"run_id","in":"path","required":true,"schema":{"type":"integer","title":"Run Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RunDetailOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/leads":{"get":{"tags":["leads"],"summary":"List leads","operationId":"list_leads_leads_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"run_id","in":"query","required":false,"schema":{"anyOf":[{"type":"integer"},{"type":"null"}],"description":"Filter by **pipeline run id** (same id as `GET /runs/{id}`). Use this to list all leads produced by run 5 — do **not** use `GET /leads/5` for that.","title":"Run Id"},"description":"Filter by **pipeline run id** (same id as `GET /runs/{id}`). Use this to list all leads produced by run 5 — do **not** use `GET /leads/5` for that."},{"name":"status","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Status"}},{"name":"canton","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Canton"}},{"name":"suppressed","in":"query","required":false,"schema":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Suppressed"}},{"name":"source_type","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source Type"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":2000,"default":200,"title":"Limit"}},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"default":0,"title":"Offset"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/LeadOut"},"title":"Response List Leads Leads Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/leads/{lead_id}":{"get":{"tags":["leads"],"summary":"Get one lead by primary key","operationId":"get_lead_leads__lead_id__get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"lead_id","in":"path","required":true,"schema":{"type":"integer","description":"**Leads table** primary key (auto-increment). This is **not** the run id. Example: run 5 may have leads with ids 87, 88, … — use `GET /leads?run_id=5` to find them.","title":"Lead Id"},"description":"**Leads table** primary key (auto-increment). This is **not** the run id. Example: run 5 may have leads with ids 87, 88, … — use `GET /leads?run_id=5` to find them."}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeadOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/clients/{client_id}/deliveries":{"get":{"tags":["clients"],"summary":"List Client Deliveries","operationId":"list_client_deliveries_clients__client_id__deliveries_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"client_id","in":"path","required":true,"schema":{"type":"integer","title":"Client Id"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":2000,"minimum":1,"default":200,"title":"Limit"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ClientDeliveryOut"},"title":"Response List Client Deliveries Clients  Client Id  Deliveries Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/clients/{client_id}/deliveries.csv":{"get":{"tags":["clients"],"summary":"List Client Deliveries Csv","operationId":"list_client_deliveries_csv_clients__client_id__deliveries_csv_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"client_id","in":"path","required":true,"schema":{"type":"integer","title":"Client Id"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":2000,"minimum":1,"default":200,"title":"Limit"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/clients/{client_id}/suppressions":{"post":{"tags":["clients"],"summary":"Upload Client Suppressions","operationId":"upload_client_suppressions_clients__client_id__suppressions_post","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"client_id","in":"path","required":true,"schema":{"type":"integer","title":"Client Id"}},{"name":"reason","in":"query","required":false,"schema":{"type":"string","description":"Reason stored on new suppression rows","default":"crm_import","title":"Reason"},"description":"Reason stored on new suppression rows"}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_upload_client_suppressions_clients__client_id__suppressions_post"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ClientSuppressionOut"},"title":"Response Upload Client Suppressions Clients  Client Id  Suppressions Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"get":{"tags":["clients"],"summary":"List Client Suppressions","operationId":"list_client_suppressions_clients__client_id__suppressions_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"client_id","in":"path","required":true,"schema":{"type":"integer","title":"Client Id"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":2000,"minimum":1,"default":200,"title":"Limit"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ClientSuppressionOut"},"title":"Response List Client Suppressions Clients  Client Id  Suppressions Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/clients/{client_id}/value-report":{"get":{"tags":["clients"],"summary":"Client Value Report","operationId":"client_value_report_clients__client_id__value_report_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"client_id","in":"path","required":true,"schema":{"type":"integer","title":"Client Id"}},{"name":"from","in":"query","required":true,"schema":{"type":"string","format":"date","title":"From"}},{"name":"to","in":"query","required":true,"schema":{"type":"string","format":"date","title":"To"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ClientValueReportOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/clients/{client_id}/value-report.csv":{"get":{"tags":["clients"],"summary":"Client Value Report Csv","operationId":"client_value_report_csv_clients__client_id__value_report_csv_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"client_id","in":"path","required":true,"schema":{"type":"integer","title":"Client Id"}},{"name":"from","in":"query","required":true,"schema":{"type":"string","format":"date","title":"From"}},{"name":"to","in":"query","required":true,"schema":{"type":"string","format":"date","title":"To"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/suppressions":{"post":{"tags":["suppressions"],"summary":"Create Suppression","operationId":"create_suppression_suppressions_post","security":[{"APIKeyHeader":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuppressionCreate"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuppressionOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"get":{"tags":["suppressions"],"summary":"List Suppressions","operationId":"list_suppressions_suppressions_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"active_only","in":"query","required":false,"schema":{"type":"boolean","default":true,"title":"Active Only"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","default":500,"title":"Limit"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/SuppressionOut"},"title":"Response List Suppressions Suppressions Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/suppressions/{suppression_id}":{"delete":{"tags":["suppressions"],"summary":"Deactivate Suppression","operationId":"deactivate_suppression_suppressions__suppression_id__delete","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"suppression_id","in":"path","required":true,"schema":{"type":"integer","title":"Suppression Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuppressionOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/exports/{run_id}":{"post":{"tags":["exports"],"summary":"Trigger Export","operationId":"trigger_export_exports__run_id__post","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"run_id","in":"path","required":true,"schema":{"type":"integer","title":"Run Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Trigger Export Exports  Run Id  Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/processing-registry":{"get":{"tags":["compliance"],"summary":"List Processing Registry","operationId":"list_processing_registry_processing_registry_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"additionalProperties":true,"type":"object"},"type":"array","title":"Response List Processing Registry Processing Registry Get"}}}}},"security":[{"APIKeyHeader":[]}]}}},"components":{"schemas":{"Body_upload_client_suppressions_clients__client_id__suppressions_post":{"properties":{"file":{"type":"string","contentMediaType":"application/octet-stream","title":"File"}},"type":"object","required":["file"],"title":"Body_upload_client_suppressions_clients__client_id__suppressions_post"},"ClientDeliveryOut":{"properties":{"client_id":{"type":"integer","title":"Client Id"},"client_name":{"type":"string","title":"Client Name"},"zefix_uid":{"type":"string","title":"Zefix Uid"},"lead_company_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Lead Company Name"},"run_id":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Run Id"},"delivered_at":{"type":"string","format":"date-time","title":"Delivered At"}},"type":"object","required":["client_id","client_name","zefix_uid","delivered_at"],"title":"ClientDeliveryOut"},"ClientMetaOut":{"properties":{"id":{"type":"integer","title":"Id"},"name":{"type":"string","title":"Name"}},"type":"object","required":["id","name"],"title":"ClientMetaOut"},"ClientSuppressionOut":{"properties":{"id":{"type":"integer","title":"Id"},"client_id":{"type":"integer","title":"Client Id"},"company_uid":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Company Uid"},"domain":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Domain"},"email_hash":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Email Hash"},"reason":{"type":"string","title":"Reason"},"active":{"type":"boolean","title":"Active"},"created_at":{"type":"string","format":"date-time","title":"Created At"}},"type":"object","required":["id","client_id","company_uid","domain","email_hash","reason","active","created_at"],"title":"ClientSuppressionOut"},"ClientValueMetricsOut":{"properties":{"delivered_count":{"type":"integer","title":"Delivered Count","default":0},"dedupe_prevented_count":{"type":"integer","title":"Dedupe Prevented Count","default":0},"suppressed_count":{"type":"integer","title":"Suppressed Count","default":0},"dropped_count":{"type":"integer","title":"Dropped Count","default":0},"avg_quality_score":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Avg Quality Score"},"runs_in_period":{"type":"integer","title":"Runs In Period","default":0}},"type":"object","title":"ClientValueMetricsOut"},"ClientValueReportOut":{"properties":{"client":{"$ref":"#/components/schemas/ClientMetaOut"},"period":{"$ref":"#/components/schemas/PeriodOut"},"metrics":{"$ref":"#/components/schemas/ClientValueMetricsOut"}},"type":"object","required":["client","period","metrics"],"title":"ClientValueReportOut"},"ExcludedLeadOut":{"properties":{"id":{"type":"integer","title":"Id"},"run_id":{"type":"integer","title":"Run Id"},"company_uid":{"type":"string","title":"Company Uid"},"company_name":{"type":"string","title":"Company Name"},"canton":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Canton"},"legal_form":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Legal Form"},"website_confidence_score":{"anyOf":[{"type":"integer","maximum":100.0,"minimum":0.0},{"type":"null"}],"title":"Website Confidence Score","description":"0-100 website confidence when a URL was considered (see ``LeadOut``)."},"drop_reason":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Drop Reason"},"source_record_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source Record Id","description":"Source record UUID as string, if linked."}},"type":"object","required":["id","run_id","company_uid","company_name"],"title":"ExcludedLeadOut","description":"Dropped lead row for operator review (no extra PII beyond stored lead fields)."},"ExportArtifactOut":{"properties":{"id":{"type":"integer","title":"Id"},"artifact_type":{"type":"string","title":"Artifact Type"},"file_path":{"type":"string","title":"File Path"},"schema_version":{"type":"string","title":"Schema Version"},"created_at":{"type":"string","format":"date-time","title":"Created At"}},"type":"object","required":["id","artifact_type","file_path","schema_version","created_at"],"title":"ExportArtifactOut"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"LeadOut":{"properties":{"id":{"type":"integer","title":"Id"},"run_id":{"type":"integer","title":"Run Id"},"source_type":{"type":"string","title":"Source Type"},"company_uid":{"type":"string","title":"Company Uid"},"external_source_record_key":{"type":"string","title":"External Source Record Key"},"company_name":{"type":"string","title":"Company Name"},"canton":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Canton"},"legal_form":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Legal Form"},"address_line":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Address Line"},"city":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"City"},"purpose":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Purpose"},"website_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Website Url"},"website_host":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Website Host"},"website_source":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Website Source"},"website_confidence_score":{"anyOf":[{"type":"integer","maximum":100.0,"minimum":0.0},{"type":"null"}],"title":"Website Confidence Score","description":"Website URL confidence 0-100 (higher = stronger match)."},"website_selection_reason":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Website Selection Reason"},"website_discovery_query":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Website Discovery Query"},"email":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Email"},"status":{"type":"string","title":"Status"},"drop_reason":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Drop Reason"},"suppressed":{"type":"boolean","title":"Suppressed"},"legal_basis":{"type":"string","title":"Legal Basis"},"provenance_json":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Provenance Json"},"ai_used":{"type":"boolean","title":"Ai Used"},"ai_prompt_version_or_hash":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Ai Prompt Version Or Hash"},"ai_model_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Ai Model Name"},"ai_input_features_summary":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Ai Input Features Summary"},"ai_generated_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Ai Generated At"},"outreach_draft":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Outreach Draft"},"created_at":{"type":"string","format":"date-time","title":"Created At"}},"type":"object","required":["id","run_id","source_type","company_uid","external_source_record_key","company_name","canton","legal_form","address_line","city","purpose","website_url","website_host","website_source","website_selection_reason","website_discovery_query","email","status","drop_reason","suppressed","legal_basis","provenance_json","ai_used","ai_prompt_version_or_hash","ai_model_name","ai_input_features_summary","ai_generated_at","outreach_draft","created_at"],"title":"LeadOut"},"PeriodOut":{"properties":{"from":{"type":"string","title":"From"},"to":{"type":"string","title":"To"}},"type":"object","required":["from","to"],"title":"PeriodOut"},"RunCreate":{"properties":{"source_type":{"type":"string","enum":["zefix_sogc","zefix"],"title":"Source Type","description":"Registered ingest adapter id. Use ``zefix_sogc`` (Zefix REST / SOGC). The shorthand ``zefix`` is accepted and stored as ``zefix_sogc``."},"config":{"additionalProperties":true,"type":"object","title":"Config","description":"Extra pipeline options merged with defaults (e.g. ``max_zefix_fetch``, ``mutation_type_keys``)."},"canton":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Canton","description":"Optional single canton code (e.g. ``ZH``); stored as ``cantons: […]`` in the snapshot."},"cantons":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Cantons","description":"Optional canton list; mutually exclusive with ``canton``."},"legal_form":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Legal Form","description":"Optional filter hint stored on the snapshot (reserved for future ingest filters)."},"lookback_days":{"anyOf":[{"type":"integer","maximum":3660.0,"minimum":1.0},{"type":"null"}],"title":"Lookback Days","description":"Optional override for ``zefix_lookback_days`` in the merged snapshot."}},"type":"object","required":["source_type"],"title":"RunCreate","description":"Body for ``POST /runs``. ``source_type`` is required; optional fields are merged into\n``config_snapshot`` (see ``config_snapshot_for_run``).","example":{"canton":"ZH","lookback_days":7,"source_type":"zefix_sogc"}},"RunDetailOut":{"properties":{"id":{"type":"integer","title":"Id"},"source_type":{"type":"string","title":"Source Type"},"status":{"type":"string","title":"Status"},"config_snapshot":{"additionalProperties":true,"type":"object","title":"Config Snapshot"},"started_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Started At"},"finished_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Finished At"},"metrics_json":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Metrics Json"},"error_summary":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error Summary"},"export_artifacts":{"items":{"$ref":"#/components/schemas/ExportArtifactOut"},"type":"array","title":"Export Artifacts"},"lead_counts":{"additionalProperties":{"type":"integer"},"type":"object","title":"Lead Counts","description":"Counts of leads for this run by pipeline status (`ok`, `suppressed`, `dropped`) and `total` (sum of those three)."},"links":{"anyOf":[{"$ref":"#/components/schemas/RunLinks"},{"type":"null"}],"description":"Navigation paths for this run (populated on ``GET /runs/{run_id}``): ``leads``, ``artifacts``, and ``exclusions`` match the nested list endpoints."},"drop_reason_counts":{"additionalProperties":{"type":"integer"},"type":"object","title":"Drop Reason Counts","description":"Counts of **dropped** leads for this run keyed by exact ``drop_reason`` string (pipeline values such as ``junk_filter``); empty string groups missing reasons."},"serper_diagnostics":{"anyOf":[{"$ref":"#/components/schemas/SerperDiagnosticsOut"},{"type":"null"}],"description":"Flattened Serper run diagnostics (preflight + circuit breaker counters) derived from ``metrics_json.enrichment`` when available."}},"type":"object","required":["id","source_type","status","config_snapshot","started_at","finished_at","metrics_json","error_summary"],"title":"RunDetailOut"},"RunLinks":{"properties":{"leads":{"type":"string","title":"Leads","description":"Path to ``GET`` leads for this run."},"artifacts":{"type":"string","title":"Artifacts","description":"Path to ``GET`` export artifact rows for this run."},"exclusions":{"type":"string","title":"Exclusions","description":"Path to ``GET`` dropped leads (exclusions) with ``drop_reason`` for this run."}},"type":"object","required":["leads","artifacts","exclusions"],"title":"RunLinks","description":"API paths for common follow-up calls for this run (relative to the service root)."},"RunOut":{"properties":{"id":{"type":"integer","title":"Id"},"source_type":{"type":"string","title":"Source Type"},"status":{"type":"string","title":"Status"},"config_snapshot":{"additionalProperties":true,"type":"object","title":"Config Snapshot"},"started_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Started At"},"finished_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Finished At"},"metrics_json":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Metrics Json"},"error_summary":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error Summary"}},"type":"object","required":["id","source_type","status","config_snapshot","started_at","finished_at","metrics_json","error_summary"],"title":"RunOut"},"SerperDiagnosticsOut":{"properties":{"serper_preflight_ok":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Serper Preflight Ok"},"serper_preflight_status":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Serper Preflight Status"},"serper_calls_attempted":{"type":"integer","title":"Serper Calls Attempted","default":0},"serper_calls_failed":{"type":"integer","title":"Serper Calls Failed","default":0},"serper_circuit_opened":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Serper Circuit Opened"},"serper_disabled_reason":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Serper Disabled Reason"},"serper_skipped_after_circuit":{"type":"integer","title":"Serper Skipped After Circuit","default":0}},"type":"object","title":"SerperDiagnosticsOut"},"SuppressionCreate":{"properties":{"company_uid":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Company Uid"},"source_record_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source Record Id"},"domain":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Domain"},"email":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Email"},"reason":{"type":"string","title":"Reason","default":""},"expires_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Expires At"}},"type":"object","title":"SuppressionCreate"},"SuppressionOut":{"properties":{"id":{"type":"integer","title":"Id"},"source_record_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source Record Id"},"company_uid":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Company Uid"},"domain":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Domain"},"email_hash":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Email Hash"},"reason":{"type":"string","title":"Reason"},"active":{"type":"boolean","title":"Active"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"expires_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Expires At"}},"type":"object","required":["id","source_record_id","company_uid","domain","email_hash","reason","active","created_at","expires_at"],"title":"SuppressionOut"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}},"securitySchemes":{"APIKeyHeader":{"type":"apiKey","in":"header","name":"X-API-Key"}}}}