{
  "openapi": "3.1.0",
  "info": {
    "title": "OHN-05 Health Facility Registry",
    "version": "1.4.0",
    "description": "Base path /api/ohn/v1. Every POST requires Idempotency-Key; mutations use expected_version. Routes default-deny on role AND purpose. Every facility carries a human-readable facility_code (TYPE-CC-RRRRK, e.g. PHA-CM-7K4QX; docs/program/java/facility-codes.md); the UUID id stays the key every module links by. Facility branding (1.2.0): the facility logo (PNG/JPEG/SVG, max 256 KiB, type from the bytes, SVG sanitised) is uploaded by the facility's own administrator (role facility_administrator, purpose facility_branding) and approved or rejected by a registry reviewer who did not upload it; only an approved logo is served (public GET /facilities/{id}/branding and /facilities/{id}/logo). The branding watermark is a facility setting, off by default and forced off without an approved logo."
  },
  "servers": [
    {
      "url": "/api/ohn/v1"
    }
  ],
  "paths": {
    "/facilities": {
      "post": {
        "operationId": "enrollFacility",
        "summary": "Enrol a facility (OHN-05-API-001)",
        "tags": [
          "OHN-05"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "422": {
            "description": "Domain refusal or dependency unavailable; facility_type_unmapped when the site type has no facility-code prefix",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Domain refusal or dependency unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FacilityEnrollment"
              }
            }
          }
        }
      },
      "get": {
        "operationId": "listFacilities",
        "summary": "List facilities (status, site_type, q, region, code, cursor filters)",
        "tags": [
          "OHN-05"
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 32
            }
          },
          {
            "name": "site_type",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          },
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 128
            }
          },
          {
            "name": "region",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 128
            }
          },
          {
            "name": "code",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 10,
              "maxLength": 32,
              "description": "Facility code, any case, with or without dashes; O is read as 0 and I/L as 1 in the last five characters."
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "429": {
            "description": "Rate limited"
          },
          "422": {
            "description": "invalid_facility_code (malformed code or wrong check character) or domain validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/facilities/{id}": {
      "get": {
        "operationId": "facilityProfile",
        "summary": "Facility profile",
        "tags": [
          "OHN-05"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    },
    "/facilities/{id}/evidence": {
      "get": {
        "operationId": "facilityEvidence",
        "summary": "Evidence references",
        "tags": [
          "OHN-05"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    },
    "/facilities/{id}/hierarchy": {
      "get": {
        "operationId": "facilityHierarchy",
        "summary": "Published hierarchy",
        "tags": [
          "OHN-05"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    },
    "/facilities/{id}/licenses": {
      "get": {
        "operationId": "listLicenses",
        "summary": "Licences",
        "tags": [
          "OHN-05"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    },
    "/facilities/{id}/verify": {
      "post": {
        "operationId": "verifyFacility",
        "summary": "Credential verification",
        "tags": [
          "OHN-05"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CredentialVerification"
              }
            }
          }
        },
        "description": "1.4.0: manual licence confirmation (confirmation_reference) while no regulator API exists; the licence view carries license_confirmation {method regulator|manual|none, label, reference, confirmed_by, confirmed_at} and the facility profile lists it per licence."
      }
    },
    "/facilities/{id}/suspend": {
      "post": {
        "operationId": "suspendFacility",
        "summary": "Suspend facility",
        "tags": [
          "OHN-05"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Suspend"
              }
            }
          }
        }
      }
    },
    "/facilities/{id}/transitions": {
      "post": {
        "operationId": "transitionFacility",
        "summary": "Facility workflow transition",
        "tags": [
          "OHN-05"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Transition"
              }
            }
          }
        }
      }
    },
    "/facilities/{id}/aliases": {
      "post": {
        "operationId": "addAlias",
        "summary": "Add alias (duplicate detection runs)",
        "tags": [
          "OHN-05"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Alias"
              }
            }
          }
        }
      }
    },
    "/facilities/{id}/licenses/{licenseId}/renew": {
      "post": {
        "operationId": "renewLicense",
        "summary": "Renew licence",
        "tags": [
          "OHN-05"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "licenseId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LicenseRenewal"
              }
            }
          }
        },
        "description": "1.4.0: manual licence confirmation (confirmation_reference) while no regulator API exists; the licence view carries license_confirmation {method regulator|manual|none, label, reference, confirmed_by, confirmed_at} and the facility profile lists it per licence."
      }
    },
    "/facilities/{id}/licenses/{licenseId}/reverify": {
      "post": {
        "operationId": "reverifyLicense",
        "summary": "Re-verify licence",
        "tags": [
          "OHN-05"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "licenseId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LicenseReverify"
              }
            }
          }
        }
      }
    },
    "/site-relationships": {
      "post": {
        "operationId": "requestRelationship",
        "summary": "Request site relationship",
        "tags": [
          "OHN-05"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SiteRelationship"
              }
            }
          }
        }
      },
      "get": {
        "operationId": "listRelationships",
        "summary": "List site relationships",
        "tags": [
          "OHN-05"
        ],
        "parameters": [],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    },
    "/site-relationships/{id}/transitions": {
      "post": {
        "operationId": "transitionRelationship",
        "summary": "Relationship workflow transition (cycle check, approval)",
        "tags": [
          "OHN-05"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RelationshipTransition"
              }
            }
          }
        }
      }
    },
    "/duplicates": {
      "get": {
        "operationId": "listDuplicates",
        "summary": "List duplicate candidates",
        "tags": [
          "OHN-05"
        ],
        "parameters": [],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    },
    "/duplicates/{id}/resolve": {
      "post": {
        "operationId": "resolveDuplicate",
        "summary": "Resolve duplicate",
        "tags": [
          "OHN-05"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DuplicateResolution"
              }
            }
          }
        }
      }
    },
    "/code-lists/{list}": {
      "get": {
        "operationId": "listCodes",
        "summary": "Read code list",
        "tags": [
          "OHN-05"
        ],
        "parameters": [
          {
            "name": "list",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "relationship_type",
                "site_type",
                "specialty"
              ]
            },
            "description": "site_type, relationship_type or specialty. Items carry source (jurisdiction or platform_default); site_type items carry facility_code_prefix."
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "429": {
            "description": "Rate limited"
          }
        }
      },
      "post": {
        "operationId": "upsertCodes",
        "summary": "Upsert code list entries",
        "tags": [
          "OHN-05"
        ],
        "parameters": [
          {
            "name": "list",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "relationship_type",
                "site_type",
                "specialty"
              ]
            },
            "description": "site_type, relationship_type or specialty. Items carry source (jurisdiction or platform_default); site_type items carry facility_code_prefix."
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CodeListUpsert"
              }
            }
          }
        }
      }
    },
    "/registry-policy": {
      "get": {
        "operationId": "readPolicy",
        "summary": "Read registry policy (unconfigured = fail closed)",
        "tags": [
          "OHN-05"
        ],
        "parameters": [],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "429": {
            "description": "Rate limited"
          }
        }
      },
      "post": {
        "operationId": "writePolicy",
        "summary": "Write registry policy",
        "tags": [
          "OHN-05"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RegistryPolicy"
              }
            }
          }
        }
      }
    },
    "/registry/maintenance/license-sweep": {
      "post": {
        "operationId": "licenseSweep",
        "summary": "Licence expiry sweep (policy-driven)",
        "tags": [
          "OHN-05"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    },
    "/registry/maintenance/drain-outbox": {
      "post": {
        "operationId": "drainOutbox",
        "summary": "Drain outbox (no sink => nothing marked delivered)",
        "tags": [
          "OHN-05"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    },
    "/registry/reports/{reportId}": {
      "get": {
        "operationId": "runReport",
        "summary": "Run report",
        "tags": [
          "OHN-05"
        ],
        "parameters": [
          {
            "name": "reportId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "OHN-05-R001",
                "OHN-05-R002",
                "OHN-05-R003"
              ]
            }
          },
          {
            "name": "jurisdiction",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "facility_type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "period_from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "period_to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "country",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "expiry_window",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "region",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "description": "A Report document (see components.schemas.Report)."
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "429": {
            "description": "Rate limited"
          },
          "422": {
            "description": "Filter failed validation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/registry/reports/{reportId}/export": {
      "post": {
        "operationId": "createExport",
        "summary": "Create signed single-use export",
        "tags": [
          "OHN-05"
        ],
        "parameters": [
          {
            "name": "reportId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "OHN-05-R001",
                "OHN-05-R002",
                "OHN-05-R003"
              ]
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExportCommand"
              }
            }
          }
        }
      }
    },
    "/registry/exports/{token}": {
      "get": {
        "operationId": "fetchExport",
        "summary": "Download export (owner only, single use, 5 min)",
        "tags": [
          "OHN-05"
        ],
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    },
    "/registry/report-catalog": {
      "get": {
        "operationId": "reportCatalog",
        "summary": "Report catalog",
        "tags": [
          "OHN-05"
        ],
        "parameters": [],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    },
    "/health/ohn-05": {
      "get": {
        "operationId": "health",
        "summary": "Liveness incl. DB and dependency modes",
        "security": [],
        "responses": {
          "200": {
            "description": "ok"
          },
          "503": {
            "description": "unavailable"
          }
        }
      }
    },
    "/facilities/by-code/{code}": {
      "get": {
        "operationId": "facilityByCode",
        "summary": "Facility profile looked up by facility code",
        "tags": [
          "OHN-05"
        ],
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 10,
              "maxLength": 32,
              "description": "Facility code, any case, with or without dashes; O is read as 0 and I/L as 1 in the last five characters."
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "429": {
            "description": "Rate limited"
          },
          "422": {
            "description": "invalid_facility_code (malformed code or wrong check character) or domain validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/facilities/{id}/site-type": {
      "post": {
        "operationId": "changeSiteType",
        "summary": "Change the facility type (the facility code is kept, not reissued; the change is audited)",
        "tags": [
          "OHN-05"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "422": {
            "description": "invalid_facility_code (malformed code or wrong check character) or domain validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SiteTypeChange"
              }
            }
          }
        }
      }
    },
    "/registry/maintenance/facility-code-backfill": {
      "post": {
        "operationId": "backfillFacilityCodes",
        "summary": "Issue facility codes to facilities of the jurisdiction that have none (unmapped types are skipped and listed)",
        "tags": [
          "OHN-05"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied (default deny)"
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "dependency_unavailable (OHN-01 country code unreadable)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/facilities/{id}/logos": {
      "post": {
        "operationId": "uploadFacilityLogo",
        "summary": "Upload a new facility logo (pending until a registry reviewer approves it)",
        "tags": [
          "Branding"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LogoUpload"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied, not the facility's own administrator, or self-review",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "409": {
            "description": "Version conflict or illegal transition",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          }
        }
      },
      "get": {
        "operationId": "listFacilityLogos",
        "summary": "The facility's logos with their review state, and its branding setting",
        "tags": [
          "Branding"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied, not the facility's own administrator, or self-review",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "409": {
            "description": "Version conflict or illegal transition",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    },
    "/facilities/{id}/logos/{logoId}/content": {
      "get": {
        "operationId": "facilityLogoContent",
        "summary": "The stored (cleaned) image of any logo, for review by the facility administrator or a registry reviewer",
        "tags": [
          "Branding"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "logoId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "The image; X-Content-Type-Options nosniff and a sandboxing CSP",
            "content": {
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/svg+xml": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/facilities/{id}/logos/{logoId}/approve": {
      "post": {
        "operationId": "approveFacilityLogo",
        "summary": "Approve a pending logo (registry reviewer; never the uploader)",
        "tags": [
          "Branding"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "logoId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LogoReview"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied, not the facility's own administrator, or self-review",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "409": {
            "description": "Version conflict or illegal transition",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    },
    "/facilities/{id}/logos/{logoId}/reject": {
      "post": {
        "operationId": "rejectFacilityLogo",
        "summary": "Reject a pending logo with a reason (registry reviewer; never the uploader)",
        "tags": [
          "Branding"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "logoId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LogoRejection"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied, not the facility's own administrator, or self-review",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "409": {
            "description": "Version conflict or illegal transition",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    },
    "/facilities/{id}/logos/{logoId}/withdraw": {
      "post": {
        "operationId": "withdrawFacilityLogo",
        "summary": "Withdraw a pending or approved logo (facility administrator)",
        "tags": [
          "Branding"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "logoId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LogoWithdrawal"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied, not the facility's own administrator, or self-review",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "409": {
            "description": "Version conflict or illegal transition",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    },
    "/facilities/{id}/branding": {
      "get": {
        "operationId": "facilityBranding",
        "summary": "Public: name, facility code, the APPROVED logo (or null) and whether the branding watermark is on",
        "tags": [
          "Branding"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "description": "FacilityBranding (see components.schemas.FacilityBranding)"
                }
              }
            }
          },
          "404": {
            "description": "Unknown or retired facility"
          },
          "429": {
            "description": "Rate limited"
          }
        }
      },
      "post": {
        "operationId": "setFacilityBranding",
        "summary": "Switch the branding watermark on or off (facility administrator; on needs an approved logo)",
        "tags": [
          "Branding"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BrandingSetting"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied, not the facility's own administrator, or self-review",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "409": {
            "description": "Version conflict or illegal transition",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    },
    "/facilities/{id}/logo": {
      "get": {
        "operationId": "facilityLogo",
        "summary": "Public: the approved logo image only, with its real content type, nosniff and (for SVG) a sandboxing CSP",
        "tags": [
          "Branding"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "v",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "The approved logo",
            "content": {
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/svg+xml": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "404": {
            "description": "No approved logo"
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    },
    "/logo-reviews": {
      "get": {
        "operationId": "logoReviewQueue",
        "summary": "Pending logos of the jurisdiction, oldest first (registry reviewer)",
        "tags": [
          "Branding"
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Role/purpose denied, not the facility's own administrator, or self-review",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found / out of scope"
          },
          "409": {
            "description": "Version conflict or illegal transition",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "details": {}
        }
      },
      "FacilityEnrollment": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "legal_name",
          "country",
          "site_type",
          "operator_org",
          "evidence"
        ],
        "properties": {
          "legal_name": {
            "type": "string",
            "maxLength": 512
          },
          "country": {
            "type": "string",
            "format": "uuid"
          },
          "site_type": {
            "type": "string"
          },
          "official_registry_id": {
            "type": "string"
          },
          "license_ref": {
            "type": "string"
          },
          "geo_coordinates": {
            "type": "string",
            "description": "latitude,longitude decimal degrees"
          },
          "operator_org": {
            "type": "string",
            "format": "uuid"
          },
          "evidence": {
            "type": "string",
            "format": "uuid"
          },
          "region": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "district": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "specialty": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "description": "Required when the site type maps to prefix SPC (specialist centre); code from the 'specialty' code list (defaults: see SpecialtyCode). Refused for any other type."
          }
        }
      },
      "CredentialVerification": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "facility_id",
          "license_authority",
          "license_number",
          "expiry_date",
          "verification_evidence",
          "review_decision",
          "expected_version"
        ],
        "properties": {
          "facility_id": {
            "type": "string",
            "format": "uuid"
          },
          "license_authority": {
            "type": "string",
            "format": "uuid"
          },
          "license_number": {
            "type": "string"
          },
          "expiry_date": {
            "type": "string",
            "format": "date"
          },
          "verification_evidence": {
            "type": "string",
            "format": "uuid"
          },
          "review_decision": {
            "type": "string",
            "enum": [
              "approved",
              "rejected"
            ]
          },
          "expected_version": {
            "type": "integer",
            "minimum": 1
          },
          "confirmation_reference": {
            "type": "string",
            "minLength": 3,
            "maxLength": 128,
            "description": "1.4.0 (owner decision 2026-11-29): the regulator's or Ministry's confirmation reference an OHN registry reviewer obtained. While no regulator integration is configured, it stands for the regulator's confirmation: the licence is recorded as authority_confirmation unconfirmed_manual (\"manually confirmed\"), with the reviewer and the time, and audited. Without it, and no regulator integration, the request answers 503 dependency_unavailable. Once a regulator API is configured, the regulator decides and a reference is no substitute."
          }
        }
      },
      "Transition": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "to_state",
          "expected_version",
          "reason"
        ],
        "properties": {
          "to_state": {
            "type": "string"
          },
          "expected_version": {
            "type": "integer",
            "minimum": 1
          },
          "reason": {
            "type": "string"
          }
        }
      },
      "Suspend": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "expected_version",
          "reason"
        ],
        "properties": {
          "expected_version": {
            "type": "integer",
            "minimum": 1
          },
          "reason": {
            "type": "string"
          }
        }
      },
      "Alias": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "alias_name"
        ],
        "properties": {
          "alias_name": {
            "type": "string",
            "maxLength": 512
          }
        }
      },
      "LicenseRenewal": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "expiry_date",
          "verification_evidence",
          "expected_version"
        ],
        "properties": {
          "expiry_date": {
            "type": "string",
            "format": "date"
          },
          "verification_evidence": {
            "type": "string",
            "format": "uuid"
          },
          "expected_version": {
            "type": "integer",
            "minimum": 1
          },
          "confirmation_reference": {
            "type": "string",
            "minLength": 3,
            "maxLength": 128,
            "description": "1.4.0 (owner decision 2026-11-29): the regulator's or Ministry's confirmation reference an OHN registry reviewer obtained. While no regulator integration is configured, it stands for the regulator's confirmation: the licence is recorded as authority_confirmation unconfirmed_manual (\"manually confirmed\"), with the reviewer and the time, and audited. Without it, and no regulator integration, the request answers 503 dependency_unavailable. Once a regulator API is configured, the regulator decides and a reference is no substitute. On renewal only a registry_reviewer may give it (403 manual_confirmation_reviewer_only), never the person who submitted the facility (403 separation_of_duties)."
          }
        }
      },
      "LicenseReverify": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "review_decision",
          "expected_version"
        ],
        "properties": {
          "review_decision": {
            "type": "string",
            "enum": [
              "approved",
              "rejected"
            ]
          },
          "expected_version": {
            "type": "integer",
            "minimum": 1
          }
        }
      },
      "SiteRelationship": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "facility_id",
          "child_site_id",
          "relationship_type",
          "effective_from"
        ],
        "properties": {
          "facility_id": {
            "type": "string",
            "format": "uuid"
          },
          "parent_site_id": {
            "type": "string",
            "format": "uuid"
          },
          "child_site_id": {
            "type": "string",
            "format": "uuid"
          },
          "relationship_type": {
            "type": "string"
          },
          "effective_from": {
            "type": "string",
            "format": "date"
          }
        }
      },
      "RelationshipTransition": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "to_state",
          "expected_version",
          "reason"
        ],
        "properties": {
          "to_state": {
            "type": "string",
            "enum": [
              "cycle_checked",
              "approved",
              "published",
              "rejected"
            ]
          },
          "expected_version": {
            "type": "integer",
            "minimum": 1
          },
          "reason": {
            "type": "string"
          }
        }
      },
      "DuplicateResolution": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "resolution",
          "reason",
          "expected_version"
        ],
        "properties": {
          "resolution": {
            "type": "string",
            "enum": [
              "confirmed_duplicate",
              "not_duplicate"
            ]
          },
          "reason": {
            "type": "string"
          },
          "expected_version": {
            "type": "integer",
            "minimum": 1
          }
        }
      },
      "CodeListUpsert": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "entries"
        ],
        "properties": {
          "entries": {
            "type": "array",
            "minItems": 1,
            "maxItems": 200,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "code",
                "label_en",
                "label_fr"
              ],
              "properties": {
                "code": {
                  "type": "string"
                },
                "label_en": {
                  "type": "string",
                  "maxLength": 128
                },
                "label_fr": {
                  "type": "string",
                  "maxLength": 128
                },
                "active": {
                  "type": "boolean",
                  "default": true
                },
                "facility_code_prefix": {
                  "type": "string",
                  "enum": [
                    "INS",
                    "HSP",
                    "CLI",
                    "HCE",
                    "LAB",
                    "PHA",
                    "DIG",
                    "MAT",
                    "CHS",
                    "BLD",
                    "DEN",
                    "SPC",
                    "AMB",
                    "DIS",
                    "HMC",
                    "VAC",
                    "OCC",
                    "NGO",
                    "PENDING"
                  ],
                  "description": "site_type list only: the facility-code prefix of this type in the jurisdiction. PENDING = enrol without a code until the owner assigns a prefix."
                }
              }
            }
          }
        }
      },
      "RegistryPolicy": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "expiring_window_days",
          "on_expiry_action",
          "cross_country_relationships_allowed",
          "approval_reference"
        ],
        "properties": {
          "expiring_window_days": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 3650
          },
          "on_expiry_action": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "suspend",
              "flag_only",
              null
            ]
          },
          "cross_country_relationships_allowed": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "approval_reference": {
            "type": "string",
            "minLength": 3,
            "maxLength": 256
          }
        }
      },
      "ExportCommand": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "format"
        ],
        "properties": {
          "format": {
            "type": "string",
            "enum": [
              "csv",
              "pdf"
            ]
          },
          "filters": {
            "type": "object"
          },
          "columns": {
            "type": "array",
            "maxItems": 16,
            "items": {
              "type": "string"
            }
          }
        }
      },
      "Report": {
        "type": "object",
        "properties": {
          "report_id": {
            "type": "string",
            "enum": [
              "OHN-05-R001",
              "OHN-05-R002",
              "OHN-05-R003"
            ]
          },
          "title": {
            "type": "string"
          },
          "columns": {
            "type": "array"
          },
          "rows": {
            "type": "array"
          },
          "summary": {
            "type": "object"
          },
          "state": {
            "type": "string",
            "enum": [
              "rendered",
              "no_authorized_data"
            ]
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "FacilityCode": {
        "type": "string",
        "pattern": "^(INS|HSP|CLI|HCE|LAB|PHA|DIG|MAT|CHS|BLD|DEN|SPC|AMB|DIS|HMC|VAC|OCC|NGO)-[A-Z]{2}-[0-9A-HJKMNP-TV-Z]{5}$",
        "description": "Display form of the facility code, returned as facility_code on every facility (null only while the type awaits an owner prefix)."
      },
      "SiteTypeChange": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "site_type",
          "expected_version",
          "reason"
        ],
        "properties": {
          "site_type": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "expected_version": {
            "type": "integer",
            "minimum": 1
          },
          "reason": {
            "type": "string",
            "minLength": 10,
            "maxLength": 2000
          },
          "specialty": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "description": "Required when the site type maps to prefix SPC (specialist centre); code from the 'specialty' code list (defaults: see SpecialtyCode). Refused for any other type."
          }
        }
      },
      "FacilityTypeCode": {
        "type": "string",
        "enum": [
          "payer_office",
          "hospital",
          "clinic",
          "health_centre",
          "laboratory",
          "pharmacy",
          "imaging_centre",
          "maternity",
          "health_post",
          "blood_bank",
          "dental_clinic",
          "specialist_centre",
          "ambulance_service",
          "medicine_distributor",
          "nursing_home",
          "vaccination_centre",
          "occupational_health",
          "health_organisation"
        ],
        "description": "Platform-default site_type codes (EN/FR labels in GET /code-lists/site_type, source platform_default), each with exactly one facility-code prefix in this order: payer_office=INS, hospital=HSP, clinic=CLI, health_centre=HCE, laboratory=LAB, pharmacy=PHA, imaging_centre=DIG, maternity=MAT, health_post=CHS, blood_bank=BLD, dental_clinic=DEN, specialist_centre=SPC, ambulance_service=AMB, medicine_distributor=DIS, nursing_home=HMC, vaccination_centre=VAC, occupational_health=OCC, health_organisation=NGO. A jurisdiction may add its own codes to the site_type list; site_type fields therefore stay open strings validated against the jurisdiction code list."
      },
      "SpecialtyCode": {
        "type": "string",
        "enum": [
          "eye_care",
          "dialysis",
          "mental_health",
          "rehabilitation",
          "other"
        ],
        "description": "Platform-default specialty codes (code list 'specialty', configurable per jurisdiction). Required for a specialist_centre (prefix SPC), refused for any other type."
      },
      "LogoUpload": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "content_base64"
        ],
        "properties": {
          "content_base64": {
            "type": "string",
            "minLength": 4,
            "maxLength": 349528,
            "description": "The file, base64. At most 262144 bytes once decoded; the type is read from the bytes."
          },
          "file_name": {
            "type": "string",
            "maxLength": 120
          }
        }
      },
      "LogoReview": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "expected_version"
        ],
        "properties": {
          "expected_version": {
            "type": "integer",
            "minimum": 1
          }
        }
      },
      "LogoRejection": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "expected_version",
          "reason"
        ],
        "properties": {
          "expected_version": {
            "type": "integer",
            "minimum": 1
          },
          "reason": {
            "type": "string",
            "minLength": 10,
            "maxLength": 500
          }
        }
      },
      "LogoWithdrawal": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "expected_version"
        ],
        "properties": {
          "expected_version": {
            "type": "integer",
            "minimum": 1
          },
          "reason": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          }
        }
      },
      "BrandingSetting": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "branding_watermark"
        ],
        "properties": {
          "branding_watermark": {
            "type": "boolean"
          },
          "expected_version": {
            "type": "integer",
            "minimum": 1,
            "description": "Required once the setting exists."
          }
        }
      },
      "FacilityBranding": {
        "type": "object",
        "required": [
          "facility_id",
          "name",
          "facility_code",
          "logo",
          "branding_watermark"
        ],
        "properties": {
          "facility_id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "facility_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "logo": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "url": {
                "type": "string"
              },
              "content_type": {
                "enum": [
                  "image/png",
                  "image/jpeg",
                  "image/svg+xml"
                ]
              },
              "version": {
                "type": "integer"
              },
              "sha256": {
                "type": "string"
              }
            }
          },
          "branding_watermark": {
            "type": "boolean"
          }
        }
      }
    }
  }
}
