{
  "openapi": "3.1.0",
  "info": {
    "title": "First Mile Labs Public Pull API",
    "version": "1.13.0",
    "description": "Read-only OAuth2 client-credentials API for pulling KYB/KYC case, document, decision, screening, and event data into your CRM, data warehouse, or case-management system.\n\nMirrors the additive compatibility policy of outbound webhooks (`eventVersion: 1`). Breaking changes ship as a new `/v2/*` namespace.\n\n**Entitlements are checked on every request.** A key keeps the scopes it was granted, but every call also needs the organisation to hold API access and the product behind the endpoint (KYB / registry, Screening & AML, AI config authoring). Without them any endpoint answers `403` with `error: api_access_disabled`, or `error: product_not_entitled` naming the `product` and the `required` scope. If they cannot be checked it answers `503` with `error: temporarily_unavailable`; retry.\n\n**A deactivated organisation keeps only its case data.** For the 12 months of its download window, `GET` calls needing `read:cases`, `read:full_case`, `read:documents`, `read:decisions`, `read:screening` or `read:events` still work, and every other call answers `403` with `error: workspace_deactivated` and `downloadWindowEndsAt`. After that every call answers `403` with `error: workspace_deactivated_expired`. If its status cannot be checked it answers `503` with `error: temporarily_unavailable`; retry.\n\n**Every failure has an `error`, and its `error_description` is fixed text.** If the credential itself cannot be re-checked, an authenticated endpoint answers `503` with `error: temporarily_unavailable`; retry. A request that cannot be read answers `400`, `413` or `415` with `error: invalid_request`. An `Origin` we do not allow answers `403` with `error: origin_not_allowed`. A body that fails validation answers `400` with `error: invalid_request` or `error: validation_error`, as each endpoint documents, and lists each failed check in `fields`. A path or method this API does not have answers `404` with `error: not_found`. A failure on our side answers `500` with `error: internal_error`, or `error: server_error` on `/v1/oauth/*`.",
    "contact": {
      "name": "First Mile Labs Support",
      "email": "support@firstmilelabs.com",
      "url": "https://www.firstmilelabs.com/docs/api"
    },
    "license": {
      "name": "Proprietary"
    }
  },
  "servers": [
    {
      "url": "https://www.firstmilelabs.com",
      "description": "Production"
    }
  ],
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "OAuth",
      "description": "Token issuance"
    },
    {
      "name": "Cases"
    },
    {
      "name": "Documents"
    },
    {
      "name": "Events"
    },
    {
      "name": "Decisions"
    },
    {
      "name": "Screening"
    },
    {
      "name": "Registry",
      "description": "Metered corporate-registry lookup (LITE tier)"
    }
  ],
  "paths": {
    "/v1/screening/run": {
      "post": {
        "tags": [
          "Screening"
        ],
        "summary": "Run sanctions/PEP (and optional adverse-media) screening.",
        "description": "Synchronous, STATELESS screening of a supplied subject roster. No case is created and nothing is persisted (the case-scoped screening + AI hit-triage flow is deliberately not used); hits are returned inline in the response.\n\nBilling is **per completed screen** — one metered event per requested check type per call, whether or not it matched (a vendor lookup happened regardless). Metering runs only on fresh execution; a retry carrying the same `Idempotency-Key` replays the stored response and is not re-billed.\n\n`sanctions_pep` screens with the tenant's sanctions vendor, OpenSanctions or ComplyAdvantage. If the tenant's sanctions or PEP slot names any other vendor, or the two differ, the request returns `409 sanctions_vendor_unavailable` before anything is billed.\n\n`adverse_media` requires the tenant's adverse-media vendor to be ComplyAdvantage; otherwise the request returns `409 adverse_media_vendor_unavailable`.\n\nRequires the `screening:run` scope.",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ScreeningRunRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Screening results (one entry per subject).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScreeningRunResponse"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: malformed subjects, or an unsupported check. `fields` lists each failed check.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "description": "The token lacks the `screening:run` scope (`insufficient_scope`)."
          },
          "409": {
            "description": "The `Idempotency-Key` conflicts with a prior request / is still in flight, `adverse_media` was requested but the tenant's adverse-media vendor is not ComplyAdvantage (`adverse_media_vendor_unavailable`), or `sanctions_pep` was requested but the tenant's sanctions or PEP slot names a vendor that can't run (`sanctions_vendor_unavailable`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                }
              }
            }
          },
          "429": {
            "description": "Per-key rate limit exceeded."
          }
        }
      }
    },
    "/v1/oauth/authorize": {
      "get": {
        "tags": [
          "OAuth"
        ],
        "summary": "Authorization-code flow entry point (Claude Custom Connector, partner OAuth apps).",
        "description": "RFC 6749 §4.1 authorization-code grant. Redirects the analyst to the FML consent screen, where they sign in (if not already) and approve the requested scopes for the calling OAuth app. On approval the analyst is redirected back to `redirect_uri` with `?code=…&state=…`; the partner exchanges the short-lived code (60 s TTL, single-use) at `/v1/oauth/token` with `grant_type=authorization_code`.\n\nUse this for end-user-facing integrations (Claude, partner connectors). Server-to-server integrations should keep using `client_credentials` against `/v1/oauth/token` instead.",
        "security": [],
        "parameters": [
          {
            "name": "response_type",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "code"
              ]
            }
          },
          {
            "name": "client_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "OAuth app identifier issued by FML (e.g. `oauth_app_claude`)."
          },
          {
            "name": "redirect_uri",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uri"
            },
            "description": "Must exactly match one of the redirect URIs registered for the OAuth app."
          },
          {
            "name": "scope",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Space-separated subset of the scopes the OAuth app is allowed to request."
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Opaque value echoed back on the redirect — partners should generate cryptographically random state per request for CSRF protection."
          }
        ],
        "responses": {
          "302": {
            "description": "Redirect to the consent screen (or, if approved, back to `redirect_uri`)."
          },
          "400": {
            "$ref": "#/components/responses/OAuthError"
          },
          "500": {
            "description": "A failure on our side, as a plain-text page: this endpoint is a browser's, so it answers `server_error: The request could not be completed. Retry later.`",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/v1/oauth/token": {
      "post": {
        "tags": [
          "OAuth"
        ],
        "summary": "Exchange credentials for an access token (client_credentials, authorization_code, refresh_token).",
        "description": "Supports three grants from RFC 6749:\n\n- `client_credentials` (§4.4) — server-to-server integrations.\n- `authorization_code` (§4.1) — exchange a one-time code from `/v1/oauth/authorize` for an access + refresh token.\n- `refresh_token` (§6) — rotate an expired access token. Refresh tokens are single-use; using a token a second time revokes the whole authorization (reuse-detection). After a `500`, retry with the same refresh token.\n\nAccess tokens are JWTs valid for 1 h. Refresh tokens are opaque, valid for 90 days, and rotated on every use.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TokenRequest"
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/TokenRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Access token issued. `refresh_token` is only present for `authorization_code` and `refresh_token` grants.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/OAuthError",
            "description": "OAuth2 error response. A body that fails validation, such as one with no `grant_type`, is `invalid_request`, and `fields` lists each failed check."
          },
          "401": {
            "$ref": "#/components/responses/OAuthError"
          },
          "500": {
            "$ref": "#/components/responses/OAuthError"
          }
        }
      }
    },
    "/v1/oauth/revoke": {
      "post": {
        "tags": [
          "OAuth"
        ],
        "summary": "Revoke a refresh token (RFC 7009).",
        "description": "Revokes the supplied refresh token immediately, along with the underlying authorization — every access token issued under that authorization stops working on the next call. Responds `200 OK` whether or not it knows the token (per RFC 7009 §2.2, revocation of an unknown token must not be distinguishable from revocation of a real one).",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RevokeRequest"
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/RevokeRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Revocation accepted."
          },
          "400": {
            "$ref": "#/components/responses/OAuthError",
            "description": "`invalid_request`: no `token`. `fields` lists each failed check."
          },
          "500": {
            "$ref": "#/components/responses/OAuthError"
          }
        }
      }
    },
    "/v1/cases": {
      "post": {
        "tags": [
          "Cases"
        ],
        "summary": "Create a new KYB case (one-click onboarding from a CRM/iPaaS).",
        "description": "Creates a case row, grants the customer portal access, sends the tenant-branded magic-link invite, fires `case.created` to subscribed outbound webhooks, and kicks off registry verifications. Idempotent two ways: send an `Idempotency-Key` header to make retries safe, and/or pass `crmRecordId` so the same upstream record can never mint a duplicate case (`(orgId, crmRecordId)` dedup). Replays return the original status + body verbatim with an `Idempotent-Replay` header.\n\nRequires the `cases:write` scope.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 200
            },
            "description": "Caller-supplied idempotency key. Replays return the original response."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CaseCreateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Idempotent replay — case already exists for this `Idempotency-Key` or `(orgId, crmRecordId)`. Body is identical to the original response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CaseCreateResponse"
                }
              }
            }
          },
          "201": {
            "description": "Case created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CaseCreateResponse"
                }
              }
            }
          },
          "400": {
            "description": "`validation_error`. A body that fails validation lists each failed check in `fields`. An `Idempotency-Key` over 200 characters has the reason in `details` instead.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/OAuthError"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "details": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "description": "`case_allowance_reached`. The tenant has opened as many cases as its case allowance covers, so no case was created. First Mile Labs can raise the allowance. The `Idempotency-Key` is released, so a retry with the same key runs again.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/OAuthError"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "allowance": {
                          "type": "integer",
                          "description": "How many cases the tenant may open."
                        },
                        "used": {
                          "type": "integer",
                          "description": "How many cases count against it."
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "409": {
            "description": "Idempotency-Key conflict (same key used on a different endpoint).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Cases"
        ],
        "summary": "List cases for the authenticated tenant.",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "updated_since",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Return cases whose derived `updatedAt` is >= this timestamp."
          },
          {
            "name": "created_since",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Return cases whose `createdAt` is >= this timestamp."
          }
        ],
        "responses": {
          "200": {
            "description": "Page of cases.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Page"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Case"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/v1/cases/{caseId}": {
      "get": {
        "tags": [
          "Cases"
        ],
        "summary": "Get a single case with its current decision and risk band.",
        "parameters": [
          {
            "name": "caseId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Case detail.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CaseDetail"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/v1/cases/{caseId}/documents": {
      "get": {
        "tags": [
          "Documents"
        ],
        "summary": "List documents for a single case (cursor-paginated).",
        "parameters": [
          {
            "name": "caseId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Page of case documents.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Page"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Document"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/v1/cases/{caseId}/decisions": {
      "get": {
        "tags": [
          "Decisions"
        ],
        "summary": "Decision history for a case (cursor-paginated).",
        "parameters": [
          {
            "name": "caseId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Page of decisions.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Page"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Decision"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/v1/cases/{caseId}/screening": {
      "get": {
        "tags": [
          "Screening"
        ],
        "summary": "Screening hits for a case (cursor-paginated).",
        "parameters": [
          {
            "name": "caseId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Page of screening hits.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Page"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/ScreeningHit"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/v1/cases/{caseId}/screening/disposition": {
      "post": {
        "tags": [
          "Screening"
        ],
        "summary": "Record a screening-hit disposition from a CRM/iPaaS.",
        "description": "Closes the screening-hit review loop without an analyst opening the console. Upserts the disposition into the same store the analyst console writes to (keyed on `(caseId, hitId)`) and triggers a background risk re-assessment, since a hit disposition moves the sanctions/PEP risk factors. Re-sending the same disposition is a no-op state-wise; send an `Idempotency-Key` header to make retries replay the original response verbatim.\n\nRequires the `screening:write` scope.",
        "parameters": [
          {
            "name": "caseId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 200
            },
            "description": "Caller-supplied idempotency key. Replays return the original response."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ScreeningDispositionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Disposition recorded.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "caseId": {
                      "type": "string"
                    },
                    "hitId": {
                      "type": "string"
                    },
                    "action": {
                      "type": "string",
                      "description": "Canonical action (approve | dismiss | escalate)."
                    },
                    "note": {
                      "type": "string"
                    },
                    "officerName": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "via": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`validation_error`. A body or `caseId` that fails validation lists each failed check in `fields`; an unknown action, or an `Idempotency-Key` over 200 characters, says so in `error_description`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "Idempotency-Key conflict or another request with the same key is in flight.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/documents": {
      "get": {
        "tags": [
          "Documents"
        ],
        "summary": "List documents across the tenant or for a single case.",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "name": "caseId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Page of documents.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Page"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Document"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/v1/documents/{id}": {
      "get": {
        "tags": [
          "Documents"
        ],
        "summary": "Get a single document with extracted data.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Document detail.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Document"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/v1/events": {
      "get": {
        "tags": [
          "Events"
        ],
        "summary": "Pull-style event feed (mirrors outbound webhook payloads).",
        "description": "Returns each distinct event exactly once (deduped by `eventId`). Useful when push delivery is impractical (firewalled environments, batch ETL pipelines, polling iPaaS recipes).",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "name": "event_type",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by event type, e.g. `case.decision.made`."
          },
          {
            "name": "since",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Page of events.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Page"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Event"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/v1/registry/jurisdictions": {
      "get": {
        "tags": [
          "Registry"
        ],
        "summary": "Published registry coverage catalogue.",
        "description": "Lists every supported jurisdiction with its registry, pricing band, available tiers, and live/credential/unavailable status. Requires the `read:registry` scope.",
        "responses": {
          "200": {
            "description": "Coverage catalogue.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/RegistryJurisdiction"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/v1/registry/search": {
      "get": {
        "tags": [
          "Registry"
        ],
        "summary": "LITE company search.",
        "description": "Search a jurisdiction's registry by company name or number. Returns a normalised LITE entity per match. An empty `results` array is a clean no-match (not billable), not an error. Requires the `read:registry` scope.",
        "parameters": [
          {
            "name": "country",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ISO-3166 alpha-2 code (e.g. `FR`) or country name (e.g. `France`). See `/v1/registry/jurisdictions`."
          },
          {
            "name": "q",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Company name or registration number. Aliases: `query`, `name`."
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "Search results (possibly empty).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "query",
                    "count",
                    "results",
                    "retrievedAt"
                  ],
                  "properties": {
                    "sandbox": {
                      "type": "boolean",
                      "description": "True when served from sandbox fixtures (no real registry call, not billed)."
                    },
                    "jurisdiction": {
                      "type": "object",
                      "properties": {
                        "country": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "registry": {
                          "type": "string"
                        },
                        "band": {
                          "type": "string"
                        }
                      }
                    },
                    "query": {
                      "type": "string"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "results": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/RegistryEntity"
                      }
                    },
                    "retrievedAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/OAuthError",
            "description": "invalid_request or jurisdiction_unsupported."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "description": "billing_hard_cap — the organisation's spend cap is exceeded. No vendor call was made and nothing was billed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "billing_hard_cap"
                    },
                    "error_description": {
                      "type": "string"
                    },
                    "spendCents": {
                      "type": "integer"
                    },
                    "budgetCents": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/OAuthError",
            "description": "idempotency_key_conflict (key reused for a different request) or idempotency_in_flight."
          },
          "422": {
            "$ref": "#/components/responses/OAuthError",
            "description": "jurisdiction_unavailable — listed but not enabled for live lookups."
          },
          "429": {
            "$ref": "#/components/responses/OAuthError",
            "description": "rate_limit_exceeded (this client's limit), or registry_rate_limited (the limit on a country's register, which every client shares; the UK only for now). Nothing was billed. Wait the `Retry-After` seconds, also `retryAfter` in the body, and retry."
          },
          "502": {
            "$ref": "#/components/responses/OAuthError",
            "description": "registry_upstream_error."
          },
          "503": {
            "$ref": "#/components/responses/OAuthError",
            "description": "rate_limit_unavailable — the limit could not be checked. Nothing was billed. Retry."
          }
        }
      }
    },
    "/v1/registry/company": {
      "get": {
        "tags": [
          "Registry"
        ],
        "summary": "LITE company detail.",
        "description": "Resolve a single company by registration number (preferred) or name. Returns `found: false` (404) on a clean miss — the signal the metering layer uses to NOT bill. Requires the `read:registry` scope.",
        "parameters": [
          {
            "name": "country",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ISO-3166 alpha-2 code or country name."
          },
          {
            "name": "companyNumber",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Registration number. Alias: `registrationNumber`. One of companyNumber / companyName is required."
          },
          {
            "name": "companyName",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Company name. Alias: `name`."
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "Company found.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "found",
                    "entity",
                    "retrievedAt"
                  ],
                  "properties": {
                    "found": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "sandbox": {
                      "type": "boolean",
                      "description": "True when served from sandbox fixtures (no real registry call, not billed)."
                    },
                    "entity": {
                      "$ref": "#/components/schemas/RegistryEntity"
                    },
                    "retrievedAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/OAuthError",
            "description": "invalid_request or jurisdiction_unsupported."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "description": "billing_hard_cap — the organisation's spend cap is exceeded. No vendor call was made and nothing was billed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "billing_hard_cap"
                    },
                    "error_description": {
                      "type": "string"
                    },
                    "spendCents": {
                      "type": "integer"
                    },
                    "budgetCents": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "not_found — no matching company (clean no-match).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "enum": [
                        "not_found"
                      ]
                    },
                    "found": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "jurisdiction": {
                      "type": "object"
                    },
                    "retrievedAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/OAuthError",
            "description": "idempotency_key_conflict (key reused for a different request) or idempotency_in_flight."
          },
          "422": {
            "$ref": "#/components/responses/OAuthError",
            "description": "jurisdiction_unavailable."
          },
          "429": {
            "$ref": "#/components/responses/OAuthError",
            "description": "rate_limit_exceeded (this client's limit), or registry_rate_limited (the limit on a country's register, which every client shares; the UK only for now). Nothing was billed. Wait the `Retry-After` seconds, also `retryAfter` in the body, and retry."
          },
          "502": {
            "$ref": "#/components/responses/OAuthError",
            "description": "registry_upstream_error."
          },
          "503": {
            "$ref": "#/components/responses/OAuthError",
            "description": "rate_limit_unavailable — the limit could not be checked. Nothing was billed. Retry."
          }
        }
      }
    },
    "/v1/registry/enhanced/company": {
      "get": {
        "tags": [
          "Registry"
        ],
        "summary": "ENHANCED company profile.",
        "description": "Lite plus legal form, company activity, directors/officers, registered shareholders, capital structure, direct ownership %, and registered agents. Coverage extends beyond the native LITE catalogue. Returns `found: false` (404) on a clean miss (not billed). Requires the `read:registry_enhanced` scope.",
        "parameters": [
          {
            "name": "country",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ISO-3166 alpha-2 code or country name."
          },
          {
            "name": "companyNumber",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Registration number. Alias: `registrationNumber`. One of companyNumber / companyName is required."
          },
          {
            "name": "companyName",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Company name. Alias: `name`."
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "Company found.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "found",
                    "entity",
                    "retrievedAt"
                  ],
                  "properties": {
                    "found": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "sandbox": {
                      "type": "boolean"
                    },
                    "entity": {
                      "$ref": "#/components/schemas/RegistryEnhancedEntity"
                    },
                    "retrievedAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/OAuthError",
            "description": "invalid_request."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "description": "billing_hard_cap — the organisation's spend cap is exceeded. No vendor call was made and nothing was billed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "billing_hard_cap"
                    },
                    "error_description": {
                      "type": "string"
                    },
                    "spendCents": {
                      "type": "integer"
                    },
                    "budgetCents": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "not_found — no matching company (clean no-match).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "enum": [
                        "not_found"
                      ]
                    },
                    "found": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "retrievedAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/OAuthError",
            "description": "idempotency_key_conflict (key reused for a different request) or idempotency_in_flight."
          },
          "502": {
            "$ref": "#/components/responses/OAuthError",
            "description": "registry_upstream_error."
          }
        }
      }
    },
    "/v1/registry/ubo/company": {
      "get": {
        "tags": [
          "Registry"
        ],
        "summary": "UBO UNWRAP — recursive ownership traversal.",
        "description": "Recursively resolves ownership to natural persons: effective ownership through the chain, a structured ownership graph, flagged unresolved branches, and reasons for non-continuation. The response carries `entityCount` (natural persons + corporate nodes resolved) so per-entity charges are attributable. Billed base + per-entity-resolved. The per-request cost ceiling (`maxCreditCost`) is clamped to a hard maximum; a breach returns `402 cost_ceiling_exceeded`. Returns `found: false` (404) on a clean miss. Requires the `read:registry_ubo` scope.",
        "parameters": [
          {
            "name": "country",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ISO-3166 alpha-2 code or country name."
          },
          {
            "name": "companyNumber",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Registration number. Alias: `registrationNumber`. One of companyNumber / companyName is required."
          },
          {
            "name": "companyName",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Company name. Alias: `name`."
          },
          {
            "name": "maxCreditCost",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Per-request cost ceiling, in credits. Clamped to a hard maximum. Alias: `max_credit_cost`. Default 50."
          },
          {
            "name": "uboThreshold",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            },
            "description": "Ownership % at/above which a natural person is flagged as a UBO. Alias: `ubo_threshold`. Default 25."
          },
          {
            "name": "maxLayers",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 10
            },
            "description": "Maximum ownership-chain depth to traverse. Alias: `max_layers`. Default 5."
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "Ownership resolved.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "found",
                    "entity",
                    "retrievedAt"
                  ],
                  "properties": {
                    "found": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "sandbox": {
                      "type": "boolean"
                    },
                    "entity": {
                      "$ref": "#/components/schemas/RegistryUboEntity"
                    },
                    "retrievedAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/OAuthError",
            "description": "invalid_request."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/OAuthError",
            "description": "cost_ceiling_exceeded — traversal hit the maxCreditCost ceiling."
          },
          "404": {
            "description": "not_found — the subject company could not be resolved (clean no-match).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "enum": [
                        "not_found"
                      ]
                    },
                    "found": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "retrievedAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/OAuthError",
            "description": "idempotency_key_conflict or idempotency_in_flight."
          },
          "502": {
            "$ref": "#/components/responses/OAuthError",
            "description": "registry_upstream_error."
          }
        }
      }
    },
    "/v1/registry/jobs": {
      "post": {
        "summary": "Submit a registry lookup to run asynchronously",
        "description": "Accepts any tier and runs it on the server, returning immediately with a job id.\n\nIntended for Band C jurisdictions, whose lookups can outlast a caller's HTTP timeout — and since billing is per successful check, a client that times out and retries pays twice for work it never saw. Async is opt-in: the synchronous endpoints are unchanged for every band.\n\nScope is enforced per tier, so an async UBO job requires `read:registry_ubo` exactly as the synchronous endpoint does.\n\nSupply `Idempotency-Key` to make a retried submit return the SAME job rather than queuing a second, billable lookup.\n\nReplaying the key of a job that has expired returns 410 `expired` and queues nothing.",
        "tags": [
          "Registry"
        ],
        "security": [
          {
            "oauth2": [
              "read:registry"
            ]
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "tier",
                  "country"
                ],
                "properties": {
                  "tier": {
                    "type": "string",
                    "enum": [
                      "lite",
                      "enhanced",
                      "ubo"
                    ]
                  },
                  "country": {
                    "type": "string",
                    "description": "ISO-3166 alpha-2."
                  },
                  "companyNumber": {
                    "type": "string"
                  },
                  "companyName": {
                    "type": "string"
                  },
                  "maxCreditCost": {
                    "type": "integer",
                    "description": "UBO only — per-request cost ceiling."
                  },
                  "uboThreshold": {
                    "type": "number",
                    "description": "UBO only."
                  },
                  "maxLayers": {
                    "type": "integer",
                    "description": "UBO only."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted. Poll the Location header.",
            "headers": {
              "Location": {
                "schema": {
                  "type": "string"
                }
              },
              "Idempotent-Replay": {
                "schema": {
                  "type": "string"
                },
                "description": "true when an existing job was returned."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RegistryJob"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: an unknown tier, or no companyNumber/companyName. A body that fails validation lists each failed check in `fields`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                }
              }
            }
          },
          "402": {
            "description": "billing_hard_cap — the organisation's spend cap is exceeded. No vendor call was made and nothing was billed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "billing_hard_cap"
                    },
                    "error_description": {
                      "type": "string"
                    },
                    "spendCents": {
                      "type": "integer"
                    },
                    "budgetCents": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope — the tier requires a scope this client was not granted."
          },
          "410": {
            "description": "expired — this Idempotency-Key's job is past its retention window. Nothing was queued or billed. Submit with a new key to run the lookup again (billed).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "expired"
                    },
                    "error_description": {
                      "type": "string"
                    },
                    "job": {
                      "$ref": "#/components/schemas/RegistryJob"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/registry/jobs/{id}": {
      "get": {
        "summary": "Collect an async registry job",
        "description": "Scoped to the submitting organisation; an unknown or foreign job id returns 404. A job's params and result are kept for 7 days after it finishes; after that it returns 410 `expired`.",
        "tags": [
          "Registry"
        ],
        "security": [
          {
            "oauth2": [
              "read:registry"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RegistryJob"
                }
              }
            },
            "description": "The job."
          },
          "404": {
            "description": "No such job."
          },
          "410": {
            "description": "expired — the job is past its retention window (7 days after finishedAt), so its params and result have been deleted. Submit again with a new Idempotency-Key to run a new, billed lookup.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "expired"
                    },
                    "error_description": {
                      "type": "string"
                    },
                    "job": {
                      "$ref": "#/components/schemas/RegistryJob"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/registry/enhanced/search": {
      "get": {
        "summary": "ENHANCED company search by name",
        "description": "Resolve a company by name across the wider registry network, returning CANDIDATES with the company number to pass to `/v1/registry/enhanced/company`.\n\nWithout this the ENHANCED tier is unreachable for a caller who does not already hold a registration number: the profile endpoint accepts a name, but a name that does not resolve exactly is simply a miss.\n\nCovers the wider registry network, so it answers for different countries than `/v1/registry/search`, which is limited to the native LITE jurisdictions.\n\n**Billing:** metered as a search at the jurisdiction's band, not at the ENHANCED profile price. A result set with no matches is never billed.",
        "tags": [
          "Registry"
        ],
        "security": [
          {
            "oauth2": [
              "read:registry_enhanced"
            ]
          }
        ],
        "parameters": [
          {
            "name": "country",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ISO-3166 alpha-2 or country name."
          },
          {
            "name": "q",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Company name to search for."
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Candidate matches (possibly empty).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sandbox": {
                      "type": "boolean"
                    },
                    "jurisdiction": {
                      "type": "object",
                      "properties": {
                        "country": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        }
                      }
                    },
                    "query": {
                      "type": "string"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string"
                          },
                          "companyNumber": {
                            "type": "string",
                            "nullable": true
                          },
                          "status": {
                            "type": "string",
                            "nullable": true
                          },
                          "type": {
                            "type": "string",
                            "nullable": true
                          },
                          "address": {
                            "type": "string",
                            "nullable": true
                          },
                          "jurisdiction": {
                            "type": "string"
                          },
                          "source": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "retrievedAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "country or q missing."
          },
          "402": {
            "description": "billing_hard_cap — the organisation's spend cap is exceeded. No vendor call was made and nothing was billed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "billing_hard_cap"
                    },
                    "error_description": {
                      "type": "string"
                    },
                    "spendCents": {
                      "type": "integer"
                    },
                    "budgetCents": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope — requires read:registry_enhanced."
          },
          "502": {
            "description": "registry_upstream_error."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    },
    "parameters": {
      "Limit": {
        "name": "limit",
        "in": "query",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 200,
          "default": 50
        }
      },
      "Cursor": {
        "name": "cursor",
        "in": "query",
        "schema": {
          "type": "string"
        },
        "description": "Opaque cursor returned in `nextCursor` from a previous page."
      },
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": false,
        "schema": {
          "type": "string",
          "maxLength": 200
        },
        "description": "Optional. A retry with the same key replays the original response (`Idempotent-Replay: true`) and is not re-billed. Reusing a key for a different request returns 409."
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "Invalid or missing access token.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/OAuthError"
            }
          }
        }
      },
      "NotFound": {
        "description": "Resource not found (or not in the authenticated tenant).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/OAuthError"
            }
          }
        }
      },
      "OAuthError": {
        "description": "OAuth2 error response.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/OAuthError"
            }
          }
        }
      }
    },
    "schemas": {
      "ScreeningSubject": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Caller-assigned id echoed back on the matching result, so hits correlate to your record. Derived (`person_N` / `entity_N`) when omitted."
          },
          "type": {
            "type": "string",
            "enum": [
              "person",
              "company"
            ],
            "description": "Defaults to `person`."
          },
          "name": {
            "type": "string",
            "description": "Full name (person) or legal name (company)."
          },
          "birthDate": {
            "type": "string",
            "description": "ISO date, e.g. `1980-01-01` (person). Improves match precision."
          },
          "country": {
            "description": "ISO-3166 alpha-2 code or country name; a single value or an array of citizenships.",
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            ]
          },
          "registrationNumber": {
            "type": "string",
            "description": "Company registration number (company subjects)."
          }
        }
      },
      "ScreeningRunRequest": {
        "type": "object",
        "required": [
          "subjects"
        ],
        "properties": {
          "subjects": {
            "type": "array",
            "minItems": 1,
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/ScreeningSubject"
            }
          },
          "checks": {
            "type": "array",
            "description": "Which checks to run. Defaults to `[\"sanctions_pep\"]`. `adverse_media` requires the ComplyAdvantage vendor (else 409).",
            "items": {
              "type": "string",
              "enum": [
                "sanctions_pep",
                "adverse_media"
              ]
            }
          }
        }
      },
      "ScreeningSanctionsHit": {
        "type": "object",
        "description": "A sanctions/PEP watchlist match.",
        "properties": {
          "caption": {
            "type": "string"
          },
          "schema": {
            "type": "string",
            "description": "`Person` or `Company`."
          },
          "score": {
            "type": "number",
            "nullable": true,
            "description": "Match score (0–1)."
          },
          "topics": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "position": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "nationality": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "isPep": {
            "type": "boolean"
          },
          "isSanctioned": {
            "type": "boolean"
          }
        }
      },
      "ScreeningAdverseMediaHit": {
        "type": "object",
        "description": "An adverse-media match (ComplyAdvantage).",
        "properties": {
          "caption": {
            "type": "string"
          },
          "score": {
            "type": "number",
            "nullable": true
          },
          "types": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "media": {
            "type": "array",
            "description": "Underlying source articles.",
            "items": {
              "type": "object",
              "properties": {
                "url": {
                  "type": "string",
                  "nullable": true
                },
                "title": {
                  "type": "string",
                  "nullable": true
                },
                "date": {
                  "type": "string",
                  "nullable": true
                }
              }
            }
          }
        }
      },
      "ScreeningSubjectResult": {
        "type": "object",
        "required": [
          "id",
          "hits",
          "sanctioned",
          "pep"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The subject id (supplied or derived)."
          },
          "hits": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScreeningSanctionsHit"
            }
          },
          "sanctioned": {
            "type": "boolean"
          },
          "pep": {
            "type": "boolean"
          },
          "adverseMedia": {
            "type": "boolean",
            "description": "Present only when `adverse_media` was requested."
          },
          "adverseMediaHits": {
            "type": "array",
            "description": "Present only when `adverse_media` was requested.",
            "items": {
              "$ref": "#/components/schemas/ScreeningAdverseMediaHit"
            }
          },
          "notRescreened": {
            "type": "object",
            "description": "Present only when the vendor reused an earlier screen instead of screening the subject again (a ComplyAdvantage Mesh subject screened before). The hits are that earlier screen's when `earlierResultKnown` is true; otherwise they say nothing, and the subject is not confirmed clear.",
            "required": [
              "lastScreenedAt",
              "earlierResultKnown"
            ],
            "properties": {
              "lastScreenedAt": {
                "type": "string",
                "format": "date-time",
                "nullable": true,
                "description": "When the subject was last actually screened, if known."
              },
              "earlierResultKnown": {
                "type": "boolean",
                "description": "Whether the earlier screen's result is on record."
              }
            }
          }
        }
      },
      "ScreeningRunResponse": {
        "type": "object",
        "required": [
          "vendor",
          "results"
        ],
        "properties": {
          "vendor": {
            "type": "string",
            "description": "The screening vendor that ran (e.g. `OpenSanctions`), or `sandbox`."
          },
          "sandbox": {
            "type": "boolean",
            "description": "True when served from sandbox fixtures (no vendor call, not billed)."
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScreeningSubjectResult"
            }
          }
        }
      },
      "TokenRequest": {
        "type": "object",
        "required": [
          "grant_type"
        ],
        "description": "Union of three grant shapes. `client_credentials` requires `client_id`+`client_secret`. `authorization_code` requires `client_id`+`client_secret`+`code`+`redirect_uri`. `refresh_token` requires `client_id`+`client_secret`+`refresh_token`.",
        "properties": {
          "grant_type": {
            "type": "string",
            "enum": [
              "client_credentials",
              "authorization_code",
              "refresh_token"
            ]
          },
          "client_id": {
            "type": "string"
          },
          "client_secret": {
            "type": "string"
          },
          "scope": {
            "type": "string",
            "description": "Space-separated subset of granted scopes (client_credentials only)."
          },
          "code": {
            "type": "string",
            "description": "Authorization code returned from `/v1/oauth/authorize` (60 s TTL, single-use)."
          },
          "redirect_uri": {
            "type": "string",
            "format": "uri",
            "description": "Must match the `redirect_uri` used on the original `/v1/oauth/authorize` call."
          },
          "refresh_token": {
            "type": "string",
            "description": "Opaque refresh token previously issued by this endpoint."
          }
        }
      },
      "TokenResponse": {
        "type": "object",
        "required": [
          "access_token",
          "token_type",
          "expires_in",
          "scope"
        ],
        "properties": {
          "access_token": {
            "type": "string"
          },
          "token_type": {
            "type": "string",
            "enum": [
              "Bearer"
            ]
          },
          "expires_in": {
            "type": "integer",
            "description": "Seconds until expiry."
          },
          "scope": {
            "type": "string"
          },
          "refresh_token": {
            "type": "string",
            "description": "Present only on `authorization_code` and `refresh_token` grants. Rotated on every refresh."
          }
        }
      },
      "RevokeRequest": {
        "type": "object",
        "required": [
          "token",
          "client_id",
          "client_secret"
        ],
        "properties": {
          "token": {
            "type": "string",
            "description": "Either a refresh token (`ort_…`) or an access token (signed JWT). Revoking either kind kills the entire underlying authorization, so every access + refresh token issued under it stops working on the next call."
          },
          "token_type_hint": {
            "type": "string",
            "enum": [
              "refresh_token",
              "access_token"
            ],
            "description": "Optional per RFC 7009. The endpoint auto-detects the token type so the hint is informational only."
          },
          "client_id": {
            "type": "string"
          },
          "client_secret": {
            "type": "string"
          }
        }
      },
      "OAuthError": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "error_description": {
            "type": "string"
          },
          "fields": {
            "type": "array",
            "description": "On a `400` for a request that failed validation, each failed check.",
            "items": {
              "$ref": "#/components/schemas/ValidationField"
            }
          }
        }
      },
      "ValidationField": {
        "type": "object",
        "required": [
          "path",
          "code",
          "message"
        ],
        "properties": {
          "path": {
            "type": "string",
            "description": "What failed, such as `body.grant_type`, `body.subjects.0.name` or `params.caseId`."
          },
          "code": {
            "type": "string",
            "description": "The kind of failure, such as `invalid_type` or `too_small`."
          },
          "message": {
            "type": "string",
            "description": "The failure in words."
          }
        }
      },
      "Page": {
        "type": "object",
        "required": [
          "data",
          "hasMore"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {}
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ]
          },
          "hasMore": {
            "type": "boolean"
          }
        }
      },
      "CaseCreateRequest": {
        "type": "object",
        "required": [
          "customerEmail",
          "customerName"
        ],
        "properties": {
          "customerEmail": {
            "type": "string",
            "format": "email",
            "maxLength": 320
          },
          "customerName": {
            "type": "string",
            "maxLength": 200,
            "description": "Display name of the human you're inviting (e.g. the deal contact). Shown in the invite email greeting and stored on the case."
          },
          "companyName": {
            "type": "string",
            "maxLength": 300,
            "nullable": true
          },
          "country": {
            "type": "string",
            "maxLength": 100,
            "nullable": true
          },
          "entityType": {
            "type": "string",
            "maxLength": 100,
            "nullable": true
          },
          "crmRecordId": {
            "type": "string",
            "maxLength": 200,
            "nullable": true,
            "description": "Stable id from the upstream CRM (Salesforce Account, HubSpot Company, …). Used as a natural dedup key per tenant."
          },
          "crmSource": {
            "type": "string",
            "maxLength": 50,
            "nullable": true,
            "description": "Lower-case slug of the calling system: `salesforce`, `hubspot`, `workato`, `zapier`, `n8n`, …"
          },
          "sendInvite": {
            "type": "boolean",
            "default": true,
            "description": "When true (default) the tenant-branded magic-link invite is emailed to `customerEmail` immediately."
          },
          "allowDuplicateCrmRecord": {
            "type": "boolean",
            "default": false,
            "description": "Bypass the `(orgId, crmRecordId)` dedup guard. Use only when you genuinely want a second case for the same CRM record."
          }
        }
      },
      "CaseCreateResponse": {
        "type": "object",
        "required": [
          "caseId",
          "customerEmail",
          "source",
          "status"
        ],
        "properties": {
          "caseId": {
            "type": "string"
          },
          "friendlyRef": {
            "type": [
              "string",
              "null"
            ],
            "description": "Human-readable per-tenant case reference, e.g. BCB-2026-00123 (Task #520). Display only — pass caseId back to the API."
          },
          "customerEmail": {
            "type": [
              "string",
              "null"
            ],
            "description": "Always present. A new case always has the email you sent. A crmRecordId replay returns the existing case's email, which is null when that case has none (for example one created by screening or upload)."
          },
          "customerName": {
            "type": [
              "string",
              "null"
            ]
          },
          "companyName": {
            "type": [
              "string",
              "null"
            ]
          },
          "country": {
            "type": [
              "string",
              "null"
            ]
          },
          "entityType": {
            "type": [
              "string",
              "null"
            ]
          },
          "crmRecordId": {
            "type": [
              "string",
              "null"
            ]
          },
          "crmSource": {
            "type": [
              "string",
              "null"
            ]
          },
          "source": {
            "type": "string",
            "enum": [
              "api"
            ]
          },
          "status": {
            "type": "string"
          },
          "inviteSentAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "customerPortalUrl": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "analystUrl": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "inviteError": {
            "type": "string",
            "description": "Present only if the invite email failed; the case is still created."
          }
        }
      },
      "Case": {
        "type": "object",
        "required": [
          "caseId",
          "status",
          "createdAt"
        ],
        "properties": {
          "caseId": {
            "type": "string"
          },
          "friendlyRef": {
            "type": [
              "string",
              "null"
            ],
            "description": "Human-readable per-tenant case reference, e.g. BCB-2026-00123 (Task #520). Display only — pass caseId back to the API."
          },
          "orgId": {
            "type": [
              "string",
              "null"
            ]
          },
          "companyName": {
            "type": [
              "string",
              "null"
            ]
          },
          "companyNumber": {
            "type": [
              "string",
              "null"
            ]
          },
          "country": {
            "type": [
              "string",
              "null"
            ]
          },
          "entityType": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string"
          },
          "owner": {
            "type": [
              "object",
              "null"
            ]
          },
          "customerEmail": {
            "type": [
              "string",
              "null"
            ]
          },
          "customerName": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "confirmedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "crmRecordId": {
            "type": [
              "string",
              "null"
            ]
          },
          "crmSource": {
            "type": [
              "string",
              "null"
            ]
          },
          "source": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "CaseDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Case"
          },
          {
            "type": "object",
            "properties": {
              "decision": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/Decision"
                  }
                ]
              },
              "risk": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "compositeScore": {
                        "type": [
                          "number",
                          "null"
                        ]
                      },
                      "band": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "assessedAt": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "format": "date-time"
                      }
                    }
                  }
                ]
              },
              "governmentChecks": {
                "type": "array",
                "description": "GBG (ID3global) government / eKYC identity checks per subject. Empty when none were run. The numeric `score` is only present when GBG returned one.",
                "items": {
                  "type": "object",
                  "properties": {
                    "subjectName": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "provider": {
                      "type": "string",
                      "examples": [
                        "GBG (Government Data)"
                      ]
                    },
                    "band": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "GBG verification band (e.g. PASS, REFER)."
                    },
                    "score": {
                      "type": "number",
                      "description": "Finer-grained GBG numeric Score. Omitted when GBG returned no score."
                    },
                    "authenticationId": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "environment": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "checkStatus": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "enum": [
                        "pass",
                        "fail",
                        "inconclusive",
                        null
                      ]
                    },
                    "outcome": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "observedAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          }
        ]
      },
      "Decision": {
        "type": "object",
        "required": [
          "outcome",
          "decidedAt"
        ],
        "properties": {
          "outcome": {
            "type": "string",
            "enum": [
              "approved",
              "declined"
            ]
          },
          "notes": {
            "type": [
              "string",
              "null"
            ]
          },
          "analystEmail": {
            "type": [
              "string",
              "null"
            ]
          },
          "decidedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Document": {
        "type": "object",
        "required": [
          "id",
          "caseId",
          "status",
          "uploadedAt"
        ],
        "properties": {
          "id": {
            "type": "integer"
          },
          "caseId": {
            "type": "string"
          },
          "documentType": {
            "type": [
              "string",
              "null"
            ]
          },
          "filename": {
            "type": [
              "string",
              "null"
            ]
          },
          "mimeType": {
            "type": [
              "string",
              "null"
            ]
          },
          "sizeBytes": {
            "type": [
              "integer",
              "null"
            ]
          },
          "status": {
            "type": "string"
          },
          "confidence": {
            "type": [
              "string",
              "null"
            ]
          },
          "uploadedAt": {
            "type": "string",
            "format": "date-time"
          },
          "warnings": {
            "type": "array",
            "items": {}
          },
          "notes": {
            "type": [
              "string",
              "null"
            ]
          },
          "extractedData": {
            "type": [
              "object",
              "null"
            ]
          }
        }
      },
      "ScreeningHit": {
        "type": "object",
        "required": [
          "hitId",
          "subjectName"
        ],
        "properties": {
          "hitId": {
            "type": "string"
          },
          "subjectName": {
            "type": "string"
          },
          "role": {
            "type": [
              "string",
              "null"
            ]
          },
          "caption": {
            "type": [
              "string",
              "null"
            ],
            "description": "The matched watchlist entity's name/caption."
          },
          "schema": {
            "type": [
              "string",
              "null"
            ]
          },
          "isPep": {
            "type": "boolean"
          },
          "isSanctioned": {
            "type": "boolean"
          },
          "score": {
            "type": [
              "number",
              "null"
            ]
          },
          "topics": {
            "type": "array",
            "items": {}
          },
          "position": {
            "type": "array",
            "items": {}
          },
          "nationality": {
            "type": "array",
            "items": {}
          },
          "observedAt": {
            "type": "string",
            "format": "date-time"
          },
          "triage": {
            "$ref": "#/components/schemas/ScreeningTriage"
          }
        }
      },
      "ScreeningTriage": {
        "type": [
          "object",
          "null"
        ],
        "description": "AI triage verdict for the hit (null when the hit has not been triaged).",
        "properties": {
          "status": {
            "type": [
              "string",
              "null"
            ]
          },
          "disposition": {
            "type": [
              "string",
              "null"
            ]
          },
          "confidence": {
            "type": [
              "number",
              "null"
            ]
          },
          "shortReason": {
            "type": [
              "string",
              "null"
            ]
          },
          "longReason": {
            "type": [
              "string",
              "null"
            ]
          },
          "provider": {
            "type": [
              "string",
              "null"
            ]
          },
          "model": {
            "type": [
              "string",
              "null"
            ]
          },
          "promptVersion": {
            "type": [
              "string",
              "null"
            ]
          },
          "triagedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "ScreeningDispositionRequest": {
        "type": "object",
        "required": [
          "hitId",
          "action",
          "note",
          "officerName"
        ],
        "properties": {
          "hitId": {
            "type": "string",
            "maxLength": 200,
            "description": "The hit to action — the `hitId` from a screening.hit.detected event or GET /v1/cases/{caseId}/screening."
          },
          "action": {
            "type": "string",
            "maxLength": 64,
            "description": "Disposition. Canonical: dismiss (false positive, not our subject) | approve (confirmed true match) | escalate. Aliases accepted: dismissed/false_positive/not_a_match/discard/clear/cleared/false_positive_cleared/whitelist → dismiss; accept → approve; escalated/refer/review → escalate."
          },
          "note": {
            "type": "string",
            "minLength": 1,
            "maxLength": 4000,
            "description": "Required justification, recorded against the disposition."
          },
          "officerName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200,
            "description": "Name of the person/system recording the disposition."
          }
        }
      },
      "Event": {
        "type": "object",
        "description": "Mirrors the outbound webhook envelope so a partner writes one payload mapper for both push and pull. The shape of `data` for each `eventType` is defined by the per-event JSON Schemas published at `/schemas/webhooks/<eventType>.v1.json` (index at `/schemas/webhooks/index.json`). When a future `eventVersion: 2` ships, a new `/v2/events` namespace will appear alongside this one.",
        "required": [
          "eventId",
          "eventType",
          "eventVersion",
          "occurredAt",
          "data"
        ],
        "properties": {
          "eventId": {
            "type": "string",
            "description": "Stable idempotency key — same id push and pull receivers see."
          },
          "eventType": {
            "type": "string",
            "description": "Event type, e.g. `case.created`. See `/schemas/webhooks/index.json` for the full enum.",
            "examples": [
              "case.created",
              "case.submitted",
              "case.decision.made",
              "case.status.changed",
              "data.corrected",
              "document.uploaded",
              "screening.completed",
              "ai_review.completed"
            ]
          },
          "eventVersion": {
            "type": "integer",
            "enum": [
              1
            ]
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "type": "object",
            "description": "Full webhook payload. Validated against the per-event JSON Schema at `/schemas/webhooks/<eventType>.v1.json`."
          }
        }
      },
      "RegistryAddress": {
        "type": "object",
        "nullable": true,
        "description": "Registered address. `formatted` is present whenever the registry returns an address; structured fields are populated where the registry provides them, else null. The key set is stable across jurisdictions.",
        "properties": {
          "formatted": {
            "type": "string",
            "nullable": true
          },
          "addressLine1": {
            "type": "string",
            "nullable": true
          },
          "addressLine2": {
            "type": "string",
            "nullable": true
          },
          "locality": {
            "type": "string",
            "nullable": true
          },
          "region": {
            "type": "string",
            "nullable": true
          },
          "postalCode": {
            "type": "string",
            "nullable": true
          },
          "country": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "RegistryEntity": {
        "type": "object",
        "description": "Jurisdiction-stable, versioned registry entity (LITE tier). Fields absent for a jurisdiction are returned as `null`, never omitted — branch on null, not on key presence.",
        "required": [
          "schemaVersion",
          "tier",
          "legalName",
          "registrationNumber",
          "status",
          "jurisdiction",
          "source"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "examples": [
              "registry.entity/v1"
            ]
          },
          "tier": {
            "type": "string",
            "enum": [
              "lite"
            ]
          },
          "legalName": {
            "type": "string",
            "nullable": true
          },
          "registrationNumber": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "dissolved",
              "unknown"
            ]
          },
          "incorporationDate": {
            "type": "string",
            "nullable": true,
            "description": "ISO-8601 date where the registry provides it."
          },
          "taxNumber": {
            "type": [
              "string",
              "null"
            ],
            "description": "Tax identifier for the company, where the source register publishes one; null where it does not. In some jurisdictions this is the registration number itself (Brazil CNPJ, Mexico RFC), and both fields are returned.",
            "example": "12.345.678/0001-95"
          },
          "legalForm": {
            "type": "string",
            "nullable": true
          },
          "registeredAddress": {
            "$ref": "#/components/schemas/RegistryAddress"
          },
          "jurisdiction": {
            "type": "object",
            "properties": {
              "country": {
                "type": "string",
                "nullable": true,
                "description": "ISO-3166 alpha-2."
              },
              "name": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "source": {
            "type": "object",
            "description": "Audit provenance — the source registry and retrieval timestamp carried on every response.",
            "properties": {
              "registry": {
                "type": "string",
                "nullable": true
              },
              "code": {
                "type": "string",
                "nullable": true
              },
              "retrievedAt": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              }
            }
          }
        }
      },
      "RegistryJurisdiction": {
        "type": "object",
        "properties": {
          "country": {
            "type": "string",
            "description": "ISO-3166 alpha-2."
          },
          "countryName": {
            "type": "string"
          },
          "registry": {
            "type": "string",
            "description": "The register the data comes from (e.g. \"CAC (Nigeria)\"), not the provider we source it through."
          },
          "band": {
            "type": "string",
            "enum": [
              "A",
              "B",
              "C"
            ],
            "description": "Pricing/latency band. Band C is asynchronous."
          },
          "tiers": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "lite",
                "enhanced",
                "ubo"
              ]
            },
            "description": "Tiers available for this jurisdiction."
          },
          "availability": {
            "type": "string",
            "enum": [
              "live",
              "requires_credential",
              "unavailable"
            ]
          },
          "caveat": {
            "type": "string",
            "description": "Present only where this jurisdiction has a coverage limitation worth knowing before you call — e.g. a source that holds no ownership. Absent otherwise."
          },
          "mode": {
            "type": "string",
            "enum": [
              "sync",
              "async"
            ]
          },
          "pricing": {
            "type": "object",
            "description": "Price in GBP pence per tier. Only tiers that can actually run for this jurisdiction are quoted, so a lite-only jurisdiction carries no enhanced or ubo price.",
            "properties": {
              "lite": {
                "type": "integer"
              },
              "enhanced": {
                "type": "integer"
              },
              "ubo": {
                "type": "integer"
              }
            }
          }
        }
      },
      "RegistryEnhancedEntity": {
        "type": "object",
        "description": "ENHANCED-tier entity — Lite plus directors, shareholders, capital, direct ownership %, etc. Same stable-key-set contract: arrays default to `[]`, absent scalars to `null`.",
        "required": [
          "schemaVersion",
          "tier",
          "legalName",
          "registrationNumber",
          "status",
          "directors",
          "shareholders",
          "directOwnership",
          "registeredAgents",
          "jurisdiction",
          "source"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "examples": [
              "registry.entity/v1"
            ]
          },
          "tier": {
            "type": "string",
            "enum": [
              "enhanced"
            ]
          },
          "legalName": {
            "type": "string",
            "nullable": true
          },
          "registrationNumber": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "dissolved",
              "unknown"
            ]
          },
          "incorporationDate": {
            "type": "string",
            "nullable": true
          },
          "taxNumber": {
            "type": [
              "string",
              "null"
            ],
            "description": "Tax identifier for the company, where the source register publishes one; null where it does not. In some jurisdictions this is the registration number itself (Brazil CNPJ, Mexico RFC), and both fields are returned.",
            "example": "12.345.678/0001-95"
          },
          "legalForm": {
            "type": "string",
            "nullable": true
          },
          "registeredAddress": {
            "$ref": "#/components/schemas/RegistryAddress"
          },
          "companyActivity": {
            "type": "object",
            "properties": {
              "description": {
                "type": "string",
                "nullable": true
              },
              "sicCodes": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "activities": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              }
            }
          },
          "directors": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "nullable": true
                },
                "role": {
                  "type": "string",
                  "nullable": true
                },
                "type": {
                  "type": "string",
                  "nullable": true
                },
                "dateOfBirth": {
                  "type": "string",
                  "nullable": true
                },
                "nationality": {
                  "type": "string",
                  "nullable": true
                }
              }
            }
          },
          "shareholders": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "nullable": true
                },
                "type": {
                  "type": "string",
                  "nullable": true
                },
                "ownershipPercent": {
                  "type": "number",
                  "nullable": true
                },
                "nationality": {
                  "type": "string",
                  "nullable": true
                }
              }
            }
          },
          "directOwnership": {
            "type": "array",
            "description": "Holders with a known direct ownership percentage.",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "nullable": true
                },
                "type": {
                  "type": "string",
                  "nullable": true
                },
                "ownershipPercent": {
                  "type": "number",
                  "nullable": true
                }
              }
            }
          },
          "capital": {
            "type": "object",
            "nullable": true,
            "properties": {
              "currency": {
                "type": "string",
                "nullable": true
              },
              "amount": {
                "type": "number",
                "nullable": true
              }
            }
          },
          "registeredAgents": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "nullable": true
                },
                "role": {
                  "type": "string",
                  "nullable": true
                }
              }
            }
          },
          "jurisdiction": {
            "type": "object",
            "properties": {
              "country": {
                "type": "string",
                "nullable": true
              },
              "name": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "source": {
            "type": "object",
            "properties": {
              "registry": {
                "type": "string",
                "nullable": true
              },
              "code": {
                "type": "string",
                "nullable": true
              },
              "retrievedAt": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              }
            }
          }
        }
      },
      "RegistryUboEntity": {
        "type": "object",
        "description": "UBO UNWRAP entity — the resolved beneficial owners, the structured ownership graph, unresolved branches, non-continuation reasons, and the resolved entity count.",
        "required": [
          "schemaVersion",
          "tier",
          "subject",
          "ubos",
          "ownershipGraph",
          "unresolvedBranches",
          "entityCount",
          "source"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "examples": [
              "registry.entity/v1"
            ]
          },
          "tier": {
            "type": "string",
            "enum": [
              "ubo"
            ]
          },
          "subject": {
            "type": "object",
            "properties": {
              "legalName": {
                "type": "string",
                "nullable": true
              },
              "registrationNumber": {
                "type": "string",
                "nullable": true
              },
              "jurisdiction": {
                "type": "object",
                "properties": {
                  "country": {
                    "type": "string",
                    "nullable": true
                  },
                  "name": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          },
          "ubos": {
            "type": "array",
            "description": "Natural persons at/above the UBO threshold, with effective ownership through the chain.",
            "items": {
              "$ref": "#/components/schemas/OwnershipNaturalPerson"
            }
          },
          "ownershipGraph": {
            "type": "object",
            "properties": {
              "naturalPersons": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/OwnershipNaturalPerson"
                }
              },
              "corporateNodes": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string",
                      "nullable": true
                    },
                    "companyNumber": {
                      "type": "string",
                      "nullable": true
                    },
                    "jurisdiction": {
                      "type": "string",
                      "nullable": true
                    },
                    "ownershipPct": {
                      "type": "string",
                      "nullable": true
                    },
                    "effectivePct": {
                      "type": "number",
                      "nullable": true
                    },
                    "depth": {
                      "type": "number",
                      "nullable": true,
                      "description": "Depth of the company this node OWNS, so a direct parent of the searched company reads 0. To place a node in the structure use `chain` — its length is the layer."
                    },
                    "parentCompany": {
                      "type": "string",
                      "nullable": true
                    },
                    "chain": {
                      "type": "array",
                      "description": "The path from the searched company to this party, root first. Each link names the company, where it is registered, its registration number, and the percentage held in the link before it — so a chain can be followed, and a border crossing spotted, without joining any other array. Its length is the layer this party sits at.",
                      "items": {
                        "type": "object",
                        "properties": {
                          "company": {
                            "type": "string",
                            "nullable": true
                          },
                          "companyNumber": {
                            "type": "string",
                            "nullable": true,
                            "description": "Identifies the company where a name cannot: two companies can share a name."
                          },
                          "jurisdiction": {
                            "type": "string",
                            "nullable": true,
                            "description": "ISO-3166 alpha-2."
                          },
                          "ownershipPct": {
                            "type": "number",
                            "nullable": true,
                            "description": "Held in the preceding link. Null on the root."
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "unresolvedBranches": {
            "type": "array",
            "description": "Ownership branches the traversal could not continue through. A branch here does NOT mean there is no owner above it — read it alongside `nonContinuationReasons`. Where the branch stopped because the company was not found in the jurisdiction searched, `continuesIn` names where it picks up again.",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "nullable": true
                },
                "reason": {
                  "type": "string",
                  "nullable": true
                },
                "continuesIn": {
                  "type": "object",
                  "description": "Present only when the global LEI register places this company in a different jurisdiction from the one searched. Re-run the same lookup with `country` set to this value to continue the chain. Reporting only — no further lookup is performed and nothing extra is billed.",
                  "properties": {
                    "country": {
                      "type": "string",
                      "description": "ISO-3166 alpha-2."
                    },
                    "lei": {
                      "type": "string",
                      "nullable": true,
                      "description": "Identifies the company more reliably than the name that failed to resolve."
                    }
                  }
                }
              }
            }
          },
          "nonContinuationReasons": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "entityCount": {
            "type": "integer",
            "description": "Natural persons + corporate nodes resolved — the per-entity billing base."
          },
          "traversal": {
            "type": "object",
            "properties": {
              "uboThreshold": {
                "type": "number",
                "nullable": true
              },
              "maxLayers": {
                "type": "number",
                "nullable": true
              },
              "generatedAt": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "costCeiling": {
            "type": "object",
            "nullable": true,
            "properties": {
              "maxCreditCost": {
                "type": "number",
                "nullable": true
              }
            }
          },
          "source": {
            "type": "object",
            "properties": {
              "registry": {
                "type": "string",
                "nullable": true
              },
              "code": {
                "type": "string",
                "nullable": true
              },
              "retrievedAt": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              }
            }
          }
        }
      },
      "OwnershipNaturalPerson": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "nullable": true
          },
          "kind": {
            "type": "string",
            "nullable": true,
            "description": "e.g. individual, director_fallback."
          },
          "ownershipPct": {
            "type": "string",
            "nullable": true,
            "description": "Display band, e.g. \"25-50%\"."
          },
          "effectivePct": {
            "type": "number",
            "nullable": true,
            "description": "Numeric effective ownership % through the chain."
          },
          "isUbo": {
            "type": "boolean"
          },
          "nationality": {
            "type": "string",
            "nullable": true
          },
          "dateOfBirth": {
            "type": "string",
            "nullable": true
          },
          "country": {
            "type": "string",
            "nullable": true
          },
          "chain": {
            "type": "array",
            "description": "The path from the searched company to this party, root first. Each link names the company, where it is registered, its registration number, and the percentage held in the link before it — so a chain can be followed, and a border crossing spotted, without joining any other array. Its length is the layer this party sits at.",
            "items": {
              "type": "object",
              "properties": {
                "company": {
                  "type": "string",
                  "nullable": true
                },
                "companyNumber": {
                  "type": "string",
                  "nullable": true,
                  "description": "Identifies the company where a name cannot: two companies can share a name."
                },
                "jurisdiction": {
                  "type": "string",
                  "nullable": true,
                  "description": "ISO-3166 alpha-2."
                },
                "ownershipPct": {
                  "type": "number",
                  "nullable": true,
                  "description": "Held in the preceding link. Null on the root."
                }
              }
            }
          }
        }
      },
      "RegistryJob": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "succeeded",
              "failed"
            ]
          },
          "tier": {
            "type": "string",
            "enum": [
              "lite",
              "enhanced",
              "ubo"
            ]
          },
          "params": {
            "type": "object",
            "nullable": true,
            "description": "The lookup as submitted. null once the job has expired."
          },
          "sandbox": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "startedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "finishedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "result": {
            "type": "object",
            "description": "Present only when status is succeeded and the job has not expired. Same shape the synchronous endpoint returns."
          },
          "error": {
            "type": "string",
            "description": "Present only when status is failed. `job_timeout`: the job could not finish (its worker died on the last attempt, or it was still unfinished 24 hours after submission). `workspace_deactivated` or `workspace_deactivated_expired`: the workspace was deactivated before the job ran, so it did not run and nothing was billed. It stays failed if the workspace is reactivated: submit a new job with a new Idempotency-Key."
          },
          "errorDescription": {
            "type": "string",
            "nullable": true
          },
          "expiredAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the job's params, result and errorDescription were deleted, 7 days after finishedAt."
          }
        },
        "required": [
          "id",
          "status",
          "tier"
        ]
      }
    }
  }
}