{
  "openapi": "3.1.0",
  "info": {
    "title": "VerifySanctions API",
    "version": "1.0.0",
    "summary": "Sanctions screening with an immutable record for every screening.",
    "description": "Screen names and identifiers against the OFAC SDN and Consolidated (non-SDN) lists, keep every\nscreening as an append-only record, monitor counterparties, and receive signed webhooks when\nanything changes.\n\n**Unavailable is never clean.** When a list failed to ingest, is stale, or was not ingested at\nthe requested time, that list's outcome is `list_unavailable` and the screening's outcome is\nnever `no_match`.\n\n**Every screening is a record.** Every screening response carries a `record_id`. Records are\nappend-only and verifiable by anyone at `verify_url`.\n\nAuthentication: `Authorization: Bearer <api key>`. Keys are per organisation, scoped, shown\nonce at creation and revocable.\n\nIdempotency: send `Idempotency-Key` on any POST. A retry with the same key and the same body\nreplays the stored response (header `Idempotent-Replayed: true`); the same key with a\ndifferent body is a `409`. Keys are kept for 24 hours.\n\nRate limits are per organisation and plan. Every authenticated response carries\n`RateLimit-Limit`, `RateLimit-Remaining`, `RateLimit-Reset` and `RateLimit-Policy`; a `429`\nalso carries `Retry-After`.\n\nNot legal advice. A candidate is a lead for a person to review, not a finding.\n",
    "license": {
      "name": "Proprietary",
      "identifier": "LicenseRef-VerifySanctions"
    }
  },
  "servers": [
    {
      "url": "{origin}",
      "description": "The domain is not final (issue",
      "variables": {
        "origin": {
          "default": "https://verifysanctions.com"
        }
      }
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "tags": [
    {
      "name": "screening"
    },
    {
      "name": "records"
    },
    {
      "name": "lists"
    },
    {
      "name": "monitoring"
    },
    {
      "name": "webhooks"
    },
    {
      "name": "keys"
    }
  ],
  "paths": {
    "/v1/screen": {
      "post": {
        "tags": [
          "screening"
        ],
        "operationId": "screen",
        "summary": "Screen one party now",
        "description": "Screens against every list, appends a record, and returns the candidates with their explanation. Scope `screen`.",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ScreenRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/Screening"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "get": {
        "tags": [
          "screening"
        ],
        "operationId": "screenAsOf",
        "summary": "Screen one party, optionally as of a past time",
        "description": "With `as_of`, screens against the list versions we held at that time (our observation time,\nnot the publisher's date of issue), and the list's freshness as it stood then. A list we had\nnot ingested, or held stale, at that time is `list_unavailable`. The screening is recorded\nlike any other; the record states `as_of`. Scope `screen`.\n",
        "parameters": [
          {
            "name": "name",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/PartyType"
            }
          },
          {
            "name": "date_of_birth",
            "in": "query",
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{4}(-[0-9]{2}(-[0-9]{2})?)?$"
            }
          },
          {
            "name": "country",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 60
            }
          },
          {
            "name": "identifier",
            "in": "query",
            "description": "Repeatable. `value`, or `kind:value` with kind document, imo, digital_currency_address or call_sign.",
            "style": "form",
            "explode": true,
            "schema": {
              "type": "array",
              "maxItems": 10,
              "items": {
                "type": "string",
                "maxLength": 130
              }
            }
          },
          {
            "name": "reference",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "as_of",
            "in": "query",
            "description": "ISO-8601 date-time or date (UTC midnight). Must not be in the future.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/Screening"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/screen/batch": {
      "post": {
        "tags": [
          "screening"
        ],
        "operationId": "screenBatch",
        "summary": "Screen many parties asynchronously",
        "description": "Accepts up to 10,000 items, creates one record per item, and fires `batch.completed` when every\nitem is done. Work starts at once and continues in the background; poll\n`GET /v1/screen/batch/{batch_id}` or subscribe to the webhook. Scope `screen`.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BatchRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted. Some items may already be done.",
            "headers": {
              "Location": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Batch"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "413": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/screen/batch/{batch_id}": {
      "get": {
        "tags": [
          "screening"
        ],
        "operationId": "getBatch",
        "summary": "Batch progress and per-item results",
        "parameters": [
          {
            "name": "batch_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^bat_[a-z2-7]{26}$"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The batch with a page of its items.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Batch"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/records": {
      "get": {
        "tags": [
          "records"
        ],
        "operationId": "listRecords",
        "summary": "Records of your organisation, oldest first",
        "description": "Scope `read`.",
        "parameters": [
          {
            "name": "since",
            "in": "query",
            "description": "ISO-8601 date-time; records recorded at or after it.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "starting_after",
            "in": "query",
            "description": "A record id from the previous page (`next_cursor`).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of record summaries.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "records",
                    "next_cursor"
                  ],
                  "properties": {
                    "records": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/RecordSummary"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/records/{record_id}": {
      "get": {
        "tags": [
          "records"
        ],
        "operationId": "getRecord",
        "summary": "One record with its decisions and integrity check",
        "parameters": [
          {
            "name": "record_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The record.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScreeningRecord"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/lists": {
      "get": {
        "tags": [
          "lists"
        ],
        "operationId": "listLists",
        "summary": "Lists, their availability now and their version history",
        "parameters": [
          {
            "name": "versions",
            "in": "query",
            "description": "How many recent versions to return per list.",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 200,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Every list we screen against.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "lists"
                  ],
                  "properties": {
                    "lists": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ListInfo"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/lists/{list}/changes": {
      "get": {
        "tags": [
          "lists"
        ],
        "operationId": "listChanges",
        "summary": "Entries added, removed and modified by each version",
        "parameters": [
          {
            "name": "list",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/ListId"
            }
          },
          {
            "name": "since",
            "in": "query",
            "description": "ISO-8601 date-time; versions we fetched after it.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Versions with their deltas, oldest first.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "list",
                    "changes"
                  ],
                  "properties": {
                    "list": {
                      "$ref": "#/components/schemas/ListId"
                    },
                    "changes": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ListChange"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/entities/{uid}": {
      "get": {
        "tags": [
          "lists"
        ],
        "operationId": "getEntity",
        "summary": "One listed entry, current or delisted, with its history",
        "parameters": [
          {
            "name": "uid",
            "in": "path",
            "required": true,
            "description": "`<list>:<entry id>` (e.g. `ofac_sdn:6903`), or the entry id alone when it is unique across lists.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The entry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Entity"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/counterparties": {
      "post": {
        "tags": [
          "monitoring"
        ],
        "operationId": "addCounterparties",
        "summary": "Add or update monitored counterparties",
        "description": "Validates each row; bad rows are reported and skipped. A row whose `external_ref` exists\nwith changed content appends a new version. New and changed counterparties are screened\nstraight away (the scheduler finishes large imports). Scope `monitor`.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "counterparties"
                ],
                "properties": {
                  "counterparties": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 50000,
                    "items": {
                      "$ref": "#/components/schemas/CounterpartyInput"
                    }
                  },
                  "dry_run": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Import result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImportResult"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "413": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "description": "No row was valid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImportResult"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "get": {
        "tags": [
          "monitoring"
        ],
        "operationId": "listCounterparties",
        "summary": "Monitored counterparties with their status",
        "description": "A counterparty is never `clear` while a list is unavailable now or was at its last screening. Scope `read`.",
        "responses": {
          "200": {
            "description": "The portfolio.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Portfolio"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/alerts": {
      "get": {
        "tags": [
          "monitoring"
        ],
        "operationId": "listAlerts",
        "summary": "Alerts and their candidates, open first",
        "description": "Scope `read`.",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "all"
              ],
              "default": "open"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Alerts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "four_eyes",
                    "alerts"
                  ],
                  "properties": {
                    "four_eyes": {
                      "type": "boolean"
                    },
                    "alerts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Alert"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/alerts/{alert_id}/decisions": {
      "post": {
        "tags": [
          "monitoring"
        ],
        "operationId": "decideAlert",
        "summary": "Record a person's decision on one candidate",
        "description": "`reviewer` must name a person; AI never clears a hit. With four-eyes on, `false_positive`\nand `true_match` wait for a second reviewer. Fires `alert.adjudicated` on a final decision.\nScope `monitor`.\n",
        "parameters": [
          {
            "name": "alert_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "list",
                  "entry_id",
                  "decision",
                  "rationale",
                  "reviewer"
                ],
                "properties": {
                  "list": {
                    "$ref": "#/components/schemas/ListId"
                  },
                  "entry_id": {
                    "type": "string"
                  },
                  "decision": {
                    "type": "string",
                    "enum": [
                      "false_positive",
                      "true_match",
                      "escalated"
                    ]
                  },
                  "rationale": {
                    "type": "string",
                    "minLength": 1
                  },
                  "reviewer": {
                    "type": "string",
                    "minLength": 1
                  },
                  "ai_draft_id": {
                    "type": "integer"
                  },
                  "suppress_days": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 366
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The candidate's status after the decision.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "adjudication_id",
                    "suppression_id"
                  ],
                  "properties": {
                    "status": {
                      "$ref": "#/components/schemas/CandidateStatus"
                    },
                    "adjudication_id": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "suppression_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/webhooks": {
      "get": {
        "tags": [
          "webhooks"
        ],
        "operationId": "listWebhooks",
        "summary": "Webhook endpoints of your organisation",
        "responses": {
          "200": {
            "description": "Endpoints.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "webhooks"
                  ],
                  "properties": {
                    "webhooks": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Webhook"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "tags": [
          "webhooks"
        ],
        "operationId": "createWebhook",
        "summary": "Subscribe an HTTPS endpoint to events",
        "description": "Returns the signing secret once. Each delivery is `POST` JSON with\n`X-VerifySanctions-Signature: t=<unix>,v1=<hex>` where `v1 = HMAC-SHA256(secret, \"<t>.<raw body>\")`,\nand `X-VerifySanctions-Event-Id`; deduplicate on the event id. Retried after 1 min, 5 min,\n30 min, 2 h and 12 h. Also the REST-hook subscribe call for Zapier and Make. Scope `webhooks`.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url",
                  "events"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "events": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "$ref": "#/components/schemas/EventType"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created. Store `signing_secret` now; it is not shown again.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Webhook"
                    },
                    {
                      "type": "object",
                      "required": [
                        "signing_secret"
                      ],
                      "properties": {
                        "signing_secret": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/webhooks/{webhook_id}": {
      "delete": {
        "tags": [
          "webhooks"
        ],
        "operationId": "deleteWebhook",
        "summary": "Unsubscribe an endpoint",
        "description": "The REST-hook unsubscribe call. Pending deliveries to it stop. Scope `webhooks`.",
        "parameters": [
          {
            "name": "webhook_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Disabled.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "disabled"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "disabled": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/webhooks/deliveries": {
      "get": {
        "tags": [
          "webhooks"
        ],
        "operationId": "listDeliveries",
        "summary": "Delivery log, newest first",
        "responses": {
          "200": {
            "description": "Deliveries.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "deliveries"
                  ],
                  "properties": {
                    "deliveries": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Delivery"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/webhooks/deliveries/{delivery_id}/replay": {
      "post": {
        "tags": [
          "webhooks"
        ],
        "operationId": "replayDelivery",
        "summary": "Send an event again",
        "description": "A new delivery of the same event id to the same endpoint. Scope `webhooks`.",
        "parameters": [
          {
            "name": "delivery_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "201": {
            "description": "Queued (or held, with the reason).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "status",
                    "held_reason"
                  ],
                  "properties": {
                    "id": {
                      "type": "integer"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "pending",
                        "held"
                      ]
                    },
                    "held_reason": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/api-keys": {
      "get": {
        "tags": [
          "keys"
        ],
        "operationId": "listApiKeys",
        "summary": "Keys of your organisation (never the secrets)",
        "description": "Scope `keys`.",
        "responses": {
          "200": {
            "description": "Keys.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "api_keys"
                  ],
                  "properties": {
                    "api_keys": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ApiKey"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "tags": [
          "keys"
        ],
        "operationId": "createApiKey",
        "summary": "Create a key (rotation is create, then revoke the old one)",
        "description": "Scope `keys`. A key cannot grant scopes its creator lacks.",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "scopes": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/Scope"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created. `secret` is shown once and never stored.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/ApiKey"
                    },
                    {
                      "type": "object",
                      "required": [
                        "secret"
                      ],
                      "properties": {
                        "secret": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/api-keys/{key_id}": {
      "delete": {
        "tags": [
          "keys"
        ],
        "operationId": "revokeApiKey",
        "summary": "Revoke a key",
        "description": "Takes effect on the next request. Scope `keys`.",
        "parameters": [
          {
            "name": "key_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiKey"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    }
  },
  "webhooks": {
    "event": {
      "post": {
        "operationId": "onEvent",
        "summary": "An event delivered to your endpoint",
        "description": "Verify `X-VerifySanctions-Signature` before trusting the body. Respond 2xx; redirects are not followed.",
        "parameters": [
          {
            "name": "X-VerifySanctions-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-VerifySanctions-Event-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Event"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API key, `vsk_...`."
      }
    },
    "parameters": {
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": false,
        "description": "1 to 255 printable characters. Kept for 24 hours per organisation.",
        "schema": {
          "type": "string",
          "minLength": 1,
          "maxLength": 255
        }
      }
    },
    "headers": {
      "RateLimit-Limit": {
        "schema": {
          "type": "integer"
        }
      },
      "RateLimit-Remaining": {
        "schema": {
          "type": "integer"
        }
      },
      "RateLimit-Reset": {
        "description": "Seconds until the window resets.",
        "schema": {
          "type": "integer"
        }
      },
      "RateLimit-Policy": {
        "schema": {
          "type": "string"
        }
      }
    },
    "responses": {
      "Screening": {
        "description": "The screening and its record.",
        "headers": {
          "RateLimit-Limit": {
            "$ref": "#/components/headers/RateLimit-Limit"
          },
          "RateLimit-Remaining": {
            "$ref": "#/components/headers/RateLimit-Remaining"
          },
          "RateLimit-Reset": {
            "$ref": "#/components/headers/RateLimit-Reset"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Screening"
            }
          }
        }
      },
      "Error": {
        "description": "An error.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Over the plan's request rate.",
        "headers": {
          "Retry-After": {
            "description": "Seconds to wait.",
            "schema": {
              "type": "integer"
            }
          },
          "RateLimit-Limit": {
            "$ref": "#/components/headers/RateLimit-Limit"
          },
          "RateLimit-Remaining": {
            "$ref": "#/components/headers/RateLimit-Remaining"
          },
          "RateLimit-Reset": {
            "$ref": "#/components/headers/RateLimit-Reset"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      }
    },
    "schemas": {
      "ApiError": {
        "type": "object",
        "required": [
          "error",
          "message"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Machine-readable code: unauthorized, api_key_revoked, forbidden, invalid_request, not_found,\nambiguous_uid, idempotency_key_reused, idempotency_key_in_progress, rate_limited,\npayload_too_large, unavailable, database_unavailable, internal.\n"
          },
          "message": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RowError"
            }
          }
        }
      },
      "ListId": {
        "type": "string",
        "enum": [
          "ofac_sdn",
          "ofac_cons"
        ]
      },
      "PartyType": {
        "type": "string",
        "enum": [
          "individual",
          "entity",
          "vessel",
          "aircraft",
          "unknown"
        ]
      },
      "IdentifierKind": {
        "type": "string",
        "enum": [
          "document",
          "imo",
          "digital_currency_address",
          "call_sign"
        ]
      },
      "Identifier": {
        "type": "object",
        "required": [
          "value"
        ],
        "properties": {
          "value": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "kind": {
            "$ref": "#/components/schemas/IdentifierKind"
          }
        }
      },
      "ScreenRequest": {
        "type": "object",
        "description": "A name, an identifier, or both.",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 200
          },
          "type": {
            "$ref": "#/components/schemas/PartyType"
          },
          "date_of_birth": {
            "type": "string",
            "pattern": "^[0-9]{4}(-[0-9]{2}(-[0-9]{2})?)?$"
          },
          "country": {
            "type": "string",
            "maxLength": 60
          },
          "identifiers": {
            "type": "array",
            "maxItems": 10,
            "items": {
              "$ref": "#/components/schemas/Identifier"
            }
          },
          "reference": {
            "type": "string",
            "maxLength": 200,
            "description": "Your own id for this screening; echoed back and in webhooks. Not part of the record."
          }
        }
      },
      "BatchRequest": {
        "type": "object",
        "required": [
          "items"
        ],
        "properties": {
          "items": {
            "type": "array",
            "minItems": 1,
            "maxItems": 10000,
            "items": {
              "$ref": "#/components/schemas/ScreenRequest"
            }
          }
        }
      },
      "Outcome": {
        "type": "string",
        "enum": [
          "potential_match",
          "no_match",
          "list_unavailable"
        ]
      },
      "ListOutcome": {
        "type": "string",
        "enum": [
          "match",
          "no_match",
          "list_unavailable"
        ]
      },
      "ListVersion": {
        "type": "object",
        "required": [
          "id",
          "date_of_issue",
          "last_successful_check"
        ],
        "properties": {
          "id": {
            "type": [
              "string",
              "null"
            ]
          },
          "date_of_issue": {
            "type": [
              "string",
              "null"
            ],
            "description": "Publisher's date of issue."
          },
          "last_successful_check": {
            "type": [
              "string",
              "null"
            ],
            "description": "Our last successful ingestion check."
          }
        }
      },
      "ListResult": {
        "type": "object",
        "required": [
          "list",
          "outcome",
          "reasons",
          "version",
          "candidates_scored"
        ],
        "properties": {
          "list": {
            "type": "string"
          },
          "outcome": {
            "$ref": "#/components/schemas/ListOutcome"
          },
          "reasons": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "version": {
            "$ref": "#/components/schemas/ListVersion"
          },
          "candidates_scored": {
            "type": "integer"
          }
        }
      },
      "Match": {
        "type": "object",
        "required": [
          "list",
          "entry_id",
          "uid",
          "primary_name",
          "party_type",
          "programs",
          "score",
          "band",
          "matched_by",
          "matched_name",
          "identifier_hits",
          "explanation",
          "explain"
        ],
        "properties": {
          "list": {
            "type": "string"
          },
          "entry_id": {
            "type": "string"
          },
          "uid": {
            "type": "string",
            "description": "Pass to GET /v1/entities/{uid}."
          },
          "primary_name": {
            "type": "string"
          },
          "party_type": {
            "type": "string"
          },
          "programs": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "score": {
            "type": "number"
          },
          "band": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "likely",
              "review",
              null
            ]
          },
          "matched_by": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "name",
                "identifier"
              ]
            }
          },
          "matched_name": {
            "type": [
              "object",
              "null"
            ],
            "required": [
              "full",
              "alias_type",
              "quality"
            ],
            "properties": {
              "full": {
                "type": "string"
              },
              "alias_type": {
                "type": "string"
              },
              "quality": {
                "type": "string",
                "enum": [
                  "strong",
                  "weak"
                ]
              },
              "script": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "identifier_hits": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "explanation": {
            "type": "array",
            "description": "Plain-language reasons, one per contributing factor.",
            "items": {
              "type": "string"
            }
          },
          "explain": {
            "type": "object",
            "description": "Every score component, token alignment and adjustment, as the matcher computed them.",
            "additionalProperties": true
          }
        }
      },
      "Screening": {
        "type": "object",
        "required": [
          "record_id",
          "verify_url",
          "content_hash",
          "outcome",
          "outcome_sentence",
          "complete",
          "screened_at",
          "as_of",
          "reference",
          "matcher_version",
          "thresholds",
          "lists",
          "matches",
          "warnings"
        ],
        "properties": {
          "record_id": {
            "type": "string",
            "pattern": "^rec_[a-z2-7]{26}$"
          },
          "verify_url": {
            "type": "string"
          },
          "pdf_url": {
            "type": "string",
            "description": "Carries a one-time access token; shown only in this response. Treat it as private."
          },
          "content_hash": {
            "type": "string"
          },
          "outcome": {
            "$ref": "#/components/schemas/Outcome"
          },
          "outcome_sentence": {
            "type": "string"
          },
          "complete": {
            "type": "boolean",
            "description": "False whenever any list was unavailable."
          },
          "screened_at": {
            "type": "string"
          },
          "as_of": {
            "type": [
              "string",
              "null"
            ]
          },
          "reference": {
            "type": [
              "string",
              "null"
            ]
          },
          "matcher_version": {
            "type": "string"
          },
          "thresholds": {
            "type": "object",
            "required": [
              "min_score",
              "review",
              "likely"
            ],
            "properties": {
              "min_score": {
                "type": "number"
              },
              "review": {
                "type": "number"
              },
              "likely": {
                "type": "number"
              }
            }
          },
          "lists": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ListResult"
            }
          },
          "matches": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Match"
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "BatchItem": {
        "type": "object",
        "required": [
          "index",
          "reference",
          "status",
          "record_id",
          "outcome",
          "match_count",
          "error"
        ],
        "properties": {
          "index": {
            "type": "integer"
          },
          "reference": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "running",
              "done",
              "failed"
            ]
          },
          "record_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "outcome": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Outcome"
              },
              {
                "type": "null"
              }
            ]
          },
          "match_count": {
            "type": [
              "integer",
              "null"
            ]
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "Batch": {
        "type": "object",
        "required": [
          "batch_id",
          "status",
          "total",
          "done",
          "failed",
          "counts",
          "created_at",
          "finished_at",
          "items"
        ],
        "properties": {
          "batch_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "running",
              "completed"
            ]
          },
          "total": {
            "type": "integer"
          },
          "done": {
            "type": "integer"
          },
          "failed": {
            "type": "integer"
          },
          "counts": {
            "type": "object",
            "required": [
              "potential_match",
              "no_match",
              "list_unavailable"
            ],
            "properties": {
              "potential_match": {
                "type": "integer"
              },
              "no_match": {
                "type": "integer"
              },
              "list_unavailable": {
                "type": "integer"
              }
            }
          },
          "created_at": {
            "type": "string"
          },
          "finished_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BatchItem"
            }
          }
        }
      },
      "RecordSummary": {
        "type": "object",
        "required": [
          "record_id",
          "recorded_at",
          "source",
          "outcome",
          "complete",
          "match_count",
          "subject_ref",
          "as_of",
          "verify_url"
        ],
        "properties": {
          "record_id": {
            "type": "string"
          },
          "recorded_at": {
            "type": "string"
          },
          "source": {
            "type": "string",
            "enum": [
              "web",
              "api",
              "batch",
              "monitor"
            ]
          },
          "outcome": {
            "$ref": "#/components/schemas/Outcome"
          },
          "complete": {
            "type": "boolean"
          },
          "match_count": {
            "type": "integer"
          },
          "subject_ref": {
            "type": [
              "string",
              "null"
            ]
          },
          "as_of": {
            "type": [
              "string",
              "null"
            ]
          },
          "verify_url": {
            "type": "string"
          }
        }
      },
      "Decision": {
        "type": "object",
        "required": [
          "id",
          "list",
          "entry_id",
          "decision",
          "rationale",
          "reviewer",
          "ai",
          "supersedes",
          "created_at",
          "in_force"
        ],
        "properties": {
          "id": {
            "type": "integer"
          },
          "list": {
            "type": "string"
          },
          "entry_id": {
            "type": "string"
          },
          "decision": {
            "type": "string",
            "enum": [
              "false_positive",
              "true_match",
              "escalated"
            ]
          },
          "rationale": {
            "type": "string"
          },
          "reviewer": {
            "type": "string"
          },
          "ai": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true
          },
          "supersedes": {
            "type": [
              "integer",
              "null"
            ]
          },
          "created_at": {
            "type": "string"
          },
          "in_force": {
            "type": "boolean",
            "description": "True for the decision currently in force on this candidate; corrections supersede."
          }
        }
      },
      "ScreeningRecord": {
        "allOf": [
          {
            "$ref": "#/components/schemas/RecordSummary"
          },
          {
            "type": "object",
            "required": [
              "content_hash",
              "content_hash_matches",
              "chain_intact",
              "retain_until",
              "result",
              "decisions"
            ],
            "properties": {
              "content_hash": {
                "type": "string"
              },
              "content_hash_matches": {
                "type": "boolean"
              },
              "chain_intact": {
                "type": "boolean"
              },
              "retain_until": {
                "type": "string"
              },
              "result": {
                "type": "object",
                "description": "Exactly what the matcher returned, as hashed into the record.",
                "additionalProperties": true
              },
              "decisions": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Decision"
                }
              }
            }
          }
        ]
      },
      "ListInfo": {
        "type": "object",
        "required": [
          "list",
          "available",
          "reasons",
          "current_version",
          "versions"
        ],
        "properties": {
          "list": {
            "$ref": "#/components/schemas/ListId"
          },
          "available": {
            "type": "boolean"
          },
          "reasons": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "current_version": {
            "$ref": "#/components/schemas/ListVersion"
          },
          "versions": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "version_id",
                "date_of_issue",
                "fetched_at",
                "counts"
              ],
              "properties": {
                "version_id": {
                  "type": "string"
                },
                "date_of_issue": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "fetched_at": {
                  "type": "string"
                },
                "counts": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      },
      "ListChange": {
        "type": "object",
        "required": [
          "version_id",
          "from_version",
          "date_of_issue",
          "fetched_at",
          "added",
          "removed",
          "modified"
        ],
        "properties": {
          "version_id": {
            "type": "string"
          },
          "from_version": {
            "type": [
              "string",
              "null"
            ]
          },
          "date_of_issue": {
            "type": [
              "string",
              "null"
            ]
          },
          "fetched_at": {
            "type": "string"
          },
          "added": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "removed": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "modified": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "entry_id",
                "fields"
              ],
              "properties": {
                "entry_id": {
                  "type": "string"
                },
                "fields": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      },
      "Entity": {
        "type": "object",
        "required": [
          "uid",
          "list",
          "entry_id",
          "status",
          "primary_name",
          "party_type",
          "programs",
          "names",
          "identifiers",
          "birthdates",
          "countries",
          "entry",
          "history"
        ],
        "properties": {
          "uid": {
            "type": "string"
          },
          "list": {
            "$ref": "#/components/schemas/ListId"
          },
          "entry_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "listed",
              "delisted"
            ]
          },
          "primary_name": {
            "type": "string"
          },
          "party_type": {
            "type": "string"
          },
          "programs": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "names": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "identifiers": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "birthdates": {
            "type": "array",
            "items": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          "countries": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "entry": {
            "type": "object",
            "description": "The parsed advanced-XML party, values verbatim.",
            "additionalProperties": true
          },
          "history": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "observed_from",
                "observed_to",
                "from_version",
                "to_version",
                "content_hash"
              ],
              "properties": {
                "observed_from": {
                  "type": "string"
                },
                "observed_to": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "from_version": {
                  "type": "string"
                },
                "to_version": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "content_hash": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "CounterpartyInput": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "type": {
            "$ref": "#/components/schemas/PartyType"
          },
          "country": {
            "type": "string"
          },
          "date_of_birth": {
            "type": "string"
          },
          "identifiers": {
            "type": "array",
            "maxItems": 10,
            "items": {
              "$ref": "#/components/schemas/Identifier"
            }
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "employee",
                "vendor",
                "customer",
                "carrier",
                "end_user"
              ]
            }
          },
          "owner": {
            "type": "string"
          },
          "notes": {
            "type": "string"
          },
          "external_ref": {
            "type": "string"
          }
        }
      },
      "RowError": {
        "type": "object",
        "required": [
          "row",
          "field",
          "message"
        ],
        "properties": {
          "row": {
            "type": "integer"
          },
          "field": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "ImportResult": {
        "type": "object",
        "required": [
          "added",
          "updated",
          "unchanged",
          "errors",
          "screening"
        ],
        "properties": {
          "added": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "updated": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "unchanged": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "errors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RowError"
            }
          },
          "screening": {
            "type": [
              "object",
              "null"
            ],
            "required": [
              "screened",
              "remaining"
            ],
            "properties": {
              "screened": {
                "type": "integer"
              },
              "remaining": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "PortfolioStatus": {
        "type": "string",
        "enum": [
          "pending",
          "list_unavailable",
          "potential_match",
          "true_match",
          "clear"
        ]
      },
      "Portfolio": {
        "type": "object",
        "required": [
          "lists",
          "counts",
          "counterparties"
        ],
        "properties": {
          "lists": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "counts": {
            "type": "object",
            "additionalProperties": {
              "type": "integer"
            }
          },
          "counterparties": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "counterparty_id",
                "external_ref",
                "name",
                "tags",
                "status",
                "reason",
                "last_screened_at",
                "record_id",
                "open_candidates"
              ],
              "properties": {
                "counterparty_id": {
                  "type": "string"
                },
                "external_ref": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "name": {
                  "type": "string"
                },
                "tags": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "status": {
                  "$ref": "#/components/schemas/PortfolioStatus"
                },
                "reason": {
                  "type": "string"
                },
                "last_screened_at": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "record_id": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "open_candidates": {
                  "type": "integer"
                }
              }
            }
          }
        }
      },
      "CandidateStatus": {
        "type": "string",
        "enum": [
          "open",
          "awaiting_second_review",
          "escalated",
          "false_positive",
          "true_match"
        ]
      },
      "Alert": {
        "type": "object",
        "required": [
          "alert_id",
          "counterparty_id",
          "counterparty_name",
          "record_id",
          "trigger",
          "created_at",
          "candidates"
        ],
        "properties": {
          "alert_id": {
            "type": "string"
          },
          "counterparty_id": {
            "type": "string"
          },
          "counterparty_name": {
            "type": "string"
          },
          "record_id": {
            "type": "string"
          },
          "trigger": {
            "type": "string",
            "enum": [
              "initial",
              "delta",
              "full"
            ]
          },
          "created_at": {
            "type": "string"
          },
          "candidates": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "list",
                "entry_id",
                "name",
                "score",
                "band",
                "status",
                "explanation",
                "drafts"
              ],
              "properties": {
                "list": {
                  "type": "string"
                },
                "entry_id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "score": {
                  "type": "number"
                },
                "band": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "status": {
                  "$ref": "#/components/schemas/CandidateStatus"
                },
                "explanation": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "drafts": {
                  "type": "array",
                  "description": "AI proposals, labelled with model, version and prompt hash. Never a decision.",
                  "items": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              }
            }
          }
        }
      },
      "EventType": {
        "type": "string",
        "enum": [
          "list.updated",
          "screening.completed",
          "match.found",
          "alert.created",
          "alert.adjudicated",
          "counterparty.status_changed",
          "batch.completed",
          "certificate.issued"
        ]
      },
      "Webhook": {
        "type": "object",
        "required": [
          "id",
          "url",
          "events",
          "created_at",
          "disabled"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EventType"
            }
          },
          "created_at": {
            "type": "string"
          },
          "disabled": {
            "type": "boolean"
          }
        }
      },
      "Delivery": {
        "type": "object",
        "required": [
          "id",
          "event_id",
          "event_type",
          "webhook_id",
          "status",
          "held_reason",
          "attempts",
          "next_attempt_at",
          "replay_of",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "integer"
          },
          "event_id": {
            "type": "string"
          },
          "event_type": {
            "type": "string"
          },
          "webhook_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "delivered",
              "failed",
              "held"
            ]
          },
          "held_reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "attempts": {
            "type": "integer"
          },
          "next_attempt_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "replay_of": {
            "type": [
              "integer",
              "null"
            ]
          },
          "created_at": {
            "type": "string"
          }
        }
      },
      "Event": {
        "type": "object",
        "required": [
          "id",
          "type",
          "created_at",
          "data"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Stable across retries and replays; deduplicate on it."
          },
          "type": {
            "$ref": "#/components/schemas/EventType"
          },
          "created_at": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "Scope": {
        "type": "string",
        "enum": [
          "screen",
          "read",
          "monitor",
          "webhooks",
          "keys"
        ]
      },
      "ApiKey": {
        "type": "object",
        "required": [
          "id",
          "name",
          "prefix",
          "scopes",
          "created_at",
          "created_by",
          "revoked_at",
          "last_used_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "prefix": {
            "type": "string",
            "description": "The first characters of the key, for recognising it."
          },
          "scopes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Scope"
            }
          },
          "created_at": {
            "type": "string"
          },
          "created_by": {
            "type": "string"
          },
          "revoked_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "last_used_at": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      }
    }
  }
}