# OHN-53 OpenAPI 3.1 contract (generated from modules/OHN-53/module.json; JSON-style YAML)
{
  "openapi": "3.1.0",
  "info": {
    "title": "OHN-53 Notifications and Messaging",
    "version": "1.0.1",
    "description": "In-app inbox, SMS, email and USSD. Local dev sink by default (no live SMS or email adapter exists: provider contracts and credentials are owner items). No clinical content in SMS or email. Tokens come from the platform gateway (ES256, issuer ohn-platform-gateway, audience ohn-53; claims role, jurisdiction, organization_id, purpose). Every call except GET /health/ohn-53 and the two secret-authenticated callbacks (POST /api/ohn/v1/ussd, POST .../intake/webhook) needs a bearer token; every non-GET call needs an Idempotency-Key (1-255 characters, not blank) except those two callbacks. The operator kill switch refuses every gateway write with 503 not_configured (setting OHN_M53_WRITES_DISABLED)."
  },
  "servers": [
    {
      "url": "https://opeshealthnetwork.com"
    }
  ],
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT (ES256 from the platform gateway; iss ohn-platform-gateway, aud ohn-53; role + purpose + jurisdiction + organization_id)"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "details": {}
        }
      },
      "Preferences": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "language",
          "channels",
          "quiet_hours",
          "opt_out",
          "expected_version"
        ],
        "properties": {
          "language": {
            "enum": [
              "en",
              "fr"
            ]
          },
          "channels": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "in_app",
              "sms",
              "email"
            ],
            "properties": {
              "in_app": {
                "const": true
              },
              "sms": {
                "type": "boolean"
              },
              "email": {
                "type": "boolean"
              }
            }
          },
          "quiet_hours": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "start",
                  "end"
                ],
                "properties": {
                  "start": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 23
                  },
                  "end": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 23
                  }
                }
              }
            ]
          },
          "opt_out": {
            "type": "boolean"
          },
          "muted_categories": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "type": "string"
            }
          },
          "expected_version": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "StartContact": {
        "oneOf": [
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "channel",
              "value"
            ],
            "properties": {
              "channel": {
                "const": "sms"
              },
              "value": {
                "type": "string",
                "pattern": "^\\+237[26]\\d{8}$"
              }
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "channel",
              "value"
            ],
            "properties": {
              "channel": {
                "const": "email"
              },
              "value": {
                "type": "string",
                "format": "email",
                "maxLength": 254
              }
            }
          }
        ]
      },
      "ConfirmContact": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "code"
        ],
        "properties": {
          "code": {
            "type": "string",
            "pattern": "^\\d{6}$"
          }
        }
      },
      "Reminder": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "patient_id",
          "kind",
          "due_at",
          "place_label"
        ],
        "properties": {
          "patient_id": {
            "type": "string",
            "format": "uuid"
          },
          "kind": {
            "enum": [
              "appointment",
              "vaccination_due"
            ]
          },
          "due_at": {
            "type": "string",
            "format": "date-time"
          },
          "remind_hours_before": {
            "type": "integer",
            "minimum": 1,
            "maximum": 336,
            "default": 24
          },
          "place_label": {
            "type": "string",
            "minLength": 2,
            "maxLength": 80
          }
        }
      },
      "ExpectedVersion": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "expected_version"
        ],
        "properties": {
          "expected_version": {
            "type": "integer",
            "minimum": 1
          }
        }
      },
      "EventEnvelope": {
        "$ref": "https://opeshealthnetwork.com/contracts/ohn-53/events.schema.json"
      },
      "UssdCallback": {
        "type": "object",
        "required": [
          "sessionId",
          "phoneNumber"
        ],
        "properties": {
          "sessionId": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1
          },
          "phoneNumber": {
            "type": "string",
            "maxLength": 20,
            "minLength": 4
          },
          "text": {
            "type": "string",
            "maxLength": 182,
            "default": ""
          },
          "serviceCode": {
            "type": "string",
            "maxLength": 32
          },
          "networkCode": {
            "type": "string",
            "maxLength": 32
          }
        },
        "additionalProperties": true
      },
      "UssdSimulator": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "session_id",
          "phone_number",
          "text"
        ],
        "properties": {
          "session_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{4,64}$"
          },
          "phone_number": {
            "type": "string",
            "pattern": "^\\+237[26]\\d{8}$"
          },
          "text": {
            "type": "string",
            "maxLength": 182
          }
        }
      },
      "TestNotification": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "recipient_id",
          "recipient_kind",
          "channels"
        ],
        "properties": {
          "recipient_id": {
            "type": "string",
            "format": "uuid"
          },
          "recipient_kind": {
            "enum": [
              "patient",
              "staff"
            ]
          },
          "channels": {
            "type": "array",
            "minItems": 1,
            "maxItems": 3,
            "items": {
              "enum": [
                "in_app",
                "sms",
                "email"
              ]
            }
          }
        }
      },
      "InboxItem": {
        "type": "object",
        "required": [
          "id",
          "category",
          "title",
          "body",
          "language",
          "texts",
          "read",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "category": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "body": {
            "type": "string"
          },
          "language": {
            "type": "string",
            "enum": [
              "en",
              "fr"
            ],
            "description": "Language of title/body as returned."
          },
          "texts": {
            "type": "object",
            "description": "Title/body per language: en and fr when the message has a template key, else only the stored language.",
            "additionalProperties": {
              "type": "object",
              "required": [
                "title",
                "body"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "body": {
                  "type": "string"
                }
              }
            }
          },
          "link": {
            "type": [
              "string",
              "null"
            ]
          },
          "read": {
            "type": "boolean"
          },
          "read_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "source_module": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      }
    }
  },
  "paths": {
    "/api/ohn/v1/notifications/inbox": {
      "get": {
        "operationId": "OHN-53-API-001",
        "summary": "List my notifications and unread count",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "unread"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/InboxItem"
                      }
                    },
                    "unread": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (audited)"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "description": "In-app messages are rendered at read time in the requested language (lang query parameter, else Accept-Language, else the language each message was sent in). Messages stored before migration 0002 have no template key and are returned in the language they were sent in (`language`).",
        "parameters": [
          {
            "name": "unread",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "name": "lang",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "en",
                "fr"
              ]
            },
            "description": "Language of title/body. Overrides Accept-Language."
          },
          {
            "name": "Accept-Language",
            "in": "header",
            "schema": {
              "type": "string"
            },
            "description": "Used when lang is absent; the first en or fr entry by weight wins."
          }
        ]
      }
    },
    "/api/ohn/v1/notifications/inbox/{id}/read": {
      "post": {
        "operationId": "OHN-53-API-002",
        "summary": "Mark one as read",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "missing_idempotency_key (header absent, blank or longer than 255), or malformed_request (body is not valid JSON)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (audited)"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "idempotency_conflict (the key was reused with a different body) or request_in_progress",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "not_configured (the operator kill switch, setting OHN_M53_WRITES_DISABLED, or a missing setting) or dependency_unavailable; nothing is stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255,
              "pattern": "\\S"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/ohn/v1/notifications/inbox/read-all": {
      "post": {
        "operationId": "OHN-53-API-003",
        "summary": "Mark all as read",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "missing_idempotency_key (header absent, blank or longer than 255), or malformed_request (body is not valid JSON)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (audited)"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "idempotency_conflict (the key was reused with a different body) or request_in_progress",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "not_configured (the operator kill switch, setting OHN_M53_WRITES_DISABLED, or a missing setting) or dependency_unavailable; nothing is stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255,
              "pattern": "\\S"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/ohn/v1/notifications/preferences": {
      "get": {
        "operationId": "OHN-53-API-004",
        "summary": "My preferences",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (audited)"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      },
      "put": {
        "operationId": "OHN-53-API-005",
        "summary": "Update my preferences (optimistic concurrency)",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "missing_idempotency_key (header absent, blank or longer than 255), or malformed_request (body is not valid JSON)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (audited)"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "version_conflict: {error, message, details: {current_version}}",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "not_configured (the operator kill switch, setting OHN_M53_WRITES_DISABLED, or a missing setting) or dependency_unavailable; nothing is stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255,
              "pattern": "\\S"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Preferences"
              }
            }
          }
        }
      }
    },
    "/api/ohn/v1/notifications/contacts": {
      "get": {
        "operationId": "OHN-53-API-006",
        "summary": "My contacts",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (audited)"
          },
          "404": {
            "description": "Not found"
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      },
      "post": {
        "operationId": "OHN-53-API-007",
        "summary": "Add a phone or email and send a code",
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "missing_idempotency_key (header absent, blank or longer than 255), or malformed_request (body is not valid JSON)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (audited)"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "contact_in_use (verified for someone else) or already_verified (the caller already verified it)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: too many codes requested in the last hour (default 5)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "not_configured (the operator kill switch, setting OHN_M53_WRITES_DISABLED, or a missing setting) or dependency_unavailable; nothing is stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255,
              "pattern": "\\S"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StartContact"
              }
            }
          }
        }
      }
    },
    "/api/ohn/v1/notifications/contacts/{id}/resend": {
      "post": {
        "operationId": "OHN-53-API-008",
        "summary": "Send a new code",
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "missing_idempotency_key (header absent, blank or longer than 255), or malformed_request (body is not valid JSON)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (audited)"
          },
          "404": {
            "description": "No pending contact of the caller with this id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "contact_in_use or already_verified",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "not_configured (the operator kill switch, setting OHN_M53_WRITES_DISABLED, or a missing setting) or dependency_unavailable; nothing is stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255,
              "pattern": "\\S"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/ohn/v1/notifications/contacts/{id}/verify": {
      "post": {
        "operationId": "OHN-53-API-009",
        "summary": "Verify with the code",
        "responses": {
          "200": {
            "description": "Verified, or already verified ({contact, duplicate: true})",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "missing_idempotency_key (header absent, blank or longer than 255), or malformed_request (body is not valid JSON)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (audited)"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "invalid_state (revoked contact) or contact_in_use (the number was verified for another account meanwhile)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "410": {
            "description": "code_expired: no open challenge or it has expired (10 minutes by default); ask for a new code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "domain_validation_failed (not 6 digits) or wrong_code: {error: wrong_code, message, attempts_left}; the attempt is counted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "type": "object",
                      "required": [
                        "error",
                        "attempts_left"
                      ],
                      "properties": {
                        "error": {
                          "const": "wrong_code"
                        },
                        "message": {
                          "type": "string"
                        },
                        "attempts_left": {
                          "type": "integer",
                          "minimum": 0
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "too_many_attempts: five wrong codes (configurable); ask for a new code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "not_configured (the operator kill switch, setting OHN_M53_WRITES_DISABLED, or a missing setting) or dependency_unavailable; nothing is stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255,
              "pattern": "\\S"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConfirmContact"
              }
            }
          }
        }
      }
    },
    "/api/ohn/v1/notifications/contacts/{id}/revoke": {
      "post": {
        "operationId": "OHN-53-API-010",
        "summary": "Remove a contact",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "missing_idempotency_key (header absent, blank or longer than 255), or malformed_request (body is not valid JSON)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (audited)"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "idempotency_conflict (the key was reused with a different body) or request_in_progress",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "not_configured (the operator kill switch, setting OHN_M53_WRITES_DISABLED, or a missing setting) or dependency_unavailable; nothing is stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255,
              "pattern": "\\S"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/ohn/v1/notifications/reminders": {
      "get": {
        "operationId": "OHN-53-API-011",
        "summary": "Reminders (patient: own; staff: organisation)",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (audited)"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      },
      "post": {
        "operationId": "OHN-53-API-012",
        "summary": "Schedule a reminder",
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "missing_idempotency_key (header absent, blank or longer than 255), or malformed_request (body is not valid JSON)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (audited)"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "idempotency_conflict (the key was reused with a different body) or request_in_progress",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "domain_validation_failed; also when due_at is in the past (details.due_at = past)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "not_configured (the operator kill switch, setting OHN_M53_WRITES_DISABLED, or a missing setting) or dependency_unavailable; nothing is stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255,
              "pattern": "\\S"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Reminder"
              }
            }
          }
        }
      }
    },
    "/api/ohn/v1/notifications/reminders/{id}/cancel": {
      "post": {
        "operationId": "OHN-53-API-013",
        "summary": "Cancel a reminder",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "missing_idempotency_key (header absent, blank or longer than 255), or malformed_request (body is not valid JSON)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (audited)"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "version_conflict, or invalid_transition (only a scheduled reminder can be cancelled)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "not_configured (the operator kill switch, setting OHN_M53_WRITES_DISABLED, or a missing setting) or dependency_unavailable; nothing is stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255,
              "pattern": "\\S"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExpectedVersion"
              }
            }
          }
        }
      }
    },
    "/api/ohn/v1/notifications/intake/events": {
      "post": {
        "operationId": "OHN-53-API-014",
        "summary": "Event intake (service role)",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "missing_idempotency_key (header absent, blank or longer than 255), or malformed_request (body is not valid JSON)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "denied_by_policy: wrong role, or the event belongs to another jurisdiction than the token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "idempotency_conflict (the key was reused with a different body) or request_in_progress",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "not_configured (the operator kill switch, setting OHN_M53_WRITES_DISABLED, or a missing setting) or dependency_unavailable; nothing is stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255,
              "pattern": "\\S"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EventEnvelope"
              }
            }
          }
        }
      }
    },
    "/api/ohn/v1/notifications/intake/webhook": {
      "post": {
        "operationId": "OHN-53-API-015",
        "summary": "OHN-24 signed webhook receiver",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "missing_idempotency_key (header absent, blank or longer than 255), or malformed_request (body is not valid JSON)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "bad_signature: X-OHN-Signature missing or not sha256=<hex HMAC-SHA256 of the raw body>",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "idempotency_conflict (the key was reused with a different body) or request_in_progress",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "not_configured (the operator kill switch, setting OHN_M53_WRITES_DISABLED, or a missing setting) or dependency_unavailable; nothing is stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EventEnvelope"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "X-OHN-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^sha256=[0-9a-f]{64}$"
            }
          }
        ],
        "security": [],
        "description": "OHN-24 webhook receiver. Authenticated by the HMAC-SHA256 of the raw body (header X-OHN-Signature: sha256=<hex>) with the shared webhook secret; no bearer token and no Idempotency-Key (duplicates are ignored by event_id). Unsigned or unconfigured is refused."
      }
    },
    "/api/ohn/v1/ussd": {
      "post": {
        "operationId": "OHN-53-API-016",
        "summary": "USSD aggregator callback (CON/END)",
        "responses": {
          "200": {
            "description": "USSD screen",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "pattern": "^(CON|END) "
                }
              }
            }
          },
          "400": {
            "description": "missing_idempotency_key (header absent, blank or longer than 255), or malformed_request (body is not valid JSON)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "END Not authorised.",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "pattern": "^END "
                }
              }
            }
          },
          "409": {
            "description": "idempotency_conflict (the key was reused with a different body) or request_in_progress",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "not_configured (the operator kill switch, setting OHN_M53_WRITES_DISABLED, or a missing setting) or dependency_unavailable; nothing is stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "description": "Aggregator callback (Africa's Talking format). Header X-OHN53-USSD-Secret or query key. Answers text/plain \"CON ...\" or \"END ...\", at most 182 characters.",
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/UssdCallback"
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UssdCallback"
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/ohn/v1/notifications/ussd-simulator": {
      "post": {
        "operationId": "OHN-53-API-017",
        "summary": "USSD simulator",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "reply",
                    "kind",
                    "text"
                  ],
                  "properties": {
                    "reply": {
                      "type": "string"
                    },
                    "kind": {
                      "enum": [
                        "continue",
                        "end"
                      ]
                    },
                    "text": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "missing_idempotency_key (header absent, blank or longer than 255), or malformed_request (body is not valid JSON)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (audited)"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "idempotency_conflict (the key was reused with a different body) or request_in_progress",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "not_configured (the operator kill switch, setting OHN_M53_WRITES_DISABLED, or a missing setting) or dependency_unavailable; nothing is stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255,
              "pattern": "\\S"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UssdSimulator"
              }
            }
          }
        }
      }
    },
    "/api/ohn/v1/notifications/admin/outbox": {
      "get": {
        "operationId": "OHN-53-API-018",
        "summary": "Dev sink messages",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (audited)"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/api/ohn/v1/notifications/admin/deliveries": {
      "get": {
        "operationId": "OHN-53-API-019",
        "summary": "Deliveries",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (audited)"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/api/ohn/v1/notifications/admin/deliveries/{id}": {
      "get": {
        "operationId": "OHN-53-API-020",
        "summary": "Delivery and its log",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (audited)"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/api/ohn/v1/notifications/admin/deliveries/{id}/retry": {
      "post": {
        "operationId": "OHN-53-API-021",
        "summary": "Retry a failed delivery",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "missing_idempotency_key (header absent, blank or longer than 255), or malformed_request (body is not valid JSON)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (audited)"
          },
          "404": {
            "description": "Not found (not a UUID)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "invalid_transition: only failed or dead deliveries can be retried",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "not_configured (the operator kill switch, setting OHN_M53_WRITES_DISABLED, or a missing setting) or dependency_unavailable; nothing is stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255,
              "pattern": "\\S"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/ohn/v1/notifications/admin/deliveries/process": {
      "post": {
        "operationId": "OHN-53-API-022",
        "summary": "Send due messages now",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "missing_idempotency_key (header absent, blank or longer than 255), or malformed_request (body is not valid JSON)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (audited)"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "idempotency_conflict (the key was reused with a different body) or request_in_progress",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "not_configured (the operator kill switch, setting OHN_M53_WRITES_DISABLED, or a missing setting) or dependency_unavailable; nothing is stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255,
              "pattern": "\\S"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/ohn/v1/notifications/admin/test-notification": {
      "post": {
        "operationId": "OHN-53-API-023",
        "summary": "Send a test message",
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "missing_idempotency_key (header absent, blank or longer than 255), or malformed_request (body is not valid JSON)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (audited)"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "idempotency_conflict (the key was reused with a different body) or request_in_progress",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "not_configured (the operator kill switch, setting OHN_M53_WRITES_DISABLED, or a missing setting) or dependency_unavailable; nothing is stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255,
              "pattern": "\\S"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TestNotification"
              }
            }
          }
        }
      }
    },
    "/api/ohn/v1/notifications/admin/subscriptions": {
      "get": {
        "operationId": "OHN-53-API-024",
        "summary": "OHN-24 subscriptions and intake counts",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (audited)"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/api/ohn/v1/notifications/admin/subscriptions/bootstrap": {
      "post": {
        "operationId": "OHN-53-API-025",
        "summary": "Create OHN-24 pull subscriptions",
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "missing_idempotency_key (header absent, blank or longer than 255), or malformed_request (body is not valid JSON)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (audited)"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "idempotency_conflict (the key was reused with a different body) or request_in_progress",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "not_configured (the operator kill switch, setting OHN_M53_WRITES_DISABLED, or a missing setting) or dependency_unavailable; nothing is stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255,
              "pattern": "\\S"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/ohn/v1/notifications/admin/intake/poll": {
      "post": {
        "operationId": "OHN-53-API-026",
        "summary": "Poll OHN-24 now",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "missing_idempotency_key (header absent, blank or longer than 255), or malformed_request (body is not valid JSON)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (audited)"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "idempotency_conflict (the key was reused with a different body) or request_in_progress",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "not_configured (the operator kill switch, setting OHN_M53_WRITES_DISABLED, or a missing setting) or dependency_unavailable; nothing is stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255,
              "pattern": "\\S"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/ohn/v1/notifications/reports": {
      "get": {
        "operationId": "OHN-53-API-027",
        "summary": "Report catalogue",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (audited)"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/api/ohn/v1/notifications/reports/{id}": {
      "get": {
        "operationId": "OHN-53-API-028",
        "summary": "Run report",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (audited)"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/api/ohn/v1/notifications/reports/{id}/export": {
      "get": {
        "operationId": "OHN-53-API-029",
        "summary": "Signed CSV",
        "responses": {
          "200": {
            "description": "Signed CSV: header X-OHN53-Signature: hmac-sha256=<hex HMAC-SHA256 of the body with the export signing key>; Content-Disposition attachment",
            "headers": {
              "X-OHN53-Signature": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (audited)"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "not_configured: the export signing key is not set (details.setting)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/api/ohn/v1/notifications/audit": {
      "get": {
        "operationId": "OHN-53-API-030",
        "summary": "Audit trail",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (audited)"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/health/ohn-53": {
      "get": {
        "operationId": "OHN-53-API-032",
        "summary": "Health and provider modes",
        "responses": {
          "200": {
            "description": "Public. status, module, providers {sms,email,in_app: {provider, mode}}, dependencies {OHN-15, OHN-24: live|unconfigured|test_fake}, worker, event_intake, ussd, contact_protection, real_delivery_allowed (always false: there is no live adapter), writes_enabled, auth_configured, synthetic_auth (always false)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (audited)"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "status unavailable: the database cannot be reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  }
}
