{
  "openapi": "3.1.0",
  "info": {
    "title": "anam-notifications",
    "version": "1.0.0-alpha.3",
    "description": "Serviço de notificações multicanal (WhatsApp, SMS, e-mail, push), multi-tenant e independente de domínio.\n\nDuas regras governam qualquer integração. **Primeira: o cliente nunca manda texto** — manda chave de\ntemplate, locale e variáveis. É isso que permite aprovação prévia de template no WhatsApp, tradução\nconsistente e minimização de conteúdo. **Segunda: as variáveis de identidade são resolvidas aqui** —\nnome do destinatário e de quem ele vai encontrar saem do cadastro deste serviço, e quem chama envia\napenas identificadores estáveis (`recipient.external_ref` e `parties`).\n\nTodo envio é idempotente por `Idempotency-Key`, e os eventos de entrega chegam por webhook assinado\ncom HMAC-SHA256 (ver `webhooks` e `contracts/v1/events/`).\n\nEste arquivo é a única coisa compartilhada com outros serviços: nada de código, biblioteca ou banco em\ncomum. Quebra de contrato é bump major com período de convivência.\n\nQuando presente, `failure_code` classifica a causa de forma estável:\n`identity_unresolved`, `party_ref_missing`, `party_ref_unknown`, `identity_override_forbidden`,\n`blank_variable`,\n`missing_provider_binding`, `data_access_notices_disabled`, `transfer_safeguards_missing`,\n`tenant_header_required`, `tenant_reference_malformed`, `tenant_ref_unknown`,\n`tenant_out_of_scope`, `tenant_ref_conflict`, `setting_locked_by_organization`,\n`setting_not_lockable`, `optional_variable_in_text`, `fallback_default_missing`.\n\nCódigos de erro:\n- unauthorized\n- forbidden\n- not_found\n- validation_failed\n- idempotency_conflict\n- projection_required\n- projection_source_conflict\n- recipient_projection_purged\n- rate_limited\n- template_not_found\n- template_invalid\n- recipient_not_found\n- provider_not_configured\n- conflict\n- internal\n\nTipos de evento de saída:\n- message.accepted\n- message.scheduled\n- message.rescheduled\n- message.cancelled\n- message.sent\n- message.delivered\n- message.read\n- message.failed\n- message.suppressed\n- recipient.opted_out\n"
  },
  "components": {
    "securitySchemes": {
      "inboxGrant": {
        "type": "http",
        "scheme": "bearer",
        "description": "Capacidade pessoal curta, vinculada a recipient e recursos, com authority externa de até10s."
      },
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Chave no formato `amk_<prefixo>_<segredo>`. Escopos: `send`, `read` e `admin`. O prefixo é público e\nserve para localizar e revogar a chave; do segredo o banco guarda só o hash.\n\nDois tipos. **Chave de tenant** está presa a um tenant e não precisa de header. **Chave de\norganização** opera sobre todos os tenants dela e precisa de `X-Anam-Tenant` em rota de tenant —\nsem ele é `422 tenant_header_required`; com tenant de outra organização é `403 tenant_out_of_scope`,\na mesma resposta de um tenant inexistente.\n"
      }
    },
    "schemas": {}
  },
  "paths": {
    "/health": {
      "get": {
        "operationId": "getHealth",
        "summary": "Vivacidade do processo",
        "tags": [
          "operação"
        ],
        "description": "Vivacidade do processo.",
        "security": [],
        "responses": {
          "200": {
            "description": "processo de pé",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "const": "ok"
                    },
                    "service": {
                      "type": "string",
                      "const": "anam-notifications"
                    }
                  }
                },
                "examples": {
                  "exemplo": {
                    "summary": "Vivacidade do processo",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/health"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/health')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/health\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/health');"
          }
        ]
      }
    },
    "/healthz": {
      "get": {
        "operationId": "getHealthz",
        "summary": "Process liveness",
        "tags": [
          "operação"
        ],
        "description": "Dependency-free process liveness; no provider calls.",
        "security": [],
        "responses": {
          "200": {
            "description": "processo de pé",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "const": "ok"
                    },
                    "service": {
                      "type": "string",
                      "const": "anam-notifications"
                    }
                  }
                },
                "examples": {
                  "exemplo": {
                    "summary": "Vivacidade do processo",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/healthz"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/healthz')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/healthz\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/healthz');"
          }
        ]
      }
    },
    "/ready": {
      "get": {
        "operationId": "getReady",
        "summary": "Prontidão, incluindo o banco",
        "tags": [
          "operação"
        ],
        "description": "Prontidão, incluindo o banco.",
        "security": [],
        "responses": {
          "200": {
            "description": "pronto para receber tráfego",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Prontidão, incluindo o banco",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "banco inacessível"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/ready"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/ready')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/ready\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/ready');"
          }
        ]
      }
    },
    "/readyz": {
      "get": {
        "operationId": "getReadyz",
        "summary": "Dependency readiness",
        "tags": [
          "operação"
        ],
        "description": "Bounded dependency checks. Does not verify worker capacity or provider delivery.",
        "security": [],
        "responses": {
          "200": {
            "description": "pronto para receber tráfego",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Prontidão, incluindo o banco",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "banco inacessível"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/readyz"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/readyz')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/readyz\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/readyz');"
          }
        ]
      }
    },
    "/readyz/processing": {
      "get": {
        "operationId": "getProcessingReadyz",
        "summary": "Dependency readiness",
        "tags": [
          "operação"
        ],
        "description": "Bounded dependency checks. Does not verify worker capacity or provider delivery.",
        "security": [],
        "responses": {
          "200": {
            "description": "pronto para receber tráfego",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Prontidão, incluindo o banco",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "banco inacessível"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/readyz/processing"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/readyz/processing')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/readyz/processing\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/readyz/processing');"
          }
        ]
      }
    },
    "/metrics": {
      "get": {
        "operationId": "getMetrics",
        "summary": "Métricas em formato Prometheus",
        "tags": [
          "operação"
        ],
        "description": "Requires a dedicated METRICS_TOKEN, never a tenant key. Disabled (404) without configuration; absent or invalid credentials return 401.",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "exposição Prometheus",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Métricas em formato Prometheus",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid collector token."
          },
          "404": {
            "description": "Metrics are disabled."
          },
          "503": {
            "description": "Metrics collection dependency unavailable."
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/metrics"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/metrics')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/metrics\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/metrics');"
          }
        ]
      }
    },
    "/openapi.yaml": {
      "get": {
        "operationId": "getOpenapiYaml",
        "summary": "Este contrato, em YAML (fonte editável)",
        "tags": [
          "operação"
        ],
        "description": "Este contrato, em YAML (fonte editável).",
        "security": [],
        "responses": {
          "200": {
            "description": "especificação OpenAPI",
            "content": {
              "application/yaml": {
                "schema": {
                  "type": "string"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Este contrato, em YAML (fonte editável)",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/openapi.yaml"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/openapi.yaml')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/openapi.yaml\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/openapi.yaml');"
          }
        ]
      }
    },
    "/openapi.json": {
      "get": {
        "operationId": "getOpenapiJson",
        "summary": "Este contrato, em JSON (para gerador de cliente)",
        "tags": [
          "operação"
        ],
        "description": "Gerado do YAML por `pnpm run contracts:build`; o teste de contrato falha se os dois divergirem.",
        "security": [],
        "responses": {
          "200": {
            "description": "especificação OpenAPI",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Este contrato, em JSON (para gerador de cliente)",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/openapi.json"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/openapi.json')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/openapi.json\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/openapi.json');"
          }
        ]
      }
    },
    "/docs/": {
      "get": {
        "operationId": "getDocs",
        "summary": "Referência interativa (Scalar)",
        "tags": [
          "operação"
        ],
        "description": "Página HTML que carrega este contrato em `/openapi.json`. Sem autenticação.\nO JavaScript do Scalar 1.75.0 é servido por esta origem em `/docs/js/scalar.js`.\nO contrato e o bearer não passam por proxy externo.\n",
        "security": [],
        "responses": {
          "200": {
            "description": "página HTML",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Referência interativa (Scalar)",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/docs/"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/docs/')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/docs/\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/docs/');"
          }
        ]
      }
    },
    "/v1/provider-webhooks/{providerId}": {
      "get": {
        "operationId": "verifyMetaWebhook",
        "summary": "Verify a Meta callback subscription",
        "tags": [
          "receipts"
        ],
        "description": "Public Meta challenge endpoint. Validates the token against the encrypted, current, non-revoked sender credential inside the named tenant. Tenant and connection IDs are routing hints, not authority. Does not disclose configuration or mutate delivery state.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "enum": [
                "subscribe"
              ]
            },
            "in": "query",
            "name": "hub.mode",
            "required": true
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "in": "query",
            "name": "hub.verify_token",
            "required": true
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "in": "query",
            "name": "hub.challenge",
            "required": true
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "query",
            "name": "connection_id",
            "required": true
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "query",
            "name": "tenant_id",
            "required": true
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "meta_whatsapp"
              ]
            },
            "in": "path",
            "name": "providerId",
            "required": true
          }
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "Exact challenge as text/plain",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "Invalid subscription authority"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/provider-webhooks/example"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/provider-webhooks/example')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/v1/provider-webhooks/example\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/v1/provider-webhooks/example');"
          }
        ]
      },
      "post": {
        "operationId": "postV1ProviderWebhooksProviderId",
        "summary": "Recibo de entrega de um provider",
        "tags": [
          "operação"
        ],
        "description": "Autenticado pela **assinatura do provider**, não pela chave de API deste serviço: `X-Twilio-Signature`\n(HMAC-SHA1 sobre a URL chamada mais os parâmetros ordenados) ou `X-Hub-Signature-256` (HMAC-SHA256\nsobre o corpo bruto). Recibo repetido é idempotente e recibo fora de ordem nunca rebaixa o estado.\n\nZavu uses X-Zavu-Signature v2; Resend uses svix-id, svix-timestamp and svix-signature. The exact raw body, provider callback URL and pinned connection authority are used for verification. A fake delivery adapter accepts x-fake-signature only in the explicit fake runtime. Do not send a backend API key to this endpoint.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {}
            },
            "application/x-www-form-urlencoded": {
              "schema": {}
            }
          }
        },
        "security": [],
        "parameters": [
          {
            "name": "providerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "twilio_whatsapp"
          },
          {
            "name": "message_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Nosso id, devolvido pelo provider no StatusCallback."
          },
          {
            "name": "x-twilio-signature",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Provider-specific signature header; use only the format of the selected runtime adapter."
          },
          {
            "name": "x-hub-signature-256",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Provider-specific signature header; use only the format of the selected runtime adapter."
          },
          {
            "name": "x-zavu-signature",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Provider-specific signature header; use only the format of the selected runtime adapter."
          },
          {
            "name": "svix-id",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Provider-specific signature header; use only the format of the selected runtime adapter."
          },
          {
            "name": "svix-timestamp",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Provider-specific signature header; use only the format of the selected runtime adapter."
          },
          {
            "name": "svix-signature",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Provider-specific signature header; use only the format of the selected runtime adapter."
          },
          {
            "name": "x-fake-signature",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Provider-specific signature header; use only the format of the selected runtime adapter."
          }
        ],
        "responses": {
          "202": {
            "description": "recibos processados",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "accepted": {
                      "type": "integer"
                    },
                    "ignored": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "externalId": {
                            "type": "string"
                          },
                          "reason": {
                            "type": "string",
                            "enum": [
                              "duplicate_receipt",
                              "stale_status",
                              "message_not_found"
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "assinatura do provider inválida"
          },
          "404": {
            "description": "provider desconhecido"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/provider-webhooks/twilio_whatsapp \\\n  --request POST"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/provider-webhooks/twilio_whatsapp', {\n  method: 'POST'\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"POST\", \"/v1/provider-webhooks/twilio_whatsapp\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/provider-webhooks/twilio_whatsapp');"
          }
        ]
      }
    },
    "/v1/provider-webhooks/{providerId}/{tenantId}/{connectionId}": {
      "get": {
        "operationId": "verifyScopedMetaWebhook",
        "summary": "Verify a Meta callback subscription",
        "tags": [
          "receipts"
        ],
        "description": "Meta callback verification with tenant and connection routing in the path. Only signed, current verification authority can echo the challenge; identifiers never grant access.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "enum": [
                "subscribe"
              ]
            },
            "in": "query",
            "name": "hub.mode",
            "required": true
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "in": "query",
            "name": "hub.verify_token",
            "required": true
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "in": "query",
            "name": "hub.challenge",
            "required": true
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "meta_whatsapp"
              ]
            },
            "in": "path",
            "name": "providerId",
            "required": true
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "tenantId",
            "required": true
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "connectionId",
            "required": true
          }
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "Exact challenge as text/plain",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "Invalid subscription authority"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/provider-webhooks/example/example/example"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/provider-webhooks/example/example/example')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/v1/provider-webhooks/example/example/example\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/v1/provider-webhooks/example/example/example');"
          }
        ]
      },
      "post": {
        "operationId": "receiveScopedMetaWebhook",
        "summary": "Recibo de entrega de um provider",
        "tags": [
          "operação"
        ],
        "description": "Receive Meta receipts for the exact connection. Requires matching tenant ownership, account and phone metadata, and the HMAC over unmodified bytes. Existing query-based provider callbacks are preserved.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {}
            },
            "application/x-www-form-urlencoded": {
              "schema": {}
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string",
              "enum": [
                "meta_whatsapp"
              ]
            },
            "in": "path",
            "name": "providerId",
            "required": true
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "tenantId",
            "required": true
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "connectionId",
            "required": true
          }
        ],
        "security": [],
        "responses": {
          "202": {
            "description": "recibos processados",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "accepted": {
                      "type": "integer"
                    },
                    "ignored": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "externalId": {
                            "type": "string"
                          },
                          "reason": {
                            "type": "string",
                            "enum": [
                              "duplicate_receipt",
                              "stale_status",
                              "message_not_found"
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "assinatura do provider inválida"
          },
          "404": {
            "description": "provider desconhecido"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/provider-webhooks/example/example/example \\\n  --request POST"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/provider-webhooks/example/example/example', {\n  method: 'POST'\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"POST\", \"/v1/provider-webhooks/example/example/example\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/provider-webhooks/example/example/example');"
          }
        ]
      }
    },
    "/v1/provider-webhooks/{providerId}/organizations/{organizationId}": {
      "get": {
        "operationId": "verifyOrganizationMetaWebhook",
        "summary": "Verify a Meta callback subscription",
        "tags": [
          "receipts"
        ],
        "description": "Verify a shared Meta sender using the named organization's enabled encrypted credential. The identifier does not grant authority; the exact verification token is required.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "enum": [
                "subscribe"
              ]
            },
            "in": "query",
            "name": "hub.mode",
            "required": true
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "in": "query",
            "name": "hub.verify_token",
            "required": true
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "in": "query",
            "name": "hub.challenge",
            "required": true
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "meta_whatsapp"
              ]
            },
            "in": "path",
            "name": "providerId",
            "required": true
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "organizationId",
            "required": true
          }
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "Exact challenge as text/plain",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "Invalid subscription authority"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/provider-webhooks/example/organizations/example"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/provider-webhooks/example/organizations/example')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/v1/provider-webhooks/example/organizations/example\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/v1/provider-webhooks/example/organizations/example');"
          }
        ]
      },
      "post": {
        "operationId": "receiveOrganizationMetaWebhook",
        "summary": "Recibo de entrega de um provider",
        "tags": [
          "operação"
        ],
        "description": "Receive HMAC-authenticated Meta delivery receipts for a shared organization sender. Every referenced message must use that organization's shared credential; tenant-connection and foreign-organization receipts are rejected. Batches can span tenants inside the same organization.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {}
            },
            "application/x-www-form-urlencoded": {
              "schema": {}
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string",
              "enum": [
                "meta_whatsapp"
              ]
            },
            "in": "path",
            "name": "providerId",
            "required": true
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "organizationId",
            "required": true
          }
        ],
        "security": [],
        "responses": {
          "202": {
            "description": "recibos processados",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "accepted": {
                      "type": "integer"
                    },
                    "ignored": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "externalId": {
                            "type": "string"
                          },
                          "reason": {
                            "type": "string",
                            "enum": [
                              "duplicate_receipt",
                              "stale_status",
                              "message_not_found"
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "assinatura do provider inválida"
          },
          "404": {
            "description": "provider desconhecido"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/provider-webhooks/example/organizations/example \\\n  --request POST"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/provider-webhooks/example/organizations/example', {\n  method: 'POST'\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"POST\", \"/v1/provider-webhooks/example/organizations/example\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/provider-webhooks/example/organizations/example');"
          }
        ]
      }
    },
    "/v1/inbox": {
      "options": {
        "responses": {
          "200": {
            "description": "Default Response"
          }
        }
      },
      "get": {
        "operationId": "getV1Inbox",
        "summary": "Consultar inbox pessoal paginada e contagem autorizada",
        "tags": [
          "central de notificações"
        ],
        "description": "Consultar inbox pessoal paginada e contagem autorizada.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 30
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 1024
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "unread",
                "archived"
              ],
              "default": "all"
            }
          }
        ],
        "security": [
          {
            "inboxGrant": []
          }
        ],
        "responses": {
          "200": {
            "description": "Resultado durável",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboxList"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Consultar inbox pessoal paginada e contagem autorizada",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Bearer inválido, revogado, expirado ou authority expirada"
          },
          "403": {
            "description": "Tenant, origem ou operação fora do escopo"
          },
          "404": {
            "description": "Recurso não encontrado no escopo"
          },
          "409": {
            "description": "Idempotência, versão de origem, CAS ou authority em conflito"
          },
          "422": {
            "description": "Entrada inválida ou limite excedido"
          },
          "429": {
            "description": "Limite de conexões ou requisições; reduzir concorrência"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/inbox"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/inbox')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/v1/inbox\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/v1/inbox');"
          }
        ]
      }
    },
    "/v1/inbox/{*}": {
      "options": {
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "*",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Default Response"
          }
        }
      }
    },
    "/v1/inbox/notifications": {
      "post": {
        "operationId": "postV1InboxNotifications",
        "summary": "Publicar aviso nativo cifrado por destinatário",
        "tags": [
          "central de notificações"
        ],
        "description": "send no backend. Mesmo pedido/chave retorna recibo original. Template usa versão push do catálogo existente; publicar inbox não reenvia e-mail/WhatsApp. schedule.at agenda na JobQueue existente; antes da ativação não existe item visível nem não lido. group_ref permite watermark de origem para substituição/cancelamento de múltiplos lembretes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "recipient_ref": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 180,
                    "pattern": "^[A-Za-z0-9_.:@/-]+$"
                  },
                  "resource_ref": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 180,
                    "pattern": "^[A-Za-z0-9_.:@/-]+$"
                  },
                  "source": {
                    "type": "object",
                    "properties": {
                      "service": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64,
                        "pattern": "^[a-z][a-z0-9_.-]*$"
                      },
                      "event_id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 180,
                        "pattern": "^[A-Za-z0-9_.:@/-]+$"
                      },
                      "group_ref": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 180,
                        "pattern": "^[A-Za-z0-9_.:@/-]+$"
                      },
                      "event_version": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 9007199254740991
                      }
                    },
                    "required": [
                      "service",
                      "event_id",
                      "event_version"
                    ],
                    "additionalProperties": false
                  },
                  "template": {
                    "type": "object",
                    "properties": {
                      "key": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 120
                      }
                    },
                    "required": [
                      "key"
                    ],
                    "additionalProperties": false
                  },
                  "parties": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 40
                    },
                    "additionalProperties": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 180,
                      "pattern": "^[A-Za-z0-9_.:@/-]+$"
                    }
                  },
                  "variables": {
                    "default": {},
                    "type": "object",
                    "propertyNames": {
                      "type": "string",
                      "maxLength": 80
                    },
                    "additionalProperties": {
                      "anyOf": [
                        {
                          "type": "string",
                          "maxLength": 500
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "presentation": {
                    "type": "object",
                    "properties": {
                      "group_key": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 180,
                        "pattern": "^[A-Za-z0-9_.:@/-]+$"
                      },
                      "attention": {
                        "default": "information",
                        "type": "string",
                        "enum": [
                          "action_required",
                          "reminder",
                          "information"
                        ]
                      }
                    },
                    "required": [
                      "group_key"
                    ],
                    "additionalProperties": false
                  },
                  "action": {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64,
                        "pattern": "^[a-z][a-z0-9_.-]*$"
                      },
                      "reference": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 180,
                        "pattern": "^[A-Za-z0-9_.:@/-]+$"
                      }
                    },
                    "required": [
                      "type",
                      "reference"
                    ],
                    "additionalProperties": false
                  },
                  "schedule": {
                    "type": "object",
                    "properties": {
                      "at": {
                        "type": "string",
                        "format": "date-time",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
                      }
                    },
                    "required": [
                      "at"
                    ],
                    "additionalProperties": false
                  },
                  "expires_at": {
                    "type": "string",
                    "format": "date-time",
                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
                  },
                  "push": {
                    "default": false,
                    "type": "boolean"
                  },
                  "cancelled": {
                    "default": false,
                    "type": "boolean"
                  }
                },
                "required": [
                  "recipient_ref",
                  "source",
                  "template"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resultado durável",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboxPublishReceipt"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Publicar aviso nativo cifrado por destinatário",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Bearer inválido, revogado, expirado ou authority expirada"
          },
          "403": {
            "description": "Tenant, origem ou operação fora do escopo"
          },
          "404": {
            "description": "Recurso não encontrado no escopo"
          },
          "409": {
            "description": "Idempotência, versão de origem, CAS ou authority em conflito"
          },
          "422": {
            "description": "Entrada inválida ou limite excedido"
          },
          "429": {
            "description": "Limite de conexões ou requisições; reduzir concorrência"
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          }
        ],
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/inbox/notifications \\\n  --request POST"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/inbox/notifications', {\n  method: 'POST'\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"POST\", \"/v1/inbox/notifications\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/inbox/notifications');"
          }
        ]
      }
    },
    "/v1/inbox/cancel-by-source": {
      "post": {
        "operationId": "postV1InboxCancelBySource",
        "summary": "Cancelar grupo de avisos ou avançar watermark sem cancelar",
        "tags": [
          "central de notificações"
        ],
        "description": "cancelled=true grava tombstone terminal e cancela todos do grupo. cancelled=false avança a versão e impede ativação tardia de lembretes antigos, mesmo sem novos offsets. event_id identifica source.group_ref. Versão antiga ou tentativa de reabrir grupo cancelado resulta409.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "recipient_ref": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 180,
                    "pattern": "^[A-Za-z0-9_.:@/-]+$"
                  },
                  "source": {
                    "type": "object",
                    "properties": {
                      "service": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64,
                        "pattern": "^[a-z][a-z0-9_.-]*$"
                      },
                      "event_id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 180,
                        "pattern": "^[A-Za-z0-9_.:@/-]+$"
                      },
                      "event_version": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 9007199254740991
                      }
                    },
                    "required": [
                      "service",
                      "event_id",
                      "event_version"
                    ],
                    "additionalProperties": false
                  },
                  "cancelled": {
                    "default": true,
                    "type": "boolean"
                  }
                },
                "required": [
                  "recipient_ref",
                  "source"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Resultado durável",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboxSourceReceipt"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Cancelar grupo de avisos ou avançar watermark sem cancelar",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Bearer inválido, revogado, expirado ou authority expirada"
          },
          "403": {
            "description": "Tenant, origem ou operação fora do escopo"
          },
          "404": {
            "description": "Recurso não encontrado no escopo"
          },
          "409": {
            "description": "Idempotência, versão de origem, CAS ou authority em conflito"
          },
          "422": {
            "description": "Entrada inválida ou limite excedido"
          },
          "429": {
            "description": "Limite de conexões ou requisições; reduzir concorrência"
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          }
        ],
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/inbox/cancel-by-source \\\n  --request POST"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/inbox/cancel-by-source', {\n  method: 'POST'\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"POST\", \"/v1/inbox/cancel-by-source\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/inbox/cancel-by-source');"
          }
        ]
      }
    },
    "/v1/inbox/grants": {
      "post": {
        "operationId": "postV1InboxGrants",
        "summary": "Emitir capacidade pessoal curta com authority externa",
        "tags": [
          "central de notificações"
        ],
        "description": "Backend read autorizado; ttl<=300s, authority_valid_until<=10s, owner_ref estável por processo. resource_refs vazio concede nenhum recurso; include_generic habilita apenas avisos sem resource_ref. Segredo somente em memória do navegador. Recibo idempotente cifrado; replay nunca reativa grant revogado/expirado.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "recipient_ref": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 180,
                    "pattern": "^[A-Za-z0-9_.:@/-]+$"
                  },
                  "principal_ref": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 180,
                    "pattern": "^[A-Za-z0-9_.:@/-]+$"
                  },
                  "resource_refs": {
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 180,
                      "pattern": "^[A-Za-z0-9_.:@/-]+$"
                    }
                  },
                  "include_generic": {
                    "default": false,
                    "type": "boolean"
                  },
                  "ttl_seconds": {
                    "default": 300,
                    "type": "integer",
                    "minimum": 10,
                    "maximum": 300
                  },
                  "owner_ref": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 180,
                    "pattern": "^[A-Za-z0-9_.:@/-]+$"
                  },
                  "authority_valid_until": {
                    "type": "string",
                    "format": "date-time",
                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
                  },
                  "push_enrollment": {
                    "type": "object",
                    "properties": {
                      "device_ref": {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      "binding_ref": {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      "authority_version": {
                        "type": "integer",
                        "exclusiveMinimum": 0,
                        "maximum": 9007199254740991
                      }
                    },
                    "required": [
                      "device_ref",
                      "binding_ref",
                      "authority_version"
                    ],
                    "additionalProperties": false
                  }
                },
                "required": [
                  "recipient_ref",
                  "principal_ref",
                  "resource_refs",
                  "owner_ref",
                  "authority_valid_until"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Resultado durável",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboxGrant"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Emitir capacidade pessoal curta com authority externa",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Bearer inválido, revogado, expirado ou authority expirada"
          },
          "403": {
            "description": "Tenant, origem ou operação fora do escopo"
          },
          "404": {
            "description": "Recurso não encontrado no escopo"
          },
          "409": {
            "description": "Idempotência, versão de origem, CAS ou authority em conflito"
          },
          "422": {
            "description": "Entrada inválida ou limite excedido"
          },
          "429": {
            "description": "Limite de conexões ou requisições; reduzir concorrência"
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          }
        ],
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/inbox/grants \\\n  --request POST"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/inbox/grants', {\n  method: 'POST'\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"POST\", \"/v1/inbox/grants\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/inbox/grants');"
          }
        ]
      }
    },
    "/v1/inbox/grants/{id}/authority": {
      "patch": {
        "operationId": "patchV1InboxGrantsIdAuthority",
        "summary": "Renovar lease externa por CAS e mesmo owner",
        "tags": [
          "central de notificações"
        ],
        "description": "Renovar antes de expirar. Lease de no máximo10s, revisão esperada e owner impedem publicação tardia por worker antigo. Lease expirada exige novo grant; não pode ser revivida.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "owner_ref": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 180,
                    "pattern": "^[A-Za-z0-9_.:@/-]+$"
                  },
                  "expected_revision": {
                    "type": "integer",
                    "exclusiveMinimum": 0,
                    "maximum": 9007199254740991
                  },
                  "authority_valid_until": {
                    "type": "string",
                    "format": "date-time",
                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
                  }
                },
                "required": [
                  "owner_ref",
                  "expected_revision",
                  "authority_valid_until"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Resultado durável",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "grant_id",
                    "revision",
                    "authority_valid_until"
                  ],
                  "properties": {
                    "grant_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "revision": {
                      "type": "integer",
                      "minimum": 1
                    },
                    "authority_valid_until": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                },
                "examples": {
                  "exemplo": {
                    "summary": "Renovar lease externa por CAS e mesmo owner",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Bearer inválido, revogado, expirado ou authority expirada"
          },
          "403": {
            "description": "Tenant, origem ou operação fora do escopo"
          },
          "404": {
            "description": "Recurso não encontrado no escopo"
          },
          "409": {
            "description": "Idempotência, versão de origem, CAS ou authority em conflito"
          },
          "422": {
            "description": "Entrada inválida ou limite excedido"
          },
          "429": {
            "description": "Limite de conexões ou requisições; reduzir concorrência"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/inbox/grants/example/authority \\\n  --request PATCH"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/inbox/grants/example/authority', {\n  method: 'PATCH'\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"PATCH\", \"/v1/inbox/grants/example/authority\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('PATCH', 'http://localhost:47311/v1/inbox/grants/example/authority');"
          }
        ]
      }
    },
    "/v1/inbox/grants/revoke": {
      "post": {
        "operationId": "postV1InboxGrantsRevoke",
        "summary": "Revogar grants pessoais já emitidos",
        "tags": [
          "central de notificações"
        ],
        "description": "Exige recipient_ref ou grant_id. Revogação afeta novas leituras imediatamente e streams na próxima batida, até5s. Browser/logout também cancela transporte local.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "recipient_ref": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 180,
                    "pattern": "^[A-Za-z0-9_.:@/-]+$"
                  },
                  "principal_ref": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 180,
                    "pattern": "^[A-Za-z0-9_.:@/-]+$"
                  },
                  "grant_id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Resultado durável",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "revoked"
                  ],
                  "properties": {
                    "revoked": {
                      "type": "integer",
                      "minimum": 0
                    }
                  }
                },
                "examples": {
                  "exemplo": {
                    "summary": "Revogar grants pessoais já emitidos",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Bearer inválido, revogado, expirado ou authority expirada"
          },
          "403": {
            "description": "Tenant, origem ou operação fora do escopo"
          },
          "404": {
            "description": "Recurso não encontrado no escopo"
          },
          "409": {
            "description": "Idempotência, versão de origem, CAS ou authority em conflito"
          },
          "422": {
            "description": "Entrada inválida ou limite excedido"
          },
          "429": {
            "description": "Limite de conexões ou requisições; reduzir concorrência"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/inbox/grants/revoke \\\n  --request POST"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/inbox/grants/revoke', {\n  method: 'POST'\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"POST\", \"/v1/inbox/grants/revoke\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/inbox/grants/revoke');"
          }
        ]
      }
    },
    "/v1/inbox/summary": {
      "get": {
        "operationId": "getV1InboxSummary",
        "summary": "Contar não lidos e obter cursor autorizado",
        "tags": [
          "central de notificações"
        ],
        "description": "Contar não lidos e obter cursor autorizado.",
        "security": [
          {
            "inboxGrant": []
          }
        ],
        "responses": {
          "200": {
            "description": "Resultado durável",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboxSummary"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Contar não lidos e obter cursor autorizado",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Bearer inválido, revogado, expirado ou authority expirada"
          },
          "403": {
            "description": "Tenant, origem ou operação fora do escopo"
          },
          "404": {
            "description": "Recurso não encontrado no escopo"
          },
          "409": {
            "description": "Idempotência, versão de origem, CAS ou authority em conflito"
          },
          "422": {
            "description": "Entrada inválida ou limite excedido"
          },
          "429": {
            "description": "Limite de conexões ou requisições; reduzir concorrência"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/inbox/summary"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/inbox/summary')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/v1/inbox/summary\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/v1/inbox/summary');"
          }
        ]
      }
    },
    "/v1/inbox/{id}": {
      "get": {
        "operationId": "getV1InboxId",
        "summary": "Consultar um aviso autorizado",
        "tags": [
          "central de notificações"
        ],
        "description": "Consultar um aviso autorizado.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "security": [
          {
            "inboxGrant": []
          }
        ],
        "responses": {
          "200": {
            "description": "Resultado durável",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboxItem"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Consultar um aviso autorizado",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Bearer inválido, revogado, expirado ou authority expirada"
          },
          "403": {
            "description": "Tenant, origem ou operação fora do escopo"
          },
          "404": {
            "description": "Recurso não encontrado no escopo"
          },
          "409": {
            "description": "Idempotência, versão de origem, CAS ou authority em conflito"
          },
          "422": {
            "description": "Entrada inválida ou limite excedido"
          },
          "429": {
            "description": "Limite de conexões ou requisições; reduzir concorrência"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/inbox/example"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/inbox/example')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/v1/inbox/example\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/v1/inbox/example');"
          }
        ]
      },
      "patch": {
        "operationId": "patchV1InboxId",
        "summary": "Marcar lido/não lido ou arquivar por revisão",
        "tags": [
          "central de notificações"
        ],
        "description": "Pelo menos read ou archived. No-op idempotente; revisão divergente que alteraria estado retorna409. A aplicação resolve action.type/reference somente após nova autorização do recurso.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "revision": {
                    "type": "integer",
                    "exclusiveMinimum": 0,
                    "maximum": 9007199254740991
                  },
                  "read": {
                    "type": "boolean"
                  },
                  "archived": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "revision"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "security": [
          {
            "inboxGrant": []
          }
        ],
        "responses": {
          "200": {
            "description": "Resultado durável",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboxItem"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Marcar lido/não lido ou arquivar por revisão",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Bearer inválido, revogado, expirado ou authority expirada"
          },
          "403": {
            "description": "Tenant, origem ou operação fora do escopo"
          },
          "404": {
            "description": "Recurso não encontrado no escopo"
          },
          "409": {
            "description": "Idempotência, versão de origem, CAS ou authority em conflito"
          },
          "422": {
            "description": "Entrada inválida ou limite excedido"
          },
          "429": {
            "description": "Limite de conexões ou requisições; reduzir concorrência"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/inbox/example \\\n  --request PATCH"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/inbox/example', {\n  method: 'PATCH'\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"PATCH\", \"/v1/inbox/example\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('PATCH', 'http://localhost:47311/v1/inbox/example');"
          }
        ]
      }
    },
    "/v1/inbox/push/config": {
      "get": {
        "operationId": "getV1InboxPushConfig",
        "summary": "Consultar disponibilidade de Web Push e chave VAPID pública",
        "tags": [
          "central de notificações"
        ],
        "description": "Consultar disponibilidade de Web Push e chave VAPID pública.",
        "security": [
          {
            "inboxGrant": []
          }
        ],
        "responses": {
          "200": {
            "description": "Resultado durável",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboxPushConfig"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Consultar disponibilidade de Web Push e chave VAPID pública",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Bearer inválido, revogado, expirado ou authority expirada"
          },
          "403": {
            "description": "Tenant, origem ou operação fora do escopo"
          },
          "404": {
            "description": "Recurso não encontrado no escopo"
          },
          "409": {
            "description": "Idempotência, versão de origem, CAS ou authority em conflito"
          },
          "422": {
            "description": "Entrada inválida ou limite excedido"
          },
          "429": {
            "description": "Limite de conexões ou requisições; reduzir concorrência"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/inbox/push/config"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/inbox/push/config')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/v1/inbox/push/config\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/v1/inbox/push/config');"
          }
        ]
      }
    },
    "/v1/inbox/push/subscriptions": {
      "put": {
        "operationId": "putV1InboxPushSubscriptions",
        "summary": "Registrar ou renovar dispositivo e binding autorizado",
        "tags": [
          "central de notificações"
        ],
        "description": "Até10 dispositivos ativos/recipient,30dias de enrollment. Segredos cifrados. Mesmo device_ref faz upsert e generation fencing; binding_ref protege troca/logout. Endpoint externo só de host allowlist. Push usa mensagem genérica e job existente, com authority de backend consultada no envio.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "device_ref": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "binding_ref": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "authority_version": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 9007199254740991
                  },
                  "subscription": {
                    "type": "object",
                    "properties": {
                      "endpoint": {
                        "type": "string",
                        "maxLength": 2048
                      },
                      "expirationTime": {
                        "anyOf": [
                          {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 9007199254740991
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "keys": {
                        "type": "object",
                        "properties": {
                          "p256dh": {
                            "type": "string",
                            "maxLength": 100
                          },
                          "auth": {
                            "type": "string",
                            "maxLength": 40
                          }
                        },
                        "required": [
                          "p256dh",
                          "auth"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "required": [
                      "endpoint",
                      "keys"
                    ],
                    "additionalProperties": false
                  }
                },
                "required": [
                  "device_ref",
                  "binding_ref",
                  "authority_version",
                  "subscription"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "security": [
          {
            "inboxGrant": []
          }
        ],
        "responses": {
          "200": {
            "description": "Resultado durável",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboxPushRegistered"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Registrar ou renovar dispositivo e binding autorizado",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Bearer inválido, revogado, expirado ou authority expirada"
          },
          "403": {
            "description": "Tenant, origem ou operação fora do escopo"
          },
          "404": {
            "description": "Recurso não encontrado no escopo"
          },
          "409": {
            "description": "Idempotência, versão de origem, CAS ou authority em conflito"
          },
          "422": {
            "description": "Entrada inválida ou limite excedido"
          },
          "429": {
            "description": "Limite de conexões ou requisições; reduzir concorrência"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/inbox/push/subscriptions \\\n  --request PUT"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/inbox/push/subscriptions', {\n  method: 'PUT'\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"PUT\", \"/v1/inbox/push/subscriptions\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('PUT', 'http://localhost:47311/v1/inbox/push/subscriptions');"
          }
        ]
      }
    },
    "/v1/inbox/push/subscriptions/{id}": {
      "delete": {
        "operationId": "deleteV1InboxPushSubscriptionsId",
        "summary": "Revogar dispositivo com binding CAS",
        "tags": [
          "central de notificações"
        ],
        "description": "Binding antigo não revoga enrollment novo. Browser limpa binding no IndexedDB no logout e troca de Account, impedindo mostrar push atrasado do contexto anterior.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "binding_ref": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  }
                },
                "required": [
                  "binding_ref"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "security": [
          {
            "inboxGrant": []
          }
        ],
        "responses": {
          "200": {
            "description": "Resultado durável",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "revoked"
                  ],
                  "properties": {
                    "revoked": {
                      "type": "boolean"
                    },
                    "stale_binding": {
                      "type": "boolean"
                    }
                  }
                },
                "examples": {
                  "exemplo": {
                    "summary": "Revogar dispositivo com binding CAS",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Bearer inválido, revogado, expirado ou authority expirada"
          },
          "403": {
            "description": "Tenant, origem ou operação fora do escopo"
          },
          "404": {
            "description": "Recurso não encontrado no escopo"
          },
          "409": {
            "description": "Idempotência, versão de origem, CAS ou authority em conflito"
          },
          "422": {
            "description": "Entrada inválida ou limite excedido"
          },
          "429": {
            "description": "Limite de conexões ou requisições; reduzir concorrência"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/inbox/push/subscriptions/example \\\n  --request DELETE"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/inbox/push/subscriptions/example', {\n  method: 'DELETE'\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"DELETE\", \"/v1/inbox/push/subscriptions/example\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('DELETE', 'http://localhost:47311/v1/inbox/push/subscriptions/example');"
          }
        ]
      }
    },
    "/v1/inbox/events": {
      "get": {
        "operationId": "getV1InboxEvents",
        "summary": "Receber sinais nativos SSE de inbox; estado permanece HTTP/PG",
        "tags": [
          "central de notificações"
        ],
        "description": "Authorization no header, nunca em URL/cookie. event:changed data:{revision:string} id:<cursor>. event:reset data:{reason:snapshot_required} indica snapshotHTTP. Sinais sem títulos, textos, contatos ou ids de destinatário. Replay7dias/100sinais; heartbeat e revalidação5s. Uma conexão por contexto ativo; limites200/processo e3/grant; backpressure encerra para reconciliação. CORS allowlist explícita.",
        "security": [
          {
            "inboxGrant": []
          }
        ],
        "responses": {
          "200": {
            "description": "Fluxo SSE autorizado",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Receber sinais nativos SSE de inbox; estado permanece HTTP/PG",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Bearer inválido, revogado, expirado ou authority expirada"
          },
          "403": {
            "description": "Tenant, origem ou operação fora do escopo"
          },
          "404": {
            "description": "Recurso não encontrado no escopo"
          },
          "409": {
            "description": "Idempotência, versão de origem, CAS ou authority em conflito"
          },
          "422": {
            "description": "Entrada inválida ou limite excedido"
          },
          "429": {
            "description": "Limite de conexões ou requisições; reduzir concorrência"
          }
        },
        "parameters": [
          {
            "name": "Last-Event-ID",
            "in": "header",
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{1,19}$"
            }
          }
        ],
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/inbox/events"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/inbox/events')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/v1/inbox/events\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/v1/inbox/events');"
          }
        ]
      }
    },
    "/v1/testing/template-messages": {
      "post": {
        "operationId": "postV1TestingTemplateMessages",
        "summary": "Preview, send an isolated template test, or read its delivery history",
        "tags": [
          "operação"
        ],
        "description": "Requires admin, read and send. Available only with delivery testing enabled. Server-owned allowlisted destinations and synthetic profiles; never changes the tenant delivery profile or source messages. Send requires a matching preview token and Idempotency-Key, has a 60-second per-channel cooldown and a daily cap. Delivery runs through the existing worker and adapters. Reconcile requires message_id, queues a read-only provider check, coalesces concurrent clicks and enforces a 20-second cooldown per message. It never sends or retries delivery. Response state is queued, checking, cached or complete. With action history and Accept text/event-stream, opens a scoped invalidation stream for that tenant, principal and context. Other actions cannot stream. Initial signal and reconnect require reading the JSON history; no provider query or send is triggered.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "action": {
                    "type": "string",
                    "enum": [
                      "preview",
                      "send",
                      "history",
                      "reconcile"
                    ]
                  },
                  "principal_ref": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 128
                  },
                  "context_ref": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 128
                  },
                  "template_key": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  },
                  "catalog_key": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  },
                  "event_key": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 160
                  },
                  "destination": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 254
                  },
                  "channel": {
                    "type": "string",
                    "enum": [
                      "email",
                      "whatsapp"
                    ]
                  },
                  "timezone": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 64
                  },
                  "locale": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 35
                  },
                  "variables": {
                    "default": {},
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  },
                  "message_id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "preview_token": {
                    "type": "string",
                    "pattern": "^[a-f0-9]{64}$"
                  }
                },
                "required": [
                  "action",
                  "principal_ref",
                  "context_ref",
                  "channel",
                  "timezone",
                  "locale"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Preview, durable test acceptance or isolated delivery history",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string",
                  "description": "event changed with data {\"changed\":true}; no content or recipient payload."
                }
              },
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                },
                "examples": {
                  "exemplo": {
                    "summary": "Preview, send an isolated template test, or read its delivery history",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Scope",
            "template or destination unavailable": null
          },
          "404": {
            "description": "Testing disabled"
          },
          "409": {
            "description": "Preview changed or idempotency conflict"
          },
          "429": {
            "description": "Cooldown or daily test budget reached"
          }
        },
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "description": "Required only for action=send; reuse after an uncertain response.",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/testing/template-messages \\\n  --request POST"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/testing/template-messages', {\n  method: 'POST'\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"POST\", \"/v1/testing/template-messages\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/testing/template-messages');"
          }
        ]
      }
    },
    "/v1/testing/profile": {
      "get": {
        "operationId": "getV1TestingProfile",
        "summary": "Estado de validação local do tenant",
        "tags": [
          "operação"
        ],
        "description": "Exige read. Retorna enabled=false quando testes estão desligados. Não revela destinatários autorizados nem credenciais.",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Estado",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "enabled": {
                      "type": "boolean"
                    },
                    "mode": {
                      "type": "string",
                      "enum": [
                        "simulated",
                        "live_test"
                      ]
                    },
                    "revision": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "liveAvailable": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "enabled"
                  ]
                },
                "examples": {
                  "exemplo": {
                    "summary": "Estado de validação local do tenant",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/testing/profile"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/testing/profile')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/v1/testing/profile\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/v1/testing/profile');"
          }
        ]
      },
      "put": {
        "operationId": "putV1TestingProfile",
        "summary": "Alterar modo de novas mensagens de teste",
        "tags": [
          "operação"
        ],
        "description": "Apenas fora de produção, com servidor em loopback e testes habilitados. Exige admin e Idempotency-Key. Mensagens existentes mantêm seu modo. Live exige destinatários autorizados no servidor.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "mode": {
                    "type": "string",
                    "enum": [
                      "simulated",
                      "live_test"
                    ]
                  },
                  "expected_revision": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  }
                },
                "required": [
                  "mode",
                  "expected_revision"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Modo salvo ou recibo idempotente",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Alterar modo de novas mensagens de teste",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Sem permissão ou sem destinatários autorizados"
          },
          "404": {
            "description": "Testes desabilitados"
          },
          "409": {
            "description": "Revisão ou chave conflitante"
          },
          "422": {
            "description": "Pedido inválido"
          }
        },
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/testing/profile \\\n  --request PUT"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/testing/profile', {\n  method: 'PUT'\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"PUT\", \"/v1/testing/profile\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('PUT', 'http://localhost:47311/v1/testing/profile');"
          }
        ]
      }
    },
    "/v1/testing/messages/{id}/actions": {
      "post": {
        "operationId": "postV1TestingMessagesIdActions",
        "summary": "Simular falha/recibo ou consultar recibo real",
        "tags": [
          "operação"
        ],
        "description": "Exige admin e testes locais habilitados. source_event_id deve pertencer ao mesmo tenant e à mensagem. Simulação exige marcador persistido simulated; não altera mensagens reais. Falha aplica-se no horário original e só antes da primeira tentativa. Reconcile faz GET ao provedor e passa pelo inbox idempotente.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source_event_id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "action": {
                    "type": "string",
                    "enum": [
                      "retryable",
                      "permanent",
                      "delivered",
                      "read",
                      "replay",
                      "reconcile"
                    ]
                  }
                },
                "required": [
                  "source_event_id",
                  "action"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Falha configurada ou resultado do inbox de recibos",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Simular falha/recibo ou consultar recibo real",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Sem permissão ou tentativa de simular mensagem real"
          },
          "404": {
            "description": "Recurso fora do escopo ou testes desabilitados"
          },
          "409": {
            "description": "Ação incompatível com o estado ou chave conflitante"
          },
          "422": {
            "description": "Pedido inválido"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/testing/messages/example/actions \\\n  --request POST"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/testing/messages/example/actions', {\n  method: 'POST'\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"POST\", \"/v1/testing/messages/example/actions\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/testing/messages/example/actions');"
          }
        ]
      }
    },
    "/v1/sender-connections": {
      "get": {
        "operationId": "GET_v1_sender_connections",
        "summary": "List tenant sender connections",
        "tags": [
          "sender management"
        ],
        "description": "List tenant sender connections. Requires admin scope; tenant resources also require a tenant-scoped key or X-Anam-Tenant. Writes are durable before provider I/O. Provider approval is distinct from operation completion and message delivery. Credentials and raw provider responses are never returned. See docs/sender-connections.md for onboarding, exact credential formats, revision fencing, safe reconciliation and compatibility.",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Durable result; external work may still be pending.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "example": {
                    "value": {
                      "connections": [
                        {
                          "id": "11111111-1111-4111-8111-111111111111",
                          "external_ref": "primary-whatsapp",
                          "provider_id": "zavu_whatsapp",
                          "state": "pending",
                          "revision": 1,
                          "is_default": false,
                          "credential_revision": 1,
                          "webhook_url": "https://notifications.example.test/v1/provider-webhooks/zavu_whatsapp?connection_id=11111111-1111-4111-8111-111111111111"
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/sender-connections"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/sender-connections')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/v1/sender-connections\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/v1/sender-connections');"
          }
        ]
      },
      "post": {
        "operationId": "POST_v1_sender_connections",
        "summary": "Register a tenant sender connection",
        "tags": [
          "sender management"
        ],
        "description": "Register a tenant sender connection. Requires admin scope; tenant resources also require a tenant-scoped key or X-Anam-Tenant. Writes are durable before provider I/O. Provider approval is distinct from operation completion and message delivery. Credentials and raw provider responses are never returned. See docs/sender-connections.md for onboarding, exact credential formats, revision fencing, safe reconciliation and compatibility.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "config": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  },
                  "processor_jurisdiction": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "BR",
                          "EU",
                          "US",
                          "OTHER"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "transfer_safeguards": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "dpa": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "anpd_annex_ii": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "eu_scc": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "importer_entity": {
                            "anyOf": [
                              {
                                "type": "string",
                                "maxLength": 200
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "notes": {
                            "anyOf": [
                              {
                                "type": "string",
                                "maxLength": 1000
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "external_ref": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 128
                  },
                  "provider_id": {
                    "type": "string",
                    "enum": [
                      "twilio_whatsapp",
                      "zavu_whatsapp",
                      "meta_whatsapp"
                    ]
                  }
                },
                "required": [
                  "config",
                  "external_ref",
                  "provider_id"
                ],
                "additionalProperties": false
              },
              "examples": {
                "example": {
                  "value": {
                    "external_ref": "primary-whatsapp",
                    "provider_id": "zavu_whatsapp",
                    "config": {}
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "201": {
            "description": "Durable result; external work may still be pending.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "example": {
                    "value": {
                      "id": "11111111-1111-4111-8111-111111111111",
                      "external_ref": "primary-whatsapp",
                      "provider_id": "zavu_whatsapp",
                      "state": "pending",
                      "revision": 1,
                      "is_default": false,
                      "credential_revision": 1,
                      "webhook_url": "https://notifications.example.test/v1/provider-webhooks/zavu_whatsapp?connection_id=11111111-1111-4111-8111-111111111111"
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            },
            "example": "operation-0001"
          }
        ],
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/sender-connections \\\n  --request POST \\\n  --header 'content-type: application/json' \\\n  --data '{\n  \"external_ref\": \"primary-whatsapp\",\n  \"provider_id\": \"zavu_whatsapp\",\n  \"config\": {}\n}'"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/sender-connections', {\n  method: 'POST',\n  headers: {\n    'content-type': 'application/json'\n  },\n  body: JSON.stringify({\n    external_ref: 'primary-whatsapp',\n    provider_id: 'zavu_whatsapp',\n    config: {}\n  })\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\nimport json\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\npayload = json.dumps({\n  \"external_ref\": \"primary-whatsapp\",\n  \"provider_id\": \"zavu_whatsapp\",\n  \"config\": {}\n})\nheaders = {\n  \"content-type\": \"application/json\"\n}\n\nconn.request(\n    \"POST\",\n    \"/v1/sender-connections\",\n    body=payload,\n    headers=headers,\n)\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/sender-connections', [\n  'headers' => [\n    'content-type' => 'application/json'\n  ],\n  'json' => [\n    'external_ref' => 'primary-whatsapp',\n    'provider_id' => 'zavu_whatsapp',\n    'config' => []\n  ]\n]);"
          }
        ]
      }
    },
    "/v1/sender-connections/{id}": {
      "get": {
        "operationId": "GET_v1_sender_connections_id",
        "summary": "Read a tenant sender connection",
        "tags": [
          "sender management"
        ],
        "description": "Read a tenant sender connection. Requires admin scope; tenant resources also require a tenant-scoped key or X-Anam-Tenant. Writes are durable before provider I/O. Provider approval is distinct from operation completion and message delivery. Credentials and raw provider responses are never returned. See docs/sender-connections.md for onboarding, exact credential formats, revision fencing, safe reconciliation and compatibility.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Durable result; external work may still be pending.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "example": {
                    "value": {
                      "id": "11111111-1111-4111-8111-111111111111",
                      "external_ref": "primary-whatsapp",
                      "provider_id": "zavu_whatsapp",
                      "state": "pending",
                      "revision": 1,
                      "is_default": false,
                      "credential_revision": 1,
                      "webhook_url": "https://notifications.example.test/v1/provider-webhooks/zavu_whatsapp?connection_id=11111111-1111-4111-8111-111111111111"
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/sender-connections/example"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/sender-connections/example')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/v1/sender-connections/example\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/v1/sender-connections/example');"
          }
        ]
      },
      "patch": {
        "operationId": "PATCH_v1_sender_connections_id",
        "summary": "Update a sender with revision fencing",
        "tags": [
          "sender management"
        ],
        "description": "Update a sender with revision fencing. Requires admin scope; tenant resources also require a tenant-scoped key or X-Anam-Tenant. Writes are durable before provider I/O. Provider approval is distinct from operation completion and message delivery. Credentials and raw provider responses are never returned. See docs/sender-connections.md for onboarding, exact credential formats, revision fencing, safe reconciliation and compatibility.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "expected_revision": {
                    "type": "integer",
                    "exclusiveMinimum": 0,
                    "maximum": 9007199254740991
                  },
                  "config": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  },
                  "is_default": {
                    "type": "boolean"
                  },
                  "state": {
                    "type": "string",
                    "enum": [
                      "inactive"
                    ]
                  },
                  "processor_jurisdiction": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "BR",
                          "EU",
                          "US",
                          "OTHER"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "transfer_safeguards": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "dpa": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "anpd_annex_ii": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "eu_scc": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "importer_entity": {
                            "anyOf": [
                              {
                                "type": "string",
                                "maxLength": 200
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "notes": {
                            "anyOf": [
                              {
                                "type": "string",
                                "maxLength": 1000
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "expected_revision"
                ],
                "additionalProperties": false
              },
              "examples": {
                "example": {
                  "value": {
                    "expected_revision": 2,
                    "is_default": true
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Durable result; external work may still be pending.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "example": {
                    "value": {
                      "id": "11111111-1111-4111-8111-111111111111",
                      "external_ref": "primary-whatsapp",
                      "provider_id": "zavu_whatsapp",
                      "state": "ready",
                      "revision": 3,
                      "is_default": true,
                      "credential_revision": 1,
                      "webhook_url": "https://notifications.example.test/v1/provider-webhooks/zavu_whatsapp?connection_id=11111111-1111-4111-8111-111111111111"
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/sender-connections/example \\\n  --request PATCH \\\n  --header 'content-type: application/json' \\\n  --data '{\n  \"expected_revision\": 2,\n  \"is_default\": true\n}'"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/sender-connections/example', {\n  method: 'PATCH',\n  headers: {\n    'content-type': 'application/json'\n  },\n  body: JSON.stringify({\n    expected_revision: 2,\n    is_default: true\n  })\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\nimport json\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\npayload = json.dumps({\n  \"expected_revision\": 2,\n  \"is_default\": True\n})\nheaders = {\n  \"content-type\": \"application/json\"\n}\n\nconn.request(\n    \"PATCH\",\n    \"/v1/sender-connections/example\",\n    body=payload,\n    headers=headers,\n)\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('PATCH', 'http://localhost:47311/v1/sender-connections/example', [\n  'headers' => [\n    'content-type' => 'application/json'\n  ],\n  'json' => [\n    'expected_revision' => 2,\n    'is_default' => true\n  ]\n]);"
          }
        ]
      }
    },
    "/v1/sender-connections/{id}/revocations": {
      "post": {
        "operationId": "POST_v1_sender_connections_id_revocations",
        "summary": "Revoke a sender credential for new sends",
        "tags": [
          "sender management"
        ],
        "description": "Revoke a sender credential for new sends. Requires admin scope; tenant resources also require a tenant-scoped key or X-Anam-Tenant. Writes are durable before provider I/O. Provider approval is distinct from operation completion and message delivery. Credentials and raw provider responses are never returned. See docs/sender-connections.md for onboarding, exact credential formats, revision fencing, safe reconciliation and compatibility.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "revision": {
                    "type": "integer",
                    "exclusiveMinimum": 0,
                    "maximum": 9007199254740991
                  }
                },
                "required": [
                  "revision"
                ],
                "additionalProperties": false
              },
              "examples": {
                "example": {
                  "value": {
                    "revision": 1
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Durable result; external work may still be pending.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "example": {
                    "value": {
                      "revoked": true
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/sender-connections/example/revocations \\\n  --request POST \\\n  --header 'content-type: application/json' \\\n  --data '{\n  \"revision\": 1\n}'"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/sender-connections/example/revocations', {\n  method: 'POST',\n  headers: {\n    'content-type': 'application/json'\n  },\n  body: JSON.stringify({\n    revision: 1\n  })\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\nimport json\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\npayload = json.dumps({\n  \"revision\": 1\n})\nheaders = {\n  \"content-type\": \"application/json\"\n}\n\nconn.request(\n    \"POST\",\n    \"/v1/sender-connections/example/revocations\",\n    body=payload,\n    headers=headers,\n)\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/sender-connections/example/revocations', [\n  'headers' => [\n    'content-type' => 'application/json'\n  ],\n  'json' => [\n    'revision' => 1\n  ]\n]);"
          }
        ]
      }
    },
    "/v1/sender-connections/{id}/operations": {
      "post": {
        "operationId": "POST_v1_sender_connections_id_operations",
        "summary": "Queue a provider management operation",
        "tags": [
          "sender management"
        ],
        "description": "Queue a provider management operation. Requires admin scope; tenant resources also require a tenant-scoped key or X-Anam-Tenant. Writes are durable before provider I/O. Provider approval is distinct from operation completion and message delivery. Credentials and raw provider responses are never returned. See docs/sender-connections.md for onboarding, exact credential formats, revision fencing, safe reconciliation and compatibility.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "verify",
                      "provision",
                      "invite",
                      "invitation_status",
                      "create_template",
                      "submit_template",
                      "template_status",
                      "adopt_template",
                      "configure_webhook"
                    ]
                  },
                  "publication_id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "spend_limit_cents": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 2147483647
                  },
                  "external_id": {
                    "type": "string",
                    "pattern": "^[a-zA-Z0-9_-]{1,200}$"
                  }
                },
                "required": [
                  "kind"
                ],
                "additionalProperties": false
              },
              "examples": {
                "example": {
                  "value": {
                    "kind": "verify"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            },
            "example": "operation-0001"
          }
        ],
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "202": {
            "description": "Durable result; external work may still be pending.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "example": {
                    "value": {
                      "id": "11111111-1111-4111-8111-111111111111",
                      "kind": "verify",
                      "state": "queued",
                      "error_code": null
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/sender-connections/example/operations \\\n  --request POST \\\n  --header 'content-type: application/json' \\\n  --data '{\n  \"kind\": \"verify\"\n}'"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/sender-connections/example/operations', {\n  method: 'POST',\n  headers: {\n    'content-type': 'application/json'\n  },\n  body: JSON.stringify({\n    kind: 'verify'\n  })\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\nimport json\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\npayload = json.dumps({\n  \"kind\": \"verify\"\n})\nheaders = {\n  \"content-type\": \"application/json\"\n}\n\nconn.request(\n    \"POST\",\n    \"/v1/sender-connections/example/operations\",\n    body=payload,\n    headers=headers,\n)\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/sender-connections/example/operations', [\n  'headers' => [\n    'content-type' => 'application/json'\n  ],\n  'json' => [\n    'kind' => 'verify'\n  ]\n]);"
          }
        ]
      }
    },
    "/v1/sender-operations/{id}": {
      "get": {
        "operationId": "GET_v1_sender_operations_id",
        "summary": "Read a management operation and onboarding result",
        "tags": [
          "sender management"
        ],
        "description": "Read a management operation and onboarding result. Requires admin scope; tenant resources also require a tenant-scoped key or X-Anam-Tenant. Writes are durable before provider I/O. Provider approval is distinct from operation completion and message delivery. Credentials and raw provider responses are never returned. See docs/sender-connections.md for onboarding, exact credential formats, revision fencing, safe reconciliation and compatibility.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Durable result; external work may still be pending.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "example": {
                    "value": {
                      "id": "11111111-1111-4111-8111-111111111111",
                      "kind": "verify",
                      "state": "succeeded",
                      "error_code": null
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/sender-operations/example"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/sender-operations/example')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/v1/sender-operations/example\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/v1/sender-operations/example');"
          }
        ]
      }
    },
    "/v1/template-publication-candidates": {
      "get": {
        "operationId": "GET_v1_template_publication_candidates",
        "summary": "Read the exact active WhatsApp version for reviewed publication",
        "tags": [
          "sender management"
        ],
        "description": "Read the exact active WhatsApp version for reviewed publication. Requires admin scope; tenant resources also require a tenant-scoped key or X-Anam-Tenant. Writes are durable before provider I/O. Provider approval is distinct from operation completion and message delivery. Credentials and raw provider responses are never returned. See docs/sender-connections.md for onboarding, exact credential formats, revision fencing, safe reconciliation and compatibility.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 120
            },
            "in": "query",
            "name": "key",
            "required": true
          },
          {
            "schema": {
              "type": "string",
              "minLength": 2,
              "maxLength": 35
            },
            "in": "query",
            "name": "locale",
            "required": true
          }
        ],
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Durable result; external work may still be pending.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "example": {
                    "value": {
                      "versions": [
                        {
                          "id": "11111111-1111-4111-8111-111111111111",
                          "channel": "whatsapp",
                          "locale": "en",
                          "status": "active",
                          "body_icu": "File {file_name} is ready."
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/template-publication-candidates"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/template-publication-candidates')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/v1/template-publication-candidates\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/v1/template-publication-candidates');"
          }
        ]
      }
    },
    "/v1/template-publications": {
      "post": {
        "operationId": "POST_v1_template_publications",
        "summary": "Bind a template version to a sender credential revision",
        "tags": [
          "sender management"
        ],
        "description": "Bind a template version to a sender credential revision. Requires admin scope; tenant resources also require a tenant-scoped key or X-Anam-Tenant. Writes are durable before provider I/O. Provider approval is distinct from operation completion and message delivery. Credentials and raw provider responses are never returned. See docs/sender-connections.md for onboarding, exact credential formats, revision fencing, safe reconciliation and compatibility.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "connection_id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "template_version_id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "publication": {
                    "type": "object",
                    "properties": {
                      "language": {
                        "type": "string",
                        "minLength": 2,
                        "maxLength": 35
                      },
                      "body": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 8000
                      },
                      "variables": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {
                          "type": "string"
                        }
                      },
                      "examples": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {
                          "type": "string"
                        }
                      },
                      "buttons": {
                        "default": [],
                        "maxItems": 2,
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "url"
                              ]
                            },
                            "label": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 25
                            },
                            "url": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 2048
                            },
                            "variable": {
                              "type": "string",
                              "pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$"
                            },
                            "example": {
                              "type": "string",
                              "maxLength": 2048
                            }
                          },
                          "required": [
                            "type",
                            "label",
                            "url"
                          ],
                          "additionalProperties": false
                        }
                      }
                    },
                    "required": [
                      "language",
                      "body",
                      "variables",
                      "examples"
                    ],
                    "additionalProperties": false
                  }
                },
                "required": [
                  "connection_id",
                  "template_version_id"
                ],
                "additionalProperties": false
              },
              "examples": {
                "example": {
                  "value": {
                    "connection_id": "11111111-1111-4111-8111-111111111111",
                    "template_version_id": "11111111-1111-4111-8111-111111111111"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "201": {
            "description": "Durable result; external work may still be pending.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "example": {
                    "value": {
                      "id": "11111111-1111-4111-8111-111111111111",
                      "connection_id": "11111111-1111-4111-8111-111111111111",
                      "credential_revision": 1,
                      "template_version_id": "11111111-1111-4111-8111-111111111111",
                      "state": "draft",
                      "revision": 1,
                      "category": "UTILITY"
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/template-publications \\\n  --request POST \\\n  --header 'content-type: application/json' \\\n  --data '{\n  \"connection_id\": \"11111111-1111-4111-8111-111111111111\",\n  \"template_version_id\": \"11111111-1111-4111-8111-111111111111\"\n}'"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/template-publications', {\n  method: 'POST',\n  headers: {\n    'content-type': 'application/json'\n  },\n  body: JSON.stringify({\n    connection_id: '11111111-1111-4111-8111-111111111111',\n    template_version_id: '11111111-1111-4111-8111-111111111111'\n  })\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\nimport json\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\npayload = json.dumps({\n  \"connection_id\": \"11111111-1111-4111-8111-111111111111\",\n  \"template_version_id\": \"11111111-1111-4111-8111-111111111111\"\n})\nheaders = {\n  \"content-type\": \"application/json\"\n}\n\nconn.request(\n    \"POST\",\n    \"/v1/template-publications\",\n    body=payload,\n    headers=headers,\n)\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/template-publications', [\n  'headers' => [\n    'content-type' => 'application/json'\n  ],\n  'json' => [\n    'connection_id' => '11111111-1111-4111-8111-111111111111',\n    'template_version_id' => '11111111-1111-4111-8111-111111111111'\n  ]\n]);"
          }
        ]
      }
    },
    "/v1/template-publications/{id}": {
      "get": {
        "operationId": "GET_v1_template_publications_id",
        "summary": "Read provider approval for an exact template version",
        "tags": [
          "sender management"
        ],
        "description": "Read provider approval for an exact template version. Requires admin scope; tenant resources also require a tenant-scoped key or X-Anam-Tenant. Writes are durable before provider I/O. Provider approval is distinct from operation completion and message delivery. Credentials and raw provider responses are never returned. See docs/sender-connections.md for onboarding, exact credential formats, revision fencing, safe reconciliation and compatibility.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Durable result; external work may still be pending.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "example": {
                    "value": {
                      "id": "11111111-1111-4111-8111-111111111111",
                      "connection_id": "11111111-1111-4111-8111-111111111111",
                      "credential_revision": 1,
                      "template_version_id": "11111111-1111-4111-8111-111111111111",
                      "state": "approved",
                      "revision": 4,
                      "category": "UTILITY"
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/template-publications/example"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/template-publications/example')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/v1/template-publications/example\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/v1/template-publications/example');"
          }
        ]
      }
    },
    "/v1/tenant-templates": {
      "post": {
        "operationId": "POST_v1_tenant_templates",
        "summary": "Save a tenant template definition",
        "tags": [
          "sender management"
        ],
        "description": "Save a tenant template definition. Requires admin scope; tenant resources also require a tenant-scoped key or X-Anam-Tenant. Writes are durable before provider I/O. Provider approval is distinct from operation completion and message delivery. Credentials and raw provider responses are never returned. See docs/sender-connections.md for onboarding, exact credential formats, revision fencing, safe reconciliation and compatibility.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "key": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  },
                  "category": {
                    "type": "string",
                    "enum": [
                      "utility",
                      "authentication",
                      "marketing"
                    ]
                  },
                  "content_class": {
                    "default": "minimal",
                    "type": "string",
                    "enum": [
                      "minimal",
                      "standard"
                    ]
                  },
                  "description": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 500
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "default_channel_chain": {
                    "anyOf": [
                      {
                        "minItems": 1,
                        "maxItems": 6,
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "push",
                            "whatsapp",
                            "sms",
                            "email"
                          ]
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "allowed_variables": {
                    "default": [],
                    "maxItems": 30,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string",
                          "pattern": "^[a-z][a-z0-9_]{0,40}$"
                        },
                        "source": {
                          "default": "payload",
                          "type": "string",
                          "enum": [
                            "payload",
                            "profile"
                          ]
                        },
                        "type": {
                          "default": "string",
                          "type": "string",
                          "enum": [
                            "string",
                            "number",
                            "datetime",
                            "url"
                          ]
                        },
                        "sensitive": {
                          "default": false,
                          "type": "boolean"
                        },
                        "required": {
                          "default": true,
                          "type": "boolean"
                        },
                        "profile_field": {
                          "anyOf": [
                            {
                              "type": "string",
                              "maxLength": 41
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "profile_field_fallback": {
                          "anyOf": [
                            {
                              "type": "string",
                              "maxLength": 41
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "subject": {
                          "anyOf": [
                            {
                              "type": "string",
                              "maxLength": 60
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "fallback": {
                          "anyOf": [
                            {
                              "type": "string",
                              "maxLength": 200
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "fallback_by_locale": {
                          "anyOf": [
                            {
                              "type": "object",
                              "propertyNames": {
                                "type": "string",
                                "minLength": 2,
                                "maxLength": 35
                              },
                              "additionalProperties": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 200
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "fallback_when": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "always",
                                "profile_incomplete"
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "name"
                      ]
                    }
                  }
                },
                "required": [
                  "key",
                  "category"
                ],
                "additionalProperties": false
              },
              "examples": {
                "example": {
                  "value": {
                    "key": "file.ready",
                    "category": "utility",
                    "allowed_variables": [],
                    "default_channel_chain": [
                      "email"
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "201": {
            "description": "Durable result; external work may still be pending.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "example": {
                    "value": {
                      "id": "11111111-1111-4111-8111-111111111111",
                      "key": "file.ready",
                      "category": "utility",
                      "content_class": "minimal",
                      "allowed_variables": [],
                      "default_channel_chain": [
                        "email"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/tenant-templates \\\n  --request POST \\\n  --header 'content-type: application/json' \\\n  --data '{\n  \"key\": \"file.ready\",\n  \"category\": \"utility\",\n  \"allowed_variables\": [],\n  \"default_channel_chain\": [\n    \"email\"\n  ]\n}'"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/tenant-templates', {\n  method: 'POST',\n  headers: {\n    'content-type': 'application/json'\n  },\n  body: JSON.stringify({\n    key: 'file.ready',\n    category: 'utility',\n    allowed_variables: [],\n    default_channel_chain: ['email']\n  })\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\nimport json\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\npayload = json.dumps({\n  \"key\": \"file.ready\",\n  \"category\": \"utility\",\n  \"allowed_variables\": [],\n  \"default_channel_chain\": [\n    \"email\"\n  ]\n})\nheaders = {\n  \"content-type\": \"application/json\"\n}\n\nconn.request(\n    \"POST\",\n    \"/v1/tenant-templates\",\n    body=payload,\n    headers=headers,\n)\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/tenant-templates', [\n  'headers' => [\n    'content-type' => 'application/json'\n  ],\n  'json' => [\n    'key' => 'file.ready',\n    'category' => 'utility',\n    'allowed_variables' => [],\n    'default_channel_chain' => [\n      'email'\n    ]\n  ]\n]);"
          }
        ]
      },
      "get": {
        "operationId": "GET_v1_tenant_templates",
        "summary": "List the tenant-owned template catalogue",
        "tags": [
          "sender management"
        ],
        "description": "List the tenant-owned template catalogue. Requires admin scope; tenant resources also require a tenant-scoped key or X-Anam-Tenant. Writes are durable before provider I/O. Provider approval is distinct from operation completion and message delivery. Credentials and raw provider responses are never returned. See docs/sender-connections.md for onboarding, exact credential formats, revision fencing, safe reconciliation and compatibility.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 120
            },
            "in": "query",
            "name": "after_key",
            "required": false
          }
        ],
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Durable result; external work may still be pending.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "example": {
                    "value": {
                      "templates": []
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/tenant-templates"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/tenant-templates')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/v1/tenant-templates\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/v1/tenant-templates');"
          }
        ]
      }
    },
    "/v1/tenant-templates/{key}": {
      "get": {
        "operationId": "GET_v1_tenant_templates_key",
        "summary": "Read tenant template drafts and versions",
        "tags": [
          "sender management"
        ],
        "description": "Read tenant template drafts and versions. Requires admin scope; tenant resources also require a tenant-scoped key or X-Anam-Tenant. Writes are durable before provider I/O. Provider approval is distinct from operation completion and message delivery. Credentials and raw provider responses are never returned. See docs/sender-connections.md for onboarding, exact credential formats, revision fencing, safe reconciliation and compatibility.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 120
            },
            "in": "path",
            "name": "key",
            "required": true
          }
        ],
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Durable result; external work may still be pending.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "example": {
                    "value": {
                      "id": "11111111-1111-4111-8111-111111111111",
                      "key": "file.ready",
                      "versions": []
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/tenant-templates/example"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/tenant-templates/example')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/v1/tenant-templates/example\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/v1/tenant-templates/example');"
          }
        ]
      }
    },
    "/v1/tenant-templates/{key}/versions": {
      "post": {
        "operationId": "POST_v1_tenant_templates_key_versions",
        "summary": "Create an immutable tenant template draft",
        "tags": [
          "sender management"
        ],
        "description": "Create an immutable tenant template draft. Requires admin scope; tenant resources also require a tenant-scoped key or X-Anam-Tenant. Writes are durable before provider I/O. Provider approval is distinct from operation completion and message delivery. Credentials and raw provider responses are never returned. See docs/sender-connections.md for onboarding, exact credential formats, revision fencing, safe reconciliation and compatibility.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "channel": {
                    "type": "string",
                    "enum": [
                      "push",
                      "whatsapp",
                      "sms",
                      "email"
                    ]
                  },
                  "locale": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 35
                  },
                  "subject_icu": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 400
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "body_icu": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100000
                  }
                },
                "required": [
                  "channel",
                  "locale",
                  "body_icu"
                ],
                "additionalProperties": false
              },
              "examples": {
                "example": {
                  "value": {
                    "channel": "email",
                    "locale": "en",
                    "subject_icu": "Ready",
                    "body_icu": "Your file is ready."
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 120
            },
            "in": "path",
            "name": "key",
            "required": true
          }
        ],
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "201": {
            "description": "Durable result; external work may still be pending.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "example": {
                    "value": {
                      "version": {
                        "id": "11111111-1111-4111-8111-111111111111",
                        "channel": "email",
                        "locale": "en",
                        "status": "draft",
                        "version": 1
                      },
                      "warnings": []
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/tenant-templates/example/versions \\\n  --request POST \\\n  --header 'content-type: application/json' \\\n  --data '{\n  \"channel\": \"email\",\n  \"locale\": \"en\",\n  \"subject_icu\": \"Ready\",\n  \"body_icu\": \"Your file is ready.\"\n}'"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/tenant-templates/example/versions', {\n  method: 'POST',\n  headers: {\n    'content-type': 'application/json'\n  },\n  body: JSON.stringify({\n    channel: 'email',\n    locale: 'en',\n    subject_icu: 'Ready',\n    body_icu: 'Your file is ready.'\n  })\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\nimport json\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\npayload = json.dumps({\n  \"channel\": \"email\",\n  \"locale\": \"en\",\n  \"subject_icu\": \"Ready\",\n  \"body_icu\": \"Your file is ready.\"\n})\nheaders = {\n  \"content-type\": \"application/json\"\n}\n\nconn.request(\n    \"POST\",\n    \"/v1/tenant-templates/example/versions\",\n    body=payload,\n    headers=headers,\n)\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/tenant-templates/example/versions', [\n  'headers' => [\n    'content-type' => 'application/json'\n  ],\n  'json' => [\n    'channel' => 'email',\n    'locale' => 'en',\n    'subject_icu' => 'Ready',\n    'body_icu' => 'Your file is ready.'\n  ]\n]);"
          }
        ]
      }
    },
    "/v1/tenant-template-versions/{id}/preview": {
      "post": {
        "operationId": "POST_v1_tenant_template_versions_id_preview",
        "summary": "Preview a tenant draft without activating or submitting it",
        "tags": [
          "sender management"
        ],
        "description": "Preview a tenant draft without activating or submitting it. Requires admin scope; tenant resources also require a tenant-scoped key or X-Anam-Tenant. Writes are durable before provider I/O. Provider approval is distinct from operation completion and message delivery. Credentials and raw provider responses are never returned. See docs/sender-connections.md for onboarding, exact credential formats, revision fencing, safe reconciliation and compatibility.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "channel": {
                    "type": "string",
                    "enum": [
                      "push",
                      "whatsapp",
                      "sms",
                      "email"
                    ]
                  },
                  "locale": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 35
                  },
                  "timezone": {
                    "default": "America/Sao_Paulo",
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 64
                  },
                  "variables": {
                    "default": {},
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  },
                  "identity_values": {
                    "default": {},
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "channel",
                  "locale"
                ],
                "additionalProperties": false
              },
              "examples": {
                "example": {
                  "value": {
                    "channel": "email",
                    "locale": "en",
                    "variables": {}
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Durable result; external work may still be pending.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "example": {
                    "value": {
                      "body": "Your file is ready.",
                      "warnings": [],
                      "templateVersionId": "11111111-1111-4111-8111-111111111111"
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/tenant-template-versions/example/preview \\\n  --request POST \\\n  --header 'content-type: application/json' \\\n  --data '{\n  \"channel\": \"email\",\n  \"locale\": \"en\",\n  \"variables\": {}\n}'"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/tenant-template-versions/example/preview', {\n  method: 'POST',\n  headers: {\n    'content-type': 'application/json'\n  },\n  body: JSON.stringify({\n    channel: 'email',\n    locale: 'en',\n    variables: {}\n  })\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\nimport json\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\npayload = json.dumps({\n  \"channel\": \"email\",\n  \"locale\": \"en\",\n  \"variables\": {}\n})\nheaders = {\n  \"content-type\": \"application/json\"\n}\n\nconn.request(\n    \"POST\",\n    \"/v1/tenant-template-versions/example/preview\",\n    body=payload,\n    headers=headers,\n)\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/tenant-template-versions/example/preview', [\n  'headers' => [\n    'content-type' => 'application/json'\n  ],\n  'json' => [\n    'channel' => 'email',\n    'locale' => 'en',\n    'variables' => []\n  ]\n]);"
          }
        ]
      }
    },
    "/v1/tenant-template-versions/{id}/retire": {
      "post": {
        "operationId": "POST_v1_tenant_template_versions_id_retire",
        "summary": "Retire a tenant version for future selections",
        "tags": [
          "sender management"
        ],
        "description": "Retire a tenant version for future selections. Requires admin scope; tenant resources also require a tenant-scoped key or X-Anam-Tenant. Writes are durable before provider I/O. Provider approval is distinct from operation completion and message delivery. Credentials and raw provider responses are never returned. See docs/sender-connections.md for onboarding, exact credential formats, revision fencing, safe reconciliation and compatibility.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Durable result; external work may still be pending.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "example": {
                    "value": {
                      "retired": true,
                      "version_id": "11111111-1111-4111-8111-111111111111"
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/tenant-template-versions/example/retire \\\n  --request POST"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/tenant-template-versions/example/retire', {\n  method: 'POST'\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"POST\", \"/v1/tenant-template-versions/example/retire\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/tenant-template-versions/example/retire');"
          }
        ]
      }
    },
    "/v1/tenant-template-versions/{id}/activate": {
      "post": {
        "operationId": "POST_v1_tenant_template_versions_id_activate",
        "summary": "Activate an approved tenant template version",
        "tags": [
          "sender management"
        ],
        "description": "Activate an approved tenant template version. Requires admin scope; tenant resources also require a tenant-scoped key or X-Anam-Tenant. Writes are durable before provider I/O. Provider approval is distinct from operation completion and message delivery. Credentials and raw provider responses are never returned. See docs/sender-connections.md for onboarding, exact credential formats, revision fencing, safe reconciliation and compatibility.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Durable result; external work may still be pending.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "example": {
                    "value": {
                      "activated": true,
                      "version_id": "11111111-1111-4111-8111-111111111111"
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/tenant-template-versions/example/activate \\\n  --request POST"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/tenant-template-versions/example/activate', {\n  method: 'POST'\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"POST\", \"/v1/tenant-template-versions/example/activate\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/tenant-template-versions/example/activate');"
          }
        ]
      }
    },
    "/v1/tenant-templates/{key}/preview": {
      "post": {
        "operationId": "POST_v1_tenant_templates_key_preview",
        "summary": "Preview an active effective template",
        "tags": [
          "sender management"
        ],
        "description": "Preview an active effective template. Requires admin scope; tenant resources also require a tenant-scoped key or X-Anam-Tenant. Writes are durable before provider I/O. Provider approval is distinct from operation completion and message delivery. Credentials and raw provider responses are never returned. See docs/sender-connections.md for onboarding, exact credential formats, revision fencing, safe reconciliation and compatibility.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "channel": {
                    "type": "string",
                    "enum": [
                      "push",
                      "whatsapp",
                      "sms",
                      "email"
                    ]
                  },
                  "locale": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 35
                  },
                  "timezone": {
                    "default": "America/Sao_Paulo",
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 64
                  },
                  "variables": {
                    "default": {},
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  },
                  "identity_values": {
                    "default": {},
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "channel",
                  "locale"
                ],
                "additionalProperties": false
              },
              "examples": {
                "example": {
                  "value": {
                    "channel": "email",
                    "locale": "en",
                    "variables": {}
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 120
            },
            "in": "path",
            "name": "key",
            "required": true
          }
        ],
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Durable result; external work may still be pending.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "example": {
                    "value": {
                      "body": "Your file is ready.",
                      "warnings": [],
                      "templateVersionId": "11111111-1111-4111-8111-111111111111"
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/tenant-templates/example/preview \\\n  --request POST \\\n  --header 'content-type: application/json' \\\n  --data '{\n  \"channel\": \"email\",\n  \"locale\": \"en\",\n  \"variables\": {}\n}'"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/tenant-templates/example/preview', {\n  method: 'POST',\n  headers: {\n    'content-type': 'application/json'\n  },\n  body: JSON.stringify({\n    channel: 'email',\n    locale: 'en',\n    variables: {}\n  })\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\nimport json\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\npayload = json.dumps({\n  \"channel\": \"email\",\n  \"locale\": \"en\",\n  \"variables\": {}\n})\nheaders = {\n  \"content-type\": \"application/json\"\n}\n\nconn.request(\n    \"POST\",\n    \"/v1/tenant-templates/example/preview\",\n    body=payload,\n    headers=headers,\n)\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/tenant-templates/example/preview', [\n  'headers' => [\n    'content-type' => 'application/json'\n  ],\n  'json' => [\n    'channel' => 'email',\n    'locale' => 'en',\n    'variables' => []\n  ]\n]);"
          }
        ]
      }
    },
    "/v1/provider-management/zavu_whatsapp/credentials": {
      "put": {
        "operationId": "PUT_v1_provider_management_zavu_whatsapp_credentials",
        "summary": "Configure organization-only Zavu provisioning authority",
        "tags": [
          "sender management"
        ],
        "description": "Configure organization-only Zavu provisioning authority. Requires admin scope; tenant resources also require a tenant-scoped key or X-Anam-Tenant. Writes are durable before provider I/O. Provider approval is distinct from operation completion and message delivery. Credentials and raw provider responses are never returned. See docs/sender-connections.md for onboarding, exact credential formats, revision fencing, safe reconciliation and compatibility.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "api_key": {
                    "type": "string",
                    "pattern": "^zv_live_[a-zA-Z0-9_-]+$"
                  }
                },
                "required": [
                  "api_key"
                ],
                "additionalProperties": false
              },
              "examples": {
                "example": {
                  "value": {
                    "api_key": "zv_live_SYNTHETIC_NOT_A_REAL_KEY"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Durable result; external work may still be pending.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "example": {
                    "value": {
                      "configured": true
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/provider-management/zavu_whatsapp/credentials \\\n  --request PUT \\\n  --header 'content-type: application/json' \\\n  --data '{\n  \"api_key\": \"zv_live_SYNTHETIC_NOT_A_REAL_KEY\"\n}'"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/provider-management/zavu_whatsapp/credentials', {\n  method: 'PUT',\n  headers: {\n    'content-type': 'application/json'\n  },\n  body: JSON.stringify({\n    api_key: 'zv_live_SYNTHETIC_NOT_A_REAL_KEY'\n  })\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\nimport json\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\npayload = json.dumps({\n  \"api_key\": \"zv_live_SYNTHETIC_NOT_A_REAL_KEY\"\n})\nheaders = {\n  \"content-type\": \"application/json\"\n}\n\nconn.request(\n    \"PUT\",\n    \"/v1/provider-management/zavu_whatsapp/credentials\",\n    body=payload,\n    headers=headers,\n)\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('PUT', 'http://localhost:47311/v1/provider-management/zavu_whatsapp/credentials', [\n  'headers' => [\n    'content-type' => 'application/json'\n  ],\n  'json' => [\n    'api_key' => 'zv_live_SYNTHETIC_NOT_A_REAL_KEY'\n  ]\n]);"
          }
        ]
      }
    },
    "/v1/preference-catalogs/{key}": {
      "get": {
        "operationId": "readCatalog",
        "summary": "Read a preference catalog",
        "tags": [
          "configuração"
        ],
        "description": "Requires read scope in the authenticated organization. Returns localized labels, supported channels and the installed catalog revision.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
            },
            "in": "path",
            "name": "key",
            "required": true
          }
        ],
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Default Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "revision": {
                      "type": "integer",
                      "exclusiveMinimum": 0,
                      "maximum": 9007199254740991
                    },
                    "catalog": {
                      "type": "object",
                      "properties": {
                        "schema_version": {
                          "type": "number",
                          "enum": [
                            1
                          ]
                        },
                        "key": {
                          "type": "string",
                          "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                        },
                        "revision": {
                          "type": "string",
                          "pattern": "^[a-f0-9]{64}$"
                        },
                        "managed_prefix": {
                          "type": "string",
                          "pattern": "^[a-z][a-z0-9._-]{1,79}\\.$"
                        },
                        "owner_party": {
                          "type": "string",
                          "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                        },
                        "required_channels": {
                          "maxItems": 4,
                          "type": "array",
                          "items": {
                            "type": "string",
                            "enum": [
                              "email",
                              "whatsapp",
                              "sms",
                              "inbox"
                            ]
                          }
                        },
                        "audiences": {
                          "minItems": 1,
                          "maxItems": 8,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "key": {
                                "type": "string",
                                "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                              },
                              "labels": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string",
                                  "minLength": 2,
                                  "maxLength": 16
                                },
                                "additionalProperties": {
                                  "type": "object",
                                  "properties": {
                                    "title": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 160
                                    },
                                    "description": {
                                      "type": "string",
                                      "maxLength": 600
                                    },
                                    "example": {
                                      "type": "string",
                                      "maxLength": 400
                                    }
                                  },
                                  "required": [
                                    "title",
                                    "description"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "key",
                              "labels"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "groups": {
                          "minItems": 1,
                          "maxItems": 30,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "key": {
                                "type": "string",
                                "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                              },
                              "labels": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string",
                                  "minLength": 2,
                                  "maxLength": 16
                                },
                                "additionalProperties": {
                                  "type": "object",
                                  "properties": {
                                    "title": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 160
                                    },
                                    "description": {
                                      "type": "string",
                                      "maxLength": 600
                                    },
                                    "example": {
                                      "type": "string",
                                      "maxLength": 400
                                    }
                                  },
                                  "required": [
                                    "title",
                                    "description"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "key",
                              "labels"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "events": {
                          "minItems": 1,
                          "maxItems": 160,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "key": {
                                "type": "string",
                                "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                              },
                              "audience": {
                                "type": "string",
                                "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                              },
                              "group": {
                                "type": "string",
                                "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                              },
                              "template_prefix": {
                                "type": "string",
                                "minLength": 3,
                                "maxLength": 120
                              },
                              "recipient_match": {
                                "type": "string",
                                "enum": [
                                  "owner",
                                  "other",
                                  "any"
                                ]
                              },
                              "channels": {
                                "minItems": 1,
                                "maxItems": 4,
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "enum": [
                                    "email",
                                    "whatsapp",
                                    "sms",
                                    "inbox"
                                  ]
                                }
                              },
                              "required": {
                                "default": false,
                                "type": "boolean"
                              },
                              "labels": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string",
                                  "minLength": 2,
                                  "maxLength": 16
                                },
                                "additionalProperties": {
                                  "type": "object",
                                  "properties": {
                                    "title": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 160
                                    },
                                    "description": {
                                      "type": "string",
                                      "maxLength": 600
                                    },
                                    "example": {
                                      "type": "string",
                                      "maxLength": 400
                                    }
                                  },
                                  "required": [
                                    "title",
                                    "description"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "key",
                              "audience",
                              "group",
                              "template_prefix",
                              "recipient_match",
                              "channels",
                              "required",
                              "labels"
                            ],
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": [
                        "schema_version",
                        "key",
                        "revision",
                        "managed_prefix",
                        "owner_party",
                        "audiences",
                        "groups",
                        "events"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "revision",
                    "catalog"
                  ],
                  "additionalProperties": false
                },
                "examples": {
                  "example": {
                    "value": {
                      "revision": 1,
                      "catalog": {
                        "schema_version": 1,
                        "key": "demo.preferences",
                        "revision": "0000000000000000000000000000000000000000000000000000000000000000",
                        "managed_prefix": "demo.",
                        "owner_party": "owner",
                        "audiences": [
                          {
                            "key": "self",
                            "labels": {
                              "en": {
                                "title": "Example notice",
                                "description": "An operational update."
                              }
                            }
                          }
                        ],
                        "groups": [
                          {
                            "key": "updates",
                            "labels": {
                              "en": {
                                "title": "Example notice",
                                "description": "An operational update."
                              }
                            }
                          }
                        ],
                        "events": [
                          {
                            "key": "update.self",
                            "audience": "self",
                            "group": "updates",
                            "template_prefix": "demo.update.",
                            "recipient_match": "owner",
                            "channels": [
                              "email",
                              "inbox"
                            ],
                            "required": false,
                            "labels": {
                              "en": {
                                "title": "Example notice",
                                "description": "An operational update."
                              }
                            }
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/preference-catalogs/example"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/preference-catalogs/example')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/v1/preference-catalogs/example\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/v1/preference-catalogs/example');"
          }
        ]
      },
      "put": {
        "operationId": "installCatalog",
        "summary": "Install a reviewed preference catalog",
        "tags": [
          "configuração"
        ],
        "description": "Requires organization admin scope. Installs generic audience/event/channel definitions with revision fencing. Identical content is idempotent; stale replacements return 409. Does not publish templates or enable providers.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "expected_revision": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "catalog": {
                    "type": "object",
                    "properties": {
                      "schema_version": {
                        "type": "number",
                        "enum": [
                          1
                        ]
                      },
                      "key": {
                        "type": "string",
                        "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                      },
                      "revision": {
                        "type": "string",
                        "pattern": "^[a-f0-9]{64}$"
                      },
                      "managed_prefix": {
                        "type": "string",
                        "pattern": "^[a-z][a-z0-9._-]{1,79}\\.$"
                      },
                      "owner_party": {
                        "type": "string",
                        "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                      },
                      "required_channels": {
                        "maxItems": 4,
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "email",
                            "whatsapp",
                            "sms",
                            "inbox"
                          ]
                        }
                      },
                      "audiences": {
                        "minItems": 1,
                        "maxItems": 8,
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "key": {
                              "type": "string",
                              "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                            },
                            "labels": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string",
                                "minLength": 2,
                                "maxLength": 16
                              },
                              "additionalProperties": {
                                "type": "object",
                                "properties": {
                                  "title": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 160
                                  },
                                  "description": {
                                    "type": "string",
                                    "maxLength": 600
                                  },
                                  "example": {
                                    "type": "string",
                                    "maxLength": 400
                                  }
                                },
                                "required": [
                                  "title",
                                  "description"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "key",
                            "labels"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "groups": {
                        "minItems": 1,
                        "maxItems": 30,
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "key": {
                              "type": "string",
                              "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                            },
                            "labels": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string",
                                "minLength": 2,
                                "maxLength": 16
                              },
                              "additionalProperties": {
                                "type": "object",
                                "properties": {
                                  "title": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 160
                                  },
                                  "description": {
                                    "type": "string",
                                    "maxLength": 600
                                  },
                                  "example": {
                                    "type": "string",
                                    "maxLength": 400
                                  }
                                },
                                "required": [
                                  "title",
                                  "description"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "key",
                            "labels"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "events": {
                        "minItems": 1,
                        "maxItems": 160,
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "key": {
                              "type": "string",
                              "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                            },
                            "audience": {
                              "type": "string",
                              "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                            },
                            "group": {
                              "type": "string",
                              "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                            },
                            "template_prefix": {
                              "type": "string",
                              "minLength": 3,
                              "maxLength": 120
                            },
                            "recipient_match": {
                              "type": "string",
                              "enum": [
                                "owner",
                                "other",
                                "any"
                              ]
                            },
                            "channels": {
                              "minItems": 1,
                              "maxItems": 4,
                              "type": "array",
                              "items": {
                                "type": "string",
                                "enum": [
                                  "email",
                                  "whatsapp",
                                  "sms",
                                  "inbox"
                                ]
                              }
                            },
                            "required": {
                              "default": false,
                              "type": "boolean"
                            },
                            "labels": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string",
                                "minLength": 2,
                                "maxLength": 16
                              },
                              "additionalProperties": {
                                "type": "object",
                                "properties": {
                                  "title": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 160
                                  },
                                  "description": {
                                    "type": "string",
                                    "maxLength": 600
                                  },
                                  "example": {
                                    "type": "string",
                                    "maxLength": 400
                                  }
                                },
                                "required": [
                                  "title",
                                  "description"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "key",
                            "audience",
                            "group",
                            "template_prefix",
                            "recipient_match",
                            "channels",
                            "labels"
                          ],
                          "additionalProperties": false
                        }
                      }
                    },
                    "required": [
                      "schema_version",
                      "key",
                      "revision",
                      "managed_prefix",
                      "owner_party",
                      "audiences",
                      "groups",
                      "events"
                    ],
                    "additionalProperties": false
                  }
                },
                "required": [
                  "expected_revision",
                  "catalog"
                ],
                "additionalProperties": false
              },
              "examples": {
                "example": {
                  "value": {
                    "expected_revision": 0,
                    "catalog": {
                      "schema_version": 1,
                      "key": "demo.preferences",
                      "revision": "0000000000000000000000000000000000000000000000000000000000000000",
                      "managed_prefix": "demo.",
                      "owner_party": "owner",
                      "audiences": [
                        {
                          "key": "self",
                          "labels": {
                            "en": {
                              "title": "Example notice",
                              "description": "An operational update."
                            }
                          }
                        }
                      ],
                      "groups": [
                        {
                          "key": "updates",
                          "labels": {
                            "en": {
                              "title": "Example notice",
                              "description": "An operational update."
                            }
                          }
                        }
                      ],
                      "events": [
                        {
                          "key": "update.self",
                          "audience": "self",
                          "group": "updates",
                          "template_prefix": "demo.update.",
                          "recipient_match": "owner",
                          "channels": [
                            "email",
                            "inbox"
                          ],
                          "required": false,
                          "labels": {
                            "en": {
                              "title": "Example notice",
                              "description": "An operational update."
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
            },
            "in": "path",
            "name": "key",
            "required": true
          }
        ],
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Default Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "revision": {
                      "type": "integer",
                      "exclusiveMinimum": 0,
                      "maximum": 9007199254740991
                    },
                    "catalog": {
                      "type": "object",
                      "properties": {
                        "schema_version": {
                          "type": "number",
                          "enum": [
                            1
                          ]
                        },
                        "key": {
                          "type": "string",
                          "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                        },
                        "revision": {
                          "type": "string",
                          "pattern": "^[a-f0-9]{64}$"
                        },
                        "managed_prefix": {
                          "type": "string",
                          "pattern": "^[a-z][a-z0-9._-]{1,79}\\.$"
                        },
                        "owner_party": {
                          "type": "string",
                          "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                        },
                        "required_channels": {
                          "maxItems": 4,
                          "type": "array",
                          "items": {
                            "type": "string",
                            "enum": [
                              "email",
                              "whatsapp",
                              "sms",
                              "inbox"
                            ]
                          }
                        },
                        "audiences": {
                          "minItems": 1,
                          "maxItems": 8,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "key": {
                                "type": "string",
                                "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                              },
                              "labels": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string",
                                  "minLength": 2,
                                  "maxLength": 16
                                },
                                "additionalProperties": {
                                  "type": "object",
                                  "properties": {
                                    "title": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 160
                                    },
                                    "description": {
                                      "type": "string",
                                      "maxLength": 600
                                    },
                                    "example": {
                                      "type": "string",
                                      "maxLength": 400
                                    }
                                  },
                                  "required": [
                                    "title",
                                    "description"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "key",
                              "labels"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "groups": {
                          "minItems": 1,
                          "maxItems": 30,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "key": {
                                "type": "string",
                                "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                              },
                              "labels": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string",
                                  "minLength": 2,
                                  "maxLength": 16
                                },
                                "additionalProperties": {
                                  "type": "object",
                                  "properties": {
                                    "title": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 160
                                    },
                                    "description": {
                                      "type": "string",
                                      "maxLength": 600
                                    },
                                    "example": {
                                      "type": "string",
                                      "maxLength": 400
                                    }
                                  },
                                  "required": [
                                    "title",
                                    "description"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "key",
                              "labels"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "events": {
                          "minItems": 1,
                          "maxItems": 160,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "key": {
                                "type": "string",
                                "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                              },
                              "audience": {
                                "type": "string",
                                "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                              },
                              "group": {
                                "type": "string",
                                "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                              },
                              "template_prefix": {
                                "type": "string",
                                "minLength": 3,
                                "maxLength": 120
                              },
                              "recipient_match": {
                                "type": "string",
                                "enum": [
                                  "owner",
                                  "other",
                                  "any"
                                ]
                              },
                              "channels": {
                                "minItems": 1,
                                "maxItems": 4,
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "enum": [
                                    "email",
                                    "whatsapp",
                                    "sms",
                                    "inbox"
                                  ]
                                }
                              },
                              "required": {
                                "default": false,
                                "type": "boolean"
                              },
                              "labels": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string",
                                  "minLength": 2,
                                  "maxLength": 16
                                },
                                "additionalProperties": {
                                  "type": "object",
                                  "properties": {
                                    "title": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 160
                                    },
                                    "description": {
                                      "type": "string",
                                      "maxLength": 600
                                    },
                                    "example": {
                                      "type": "string",
                                      "maxLength": 400
                                    }
                                  },
                                  "required": [
                                    "title",
                                    "description"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "key",
                              "audience",
                              "group",
                              "template_prefix",
                              "recipient_match",
                              "channels",
                              "required",
                              "labels"
                            ],
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": [
                        "schema_version",
                        "key",
                        "revision",
                        "managed_prefix",
                        "owner_party",
                        "audiences",
                        "groups",
                        "events"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "revision",
                    "catalog"
                  ],
                  "additionalProperties": false
                },
                "examples": {
                  "example": {
                    "value": {
                      "revision": 1,
                      "catalog": {
                        "schema_version": 1,
                        "key": "demo.preferences",
                        "revision": "0000000000000000000000000000000000000000000000000000000000000000",
                        "managed_prefix": "demo.",
                        "owner_party": "owner",
                        "audiences": [
                          {
                            "key": "self",
                            "labels": {
                              "en": {
                                "title": "Example notice",
                                "description": "An operational update."
                              }
                            }
                          }
                        ],
                        "groups": [
                          {
                            "key": "updates",
                            "labels": {
                              "en": {
                                "title": "Example notice",
                                "description": "An operational update."
                              }
                            }
                          }
                        ],
                        "events": [
                          {
                            "key": "update.self",
                            "audience": "self",
                            "group": "updates",
                            "template_prefix": "demo.update.",
                            "recipient_match": "owner",
                            "channels": [
                              "email",
                              "inbox"
                            ],
                            "required": false,
                            "labels": {
                              "en": {
                                "title": "Example notice",
                                "description": "An operational update."
                              }
                            }
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/preference-catalogs/example \\\n  --request PUT \\\n  --header 'content-type: application/json' \\\n  --data '{\n  \"expected_revision\": 0,\n  \"catalog\": {\n    \"schema_version\": 1,\n    \"key\": \"demo.preferences\",\n    \"revision\": \"0000000000000000000000000000000000000000000000000000000000000000\",\n    \"managed_prefix\": \"demo.\",\n    \"owner_party\": \"owner\",\n    \"audiences\": [\n      {\n        \"key\": \"self\",\n        \"labels\": {\n          \"en\": {\n            \"title\": \"Example notice\",\n            \"description\": \"An operational update.\"\n          }\n        }\n      }\n    ],\n    \"groups\": [\n      {\n        \"key\": \"updates\",\n        \"labels\": {\n          \"en\": {\n            \"title\": \"Example notice\",\n            \"description\": \"An operational update.\"\n          }\n        }\n      }\n    ],\n    \"events\": [\n      {\n        \"key\": \"update.self\",\n        \"audience\": \"self\",\n        \"group\": \"updates\",\n        \"template_prefix\": \"demo.update.\",\n        \"recipient_match\": \"owner\",\n        \"channels\": [\n          \"email\",\n          \"inbox\"\n        ],\n        \"required\": false,\n        \"labels\": {\n          \"en\": {\n            \"title\": \"Example notice\",\n            \"description\": \"An operational update.\"\n          }\n        }\n      }\n    ]\n  }\n}'"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/preference-catalogs/example', {\n  method: 'PUT',\n  headers: {\n    'content-type': 'application/json'\n  },\n  body: JSON.stringify({\n    expected_revision: 0,\n    catalog: {\n      schema_version: 1,\n      key: 'demo.preferences',\n      revision: '0000000000000000000000000000000000000000000000000000000000000000',\n      managed_prefix: 'demo.',\n      owner_party: 'owner',\n      audiences: [\n        {\n          key: 'self',\n          labels: {\n            en: {\n              title: 'Example notice',\n              description: 'An operational update.'\n            }\n          }\n        }\n      ],\n      groups: [\n        {\n          key: 'updates',\n          labels: {\n            en: {\n              title: 'Example notice',\n              description: 'An operational update.'\n            }\n          }\n        }\n      ],\n      events: [\n        {\n          key: 'update.self',\n          audience: 'self',\n          group: 'updates',\n          template_prefix: 'demo.update.',\n          recipient_match: 'owner',\n          channels: ['email', 'inbox'],\n          required: false,\n          labels: {\n            en: {\n              title: 'Example notice',\n              description: 'An operational update.'\n            }\n          }\n        }\n      ]\n    }\n  })\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\nimport json\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\npayload = json.dumps({\n  \"expected_revision\": 0,\n  \"catalog\": {\n    \"schema_version\": 1,\n    \"key\": \"demo.preferences\",\n    \"revision\": \"0000000000000000000000000000000000000000000000000000000000000000\",\n    \"managed_prefix\": \"demo.\",\n    \"owner_party\": \"owner\",\n    \"audiences\": [\n      {\n        \"key\": \"self\",\n        \"labels\": {\n          \"en\": {\n            \"title\": \"Example notice\",\n            \"description\": \"An operational update.\"\n          }\n        }\n      }\n    ],\n    \"groups\": [\n      {\n        \"key\": \"updates\",\n        \"labels\": {\n          \"en\": {\n            \"title\": \"Example notice\",\n            \"description\": \"An operational update.\"\n          }\n        }\n      }\n    ],\n    \"events\": [\n      {\n        \"key\": \"update.self\",\n        \"audience\": \"self\",\n        \"group\": \"updates\",\n        \"template_prefix\": \"demo.update.\",\n        \"recipient_match\": \"owner\",\n        \"channels\": [\n          \"email\",\n          \"inbox\"\n        ],\n        \"required\": False,\n        \"labels\": {\n          \"en\": {\n            \"title\": \"Example notice\",\n            \"description\": \"An operational update.\"\n          }\n        }\n      }\n    ]\n  }\n})\nheaders = {\n  \"content-type\": \"application/json\"\n}\n\nconn.request(\n    \"PUT\",\n    \"/v1/preference-catalogs/example\",\n    body=payload,\n    headers=headers,\n)\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('PUT', 'http://localhost:47311/v1/preference-catalogs/example', [\n  'headers' => [\n    'content-type' => 'application/json'\n  ],\n  'json' => [\n    'expected_revision' => 0,\n    'catalog' => [\n      'schema_version' => 1,\n      'key' => 'demo.preferences',\n      'revision' => '0000000000000000000000000000000000000000000000000000000000000000',\n      'managed_prefix' => 'demo.',\n      'owner_party' => 'owner',\n      'audiences' => [\n        [\n          'key' => 'self',\n          'labels' => [\n            'en' => [\n              'title' => 'Example notice',\n              'description' => 'An operational update.'\n            ]\n          ]\n        ]\n      ],\n      'groups' => [\n        [\n          'key' => 'updates',\n          'labels' => [\n            'en' => [\n              'title' => 'Example notice',\n              'description' => 'An operational update.'\n            ]\n          ]\n        ]\n      ],\n      'events' => [\n        [\n          'key' => 'update.self',\n          'audience' => 'self',\n          'group' => 'updates',\n          'template_prefix' => 'demo.update.',\n          'recipient_match' => 'owner',\n          'channels' => [\n            'email',\n            'inbox'\n          ],\n          'required' => false,\n          'labels' => [\n            'en' => [\n              'title' => 'Example notice',\n              'description' => 'An operational update.'\n            ]\n          ]\n        ]\n      ]\n    ]\n  ]\n]);"
          }
        ]
      }
    },
    "/v1/preference-catalogs/{key}/events/{eventKey}/preview": {
      "post": {
        "description": "Render the active tenant template for a preference catalog event and channel, using sample values.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "channel": {
                    "type": "string",
                    "enum": [
                      "email",
                      "whatsapp",
                      "inbox"
                    ]
                  },
                  "locale": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 35
                  },
                  "timezone": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 64
                  },
                  "variables": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  },
                  "identity_values": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "channel",
                  "locale",
                  "timezone",
                  "variables",
                  "identity_values"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
            },
            "in": "path",
            "name": "key",
            "required": true
          },
          {
            "schema": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
            },
            "in": "path",
            "name": "eventKey",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Default Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "subject": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "body": {
                      "type": "string"
                    },
                    "body_format": {
                      "type": "string",
                      "enum": [
                        "html",
                        "text"
                      ]
                    },
                    "locale_used": {
                      "type": "string"
                    },
                    "test_allowed": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "subject",
                    "body",
                    "body_format",
                    "locale_used",
                    "test_allowed"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/preference-catalogs/example/events/example/preview \\\n  --request POST"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/preference-catalogs/example/events/example/preview', {\n  method: 'POST'\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"POST\", \"/v1/preference-catalogs/example/events/example/preview\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/preference-catalogs/example/events/example/preview');"
          }
        ]
      }
    },
    "/v1/preference-sets/{catalogKey}/{ownerRef}": {
      "get": {
        "operationId": "readPreferences",
        "summary": "Read delivery preferences for an owner",
        "tags": [
          "configuração"
        ],
        "description": "Requires a tenant-scoped key or an organization key with X-Anam-Tenant. The trusted integration must derive ownerRef from its own current authority. Reads need read scope; writes need send scope, both current revisions and Idempotency-Key. Required events cannot be disabled. Choices apply at dispatch and activation; received history is preserved. Retry uncertain saves with the same body and key; resolve 409 by rereading.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
            },
            "in": "path",
            "name": "catalogKey",
            "required": true
          },
          {
            "schema": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
            },
            "in": "path",
            "name": "ownerRef",
            "required": true
          }
        ],
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Default Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "revision": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "catalog": {
                      "type": "object",
                      "properties": {
                        "schema_version": {
                          "type": "number",
                          "enum": [
                            1
                          ]
                        },
                        "key": {
                          "type": "string",
                          "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                        },
                        "revision": {
                          "type": "string",
                          "pattern": "^[a-f0-9]{64}$"
                        },
                        "managed_prefix": {
                          "type": "string",
                          "pattern": "^[a-z][a-z0-9._-]{1,79}\\.$"
                        },
                        "owner_party": {
                          "type": "string",
                          "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                        },
                        "required_channels": {
                          "maxItems": 4,
                          "type": "array",
                          "items": {
                            "type": "string",
                            "enum": [
                              "email",
                              "whatsapp",
                              "sms",
                              "inbox"
                            ]
                          }
                        },
                        "audiences": {
                          "minItems": 1,
                          "maxItems": 8,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "key": {
                                "type": "string",
                                "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                              },
                              "labels": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string",
                                  "minLength": 2,
                                  "maxLength": 16
                                },
                                "additionalProperties": {
                                  "type": "object",
                                  "properties": {
                                    "title": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 160
                                    },
                                    "description": {
                                      "type": "string",
                                      "maxLength": 600
                                    },
                                    "example": {
                                      "type": "string",
                                      "maxLength": 400
                                    }
                                  },
                                  "required": [
                                    "title",
                                    "description"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "key",
                              "labels"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "groups": {
                          "minItems": 1,
                          "maxItems": 30,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "key": {
                                "type": "string",
                                "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                              },
                              "labels": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string",
                                  "minLength": 2,
                                  "maxLength": 16
                                },
                                "additionalProperties": {
                                  "type": "object",
                                  "properties": {
                                    "title": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 160
                                    },
                                    "description": {
                                      "type": "string",
                                      "maxLength": 600
                                    },
                                    "example": {
                                      "type": "string",
                                      "maxLength": 400
                                    }
                                  },
                                  "required": [
                                    "title",
                                    "description"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "key",
                              "labels"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "events": {
                          "minItems": 1,
                          "maxItems": 160,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "key": {
                                "type": "string",
                                "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                              },
                              "audience": {
                                "type": "string",
                                "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                              },
                              "group": {
                                "type": "string",
                                "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                              },
                              "template_prefix": {
                                "type": "string",
                                "minLength": 3,
                                "maxLength": 120
                              },
                              "recipient_match": {
                                "type": "string",
                                "enum": [
                                  "owner",
                                  "other",
                                  "any"
                                ]
                              },
                              "channels": {
                                "minItems": 1,
                                "maxItems": 4,
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "enum": [
                                    "email",
                                    "whatsapp",
                                    "sms",
                                    "inbox"
                                  ]
                                }
                              },
                              "required": {
                                "default": false,
                                "type": "boolean"
                              },
                              "labels": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string",
                                  "minLength": 2,
                                  "maxLength": 16
                                },
                                "additionalProperties": {
                                  "type": "object",
                                  "properties": {
                                    "title": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 160
                                    },
                                    "description": {
                                      "type": "string",
                                      "maxLength": 600
                                    },
                                    "example": {
                                      "type": "string",
                                      "maxLength": 400
                                    }
                                  },
                                  "required": [
                                    "title",
                                    "description"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "key",
                              "audience",
                              "group",
                              "template_prefix",
                              "recipient_match",
                              "channels",
                              "required",
                              "labels"
                            ],
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": [
                        "schema_version",
                        "key",
                        "revision",
                        "managed_prefix",
                        "owner_party",
                        "audiences",
                        "groups",
                        "events"
                      ],
                      "additionalProperties": false
                    },
                    "values": {
                      "type": "object",
                      "properties": {
                        "audience_channels": {
                          "default": {},
                          "type": "object",
                          "propertyNames": {
                            "type": "string",
                            "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                          },
                          "additionalProperties": {
                            "type": "object",
                            "propertyNames": {
                              "type": "string",
                              "enum": [
                                "email",
                                "whatsapp",
                                "sms",
                                "inbox"
                              ]
                            },
                            "additionalProperties": {
                              "type": "boolean"
                            }
                          }
                        },
                        "event_channels": {
                          "default": {},
                          "type": "object",
                          "propertyNames": {
                            "type": "string",
                            "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                          },
                          "additionalProperties": {
                            "type": "object",
                            "propertyNames": {
                              "type": "string",
                              "enum": [
                                "email",
                                "whatsapp",
                                "sms",
                                "inbox"
                              ]
                            },
                            "additionalProperties": {
                              "type": "boolean"
                            }
                          }
                        }
                      },
                      "required": [
                        "audience_channels",
                        "event_channels"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "revision",
                    "catalog",
                    "values"
                  ],
                  "additionalProperties": false
                },
                "examples": {
                  "example": {
                    "value": {
                      "revision": 1,
                      "catalog": {
                        "schema_version": 1,
                        "key": "demo.preferences",
                        "revision": "0000000000000000000000000000000000000000000000000000000000000000",
                        "managed_prefix": "demo.",
                        "owner_party": "owner",
                        "audiences": [
                          {
                            "key": "self",
                            "labels": {
                              "en": {
                                "title": "Example notice",
                                "description": "An operational update."
                              }
                            }
                          }
                        ],
                        "groups": [
                          {
                            "key": "updates",
                            "labels": {
                              "en": {
                                "title": "Example notice",
                                "description": "An operational update."
                              }
                            }
                          }
                        ],
                        "events": [
                          {
                            "key": "update.self",
                            "audience": "self",
                            "group": "updates",
                            "template_prefix": "demo.update.",
                            "recipient_match": "owner",
                            "channels": [
                              "email",
                              "inbox"
                            ],
                            "required": false,
                            "labels": {
                              "en": {
                                "title": "Example notice",
                                "description": "An operational update."
                              }
                            }
                          }
                        ]
                      },
                      "values": {
                        "audience_channels": {
                          "self": {
                            "email": false
                          }
                        },
                        "event_channels": {}
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/preference-sets/example/example"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/preference-sets/example/example')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/v1/preference-sets/example/example\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/v1/preference-sets/example/example');"
          }
        ]
      },
      "put": {
        "operationId": "savePreferences",
        "summary": "Save delivery preferences for an owner",
        "tags": [
          "configuração"
        ],
        "description": "Requires a tenant-scoped key or an organization key with X-Anam-Tenant. The trusted integration must derive ownerRef from its own current authority. Reads need read scope; writes need send scope, both current revisions and Idempotency-Key. Required events cannot be disabled. Choices apply at dispatch and activation; received history is preserved. Retry uncertain saves with the same body and key; resolve 409 by rereading.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "expected_revision": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "catalog_revision": {
                    "type": "string",
                    "pattern": "^[a-f0-9]{64}$"
                  },
                  "values": {
                    "type": "object",
                    "properties": {
                      "audience_channels": {
                        "default": {},
                        "type": "object",
                        "propertyNames": {
                          "type": "string",
                          "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                        },
                        "additionalProperties": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string",
                            "enum": [
                              "email",
                              "whatsapp",
                              "sms",
                              "inbox"
                            ]
                          },
                          "additionalProperties": {
                            "type": "boolean"
                          }
                        }
                      },
                      "event_channels": {
                        "default": {},
                        "type": "object",
                        "propertyNames": {
                          "type": "string",
                          "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                        },
                        "additionalProperties": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string",
                            "enum": [
                              "email",
                              "whatsapp",
                              "sms",
                              "inbox"
                            ]
                          },
                          "additionalProperties": {
                            "type": "boolean"
                          }
                        }
                      }
                    },
                    "additionalProperties": false
                  }
                },
                "required": [
                  "expected_revision",
                  "catalog_revision",
                  "values"
                ],
                "additionalProperties": false
              },
              "examples": {
                "example": {
                  "value": {
                    "expected_revision": 0,
                    "catalog_revision": "0000000000000000000000000000000000000000000000000000000000000000",
                    "values": {
                      "audience_channels": {
                        "self": {
                          "email": false
                        }
                      },
                      "event_channels": {}
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
            },
            "in": "path",
            "name": "catalogKey",
            "required": true
          },
          {
            "schema": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
            },
            "in": "path",
            "name": "ownerRef",
            "required": true
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            },
            "example": "preferences-save-0001"
          }
        ],
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Default Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "revision": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "catalog": {
                      "type": "object",
                      "properties": {
                        "schema_version": {
                          "type": "number",
                          "enum": [
                            1
                          ]
                        },
                        "key": {
                          "type": "string",
                          "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                        },
                        "revision": {
                          "type": "string",
                          "pattern": "^[a-f0-9]{64}$"
                        },
                        "managed_prefix": {
                          "type": "string",
                          "pattern": "^[a-z][a-z0-9._-]{1,79}\\.$"
                        },
                        "owner_party": {
                          "type": "string",
                          "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                        },
                        "required_channels": {
                          "maxItems": 4,
                          "type": "array",
                          "items": {
                            "type": "string",
                            "enum": [
                              "email",
                              "whatsapp",
                              "sms",
                              "inbox"
                            ]
                          }
                        },
                        "audiences": {
                          "minItems": 1,
                          "maxItems": 8,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "key": {
                                "type": "string",
                                "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                              },
                              "labels": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string",
                                  "minLength": 2,
                                  "maxLength": 16
                                },
                                "additionalProperties": {
                                  "type": "object",
                                  "properties": {
                                    "title": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 160
                                    },
                                    "description": {
                                      "type": "string",
                                      "maxLength": 600
                                    },
                                    "example": {
                                      "type": "string",
                                      "maxLength": 400
                                    }
                                  },
                                  "required": [
                                    "title",
                                    "description"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "key",
                              "labels"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "groups": {
                          "minItems": 1,
                          "maxItems": 30,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "key": {
                                "type": "string",
                                "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                              },
                              "labels": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string",
                                  "minLength": 2,
                                  "maxLength": 16
                                },
                                "additionalProperties": {
                                  "type": "object",
                                  "properties": {
                                    "title": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 160
                                    },
                                    "description": {
                                      "type": "string",
                                      "maxLength": 600
                                    },
                                    "example": {
                                      "type": "string",
                                      "maxLength": 400
                                    }
                                  },
                                  "required": [
                                    "title",
                                    "description"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "key",
                              "labels"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "events": {
                          "minItems": 1,
                          "maxItems": 160,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "key": {
                                "type": "string",
                                "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                              },
                              "audience": {
                                "type": "string",
                                "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                              },
                              "group": {
                                "type": "string",
                                "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                              },
                              "template_prefix": {
                                "type": "string",
                                "minLength": 3,
                                "maxLength": 120
                              },
                              "recipient_match": {
                                "type": "string",
                                "enum": [
                                  "owner",
                                  "other",
                                  "any"
                                ]
                              },
                              "channels": {
                                "minItems": 1,
                                "maxItems": 4,
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "enum": [
                                    "email",
                                    "whatsapp",
                                    "sms",
                                    "inbox"
                                  ]
                                }
                              },
                              "required": {
                                "default": false,
                                "type": "boolean"
                              },
                              "labels": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string",
                                  "minLength": 2,
                                  "maxLength": 16
                                },
                                "additionalProperties": {
                                  "type": "object",
                                  "properties": {
                                    "title": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 160
                                    },
                                    "description": {
                                      "type": "string",
                                      "maxLength": 600
                                    },
                                    "example": {
                                      "type": "string",
                                      "maxLength": 400
                                    }
                                  },
                                  "required": [
                                    "title",
                                    "description"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "key",
                              "audience",
                              "group",
                              "template_prefix",
                              "recipient_match",
                              "channels",
                              "required",
                              "labels"
                            ],
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": [
                        "schema_version",
                        "key",
                        "revision",
                        "managed_prefix",
                        "owner_party",
                        "audiences",
                        "groups",
                        "events"
                      ],
                      "additionalProperties": false
                    },
                    "values": {
                      "type": "object",
                      "properties": {
                        "audience_channels": {
                          "default": {},
                          "type": "object",
                          "propertyNames": {
                            "type": "string",
                            "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                          },
                          "additionalProperties": {
                            "type": "object",
                            "propertyNames": {
                              "type": "string",
                              "enum": [
                                "email",
                                "whatsapp",
                                "sms",
                                "inbox"
                              ]
                            },
                            "additionalProperties": {
                              "type": "boolean"
                            }
                          }
                        },
                        "event_channels": {
                          "default": {},
                          "type": "object",
                          "propertyNames": {
                            "type": "string",
                            "pattern": "^[a-zA-Z0-9_.:-]{1,160}$"
                          },
                          "additionalProperties": {
                            "type": "object",
                            "propertyNames": {
                              "type": "string",
                              "enum": [
                                "email",
                                "whatsapp",
                                "sms",
                                "inbox"
                              ]
                            },
                            "additionalProperties": {
                              "type": "boolean"
                            }
                          }
                        }
                      },
                      "required": [
                        "audience_channels",
                        "event_channels"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "revision",
                    "catalog",
                    "values"
                  ],
                  "additionalProperties": false
                },
                "examples": {
                  "example": {
                    "value": {
                      "revision": 1,
                      "catalog": {
                        "schema_version": 1,
                        "key": "demo.preferences",
                        "revision": "0000000000000000000000000000000000000000000000000000000000000000",
                        "managed_prefix": "demo.",
                        "owner_party": "owner",
                        "audiences": [
                          {
                            "key": "self",
                            "labels": {
                              "en": {
                                "title": "Example notice",
                                "description": "An operational update."
                              }
                            }
                          }
                        ],
                        "groups": [
                          {
                            "key": "updates",
                            "labels": {
                              "en": {
                                "title": "Example notice",
                                "description": "An operational update."
                              }
                            }
                          }
                        ],
                        "events": [
                          {
                            "key": "update.self",
                            "audience": "self",
                            "group": "updates",
                            "template_prefix": "demo.update.",
                            "recipient_match": "owner",
                            "channels": [
                              "email",
                              "inbox"
                            ],
                            "required": false,
                            "labels": {
                              "en": {
                                "title": "Example notice",
                                "description": "An operational update."
                              }
                            }
                          }
                        ]
                      },
                      "values": {
                        "audience_channels": {
                          "self": {
                            "email": false
                          }
                        },
                        "event_channels": {}
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/preference-sets/example/example \\\n  --request PUT \\\n  --header 'content-type: application/json' \\\n  --data '{\n  \"expected_revision\": 0,\n  \"catalog_revision\": \"0000000000000000000000000000000000000000000000000000000000000000\",\n  \"values\": {\n    \"audience_channels\": {\n      \"self\": {\n        \"email\": false\n      }\n    },\n    \"event_channels\": {}\n  }\n}'"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/preference-sets/example/example', {\n  method: 'PUT',\n  headers: {\n    'content-type': 'application/json'\n  },\n  body: JSON.stringify({\n    expected_revision: 0,\n    catalog_revision: '0000000000000000000000000000000000000000000000000000000000000000',\n    values: {\n      audience_channels: {\n        self: {\n          email: false\n        }\n      },\n      event_channels: {}\n    }\n  })\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\nimport json\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\npayload = json.dumps({\n  \"expected_revision\": 0,\n  \"catalog_revision\": \"0000000000000000000000000000000000000000000000000000000000000000\",\n  \"values\": {\n    \"audience_channels\": {\n      \"self\": {\n        \"email\": False\n      }\n    },\n    \"event_channels\": {}\n  }\n})\nheaders = {\n  \"content-type\": \"application/json\"\n}\n\nconn.request(\n    \"PUT\",\n    \"/v1/preference-sets/example/example\",\n    body=payload,\n    headers=headers,\n)\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('PUT', 'http://localhost:47311/v1/preference-sets/example/example', [\n  'headers' => [\n    'content-type' => 'application/json'\n  ],\n  'json' => [\n    'expected_revision' => 0,\n    'catalog_revision' => '0000000000000000000000000000000000000000000000000000000000000000',\n    'values' => [\n      'audience_channels' => [\n        'self' => [\n          'email' => false\n        ]\n      ],\n      'event_channels' => []\n    ]\n  ]\n]);"
          }
        ]
      }
    },
    "/v1/capabilities": {
      "get": {
        "operationId": "getCapabilities",
        "summary": "Discover runtime modes and registered connector capabilities",
        "tags": [
          "developer"
        ],
        "description": "Authenticated registry-derived capabilities. Sender management remains real even when message delivery is simulated.",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Authenticated runtime capabilities",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "capabilities": {
                    "value": {
                      "service": "anam-notifications",
                      "key_scope": "organization",
                      "scopes": [
                        "admin",
                        "read",
                        "send"
                      ],
                      "delivery_mode": "fake",
                      "sender_management_mode": "live",
                      "web_push": {
                        "available": false,
                        "max_devices": 10
                      },
                      "providers": []
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key"
          },
          "403": {
            "description": "Missing read scope"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/capabilities"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/capabilities')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/v1/capabilities\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/v1/capabilities');"
          }
        ]
      }
    },
    "/v1/messages": {
      "post": {
        "operationId": "postV1Messages",
        "summary": "Aceita um envio imediato ou agendado",
        "tags": [
          "mensagens"
        ],
        "description": "Cria uma mensagem por antecedência pedida em `schedule.offsets`, cada uma no instante calculado a\npartir de `schedule.anchor_at` e já ajustada à janela de silêncio no fuso do destinatário.\n\nO header `Idempotency-Key` é obrigatório. Mesma chave com o mesmo corpo devolve a resposta original\ne o header `idempotent-replay: true`; mesma chave com corpo diferente é `409`.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "recipient": {
                    "type": "object",
                    "properties": {
                      "external_ref": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      "locale": {
                        "anyOf": [
                          {
                            "type": "string",
                            "minLength": 2,
                            "maxLength": 35
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "timezone": {
                        "anyOf": [
                          {
                            "type": "string",
                            "minLength": 3,
                            "maxLength": 64
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    },
                    "required": [
                      "external_ref"
                    ]
                  },
                  "template": {
                    "type": "object",
                    "properties": {
                      "key": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 120
                      }
                    },
                    "required": [
                      "key"
                    ]
                  },
                  "sender_ref": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 128
                  },
                  "variables": {
                    "default": {},
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  },
                  "parties": {
                    "default": {},
                    "type": "object",
                    "propertyNames": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 40
                    },
                    "additionalProperties": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 200
                    }
                  },
                  "category": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "utility",
                          "authentication",
                          "marketing"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "channel_policy": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "chain": {
                            "anyOf": [
                              {
                                "minItems": 1,
                                "maxItems": 6,
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "escalate_after_seconds": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": 30,
                                "maximum": 86400
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "dedup_key": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "schedule": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "anchor_at": {
                            "type": "string"
                          },
                          "offsets": {
                            "anyOf": [
                              {
                                "maxItems": 12,
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 12
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "anchor_at"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "send_at": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "source": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "system": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "event_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 200
                          },
                          "event_version": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "occurrence_id": {
                            "anyOf": [
                              {
                                "type": "string",
                                "maxLength": 200
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "system",
                          "event_id"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "recipient",
                  "template"
                ],
                "additionalProperties": false
              },
              "examples": {
                "lembrete_agendado": {
                  "summary": "Lembretes de 24h e 2h de uma consulta",
                  "value": {
                    "recipient": {
                      "external_ref": "patient_77",
                      "locale": "pt-BR",
                      "timezone": "America/Sao_Paulo"
                    },
                    "template": {
                      "key": "appointment.reminder"
                    },
                    "variables": {
                      "appointment_at": "2026-10-02T13:00:00Z"
                    },
                    "parties": {
                      "professional": "prof_1042"
                    },
                    "channel_policy": {
                      "chain": [
                        "push",
                        "whatsapp",
                        "sms"
                      ],
                      "escalate_after_seconds": 900
                    },
                    "dedup_key": "evt_8f2c:reminder",
                    "schedule": {
                      "anchor_at": "2026-10-02T13:00:00Z",
                      "offsets": [
                        "-24h",
                        "-2h"
                      ]
                    },
                    "source": {
                      "system": "anam-calendar",
                      "event_id": "evt_8f2c",
                      "event_version": 7
                    }
                  }
                },
                "aviso_de_acesso": {
                  "summary": "Notificação de acesso ao titular (art. 29(6) da Lei nº 58/2019)",
                  "value": {
                    "recipient": {
                      "external_ref": "patient_77"
                    },
                    "template": {
                      "key": "privacy.data_access_notice"
                    },
                    "variables": {
                      "accessed_at": "2026-09-18T14:30:00Z",
                      "data_category": "agenda"
                    },
                    "parties": {
                      "accessor": "prof_1042"
                    },
                    "dedup_key": "access:patient_77:2026-09-18"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "202": {
            "description": "aceito",
            "headers": {
              "idempotent-replay": {
                "description": "Presente e `true` quando a resposta é a repetição de uma chamada anterior.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SendMessageResponse"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Aceita um envio imediato ou agendado",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Escopo insuficiente, tenant suspenso, destinatário bloqueado, ou recurso desabilitado para o\ntenant (`data_access_notices_disabled`).\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "destinatário ou template inexistente",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "`idempotency_conflict` (mesma chave, corpo diferente) ou chave ainda em processamento.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "corpo inválido, variável não declarada, ou identidade não resolvível",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "identidade_nao_resolvida": {
                    "summary": "O cadastro não tem o nome exigido pelo template",
                    "value": {
                      "error": {
                        "code": "validation_failed",
                        "message": "o cadastro de \"patient_77\" não tem o campo \"first_name\", exigido pela variável \"recipient_first_name\"",
                        "detail": {
                          "failure_code": "identity_unresolved",
                          "variable": "recipient_first_name",
                          "template_key": "appointment.reminder",
                          "external_ref": "patient_77",
                          "profile_field": "first_name",
                          "available_fields": [
                            "display_name"
                          ],
                          "hint": "preencha o campo no cadastro, ou declare um fallback explícito na variável do template. Mensagem com nome em branco não é enviada."
                        }
                      }
                    }
                  },
                  "identidade_enviada_pelo_cliente": {
                    "summary": "Variável de identidade não pode vir no pedido",
                    "value": {
                      "error": {
                        "code": "validation_failed",
                        "message": "estas variáveis são resolvidas pelo cadastro de destinatários e não podem vir no pedido: recipient_first_name",
                        "detail": {
                          "failure_code": "identity_override_forbidden",
                          "variables": [
                            "recipient_first_name"
                          ]
                        }
                      }
                    }
                  },
                  "papel_ausente_em_parties": {
                    "summary": "O template exige um papel que o pedido não trouxe",
                    "value": {
                      "error": {
                        "code": "validation_failed",
                        "message": "o template \"appointment.reminder\" exige o papel \"professional\" em parties",
                        "detail": {
                          "failure_code": "party_ref_missing",
                          "template_key": "appointment.reminder",
                          "missing_roles": [
                            "professional"
                          ],
                          "hint": "envie parties: { \"professional\": \"<external_ref>\" }. Os nomes vêm do cadastro deste serviço, não do pedido."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "description": "Derive do evento de origem, por exemplo `evt_8f2c:7:reminder`."
          }
        ],
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/messages \\\n  --request POST \\\n  --header 'content-type: application/json' \\\n  --data '{\n  \"recipient\": {\n    \"external_ref\": \"patient_77\",\n    \"locale\": \"pt-BR\",\n    \"timezone\": \"America/Sao_Paulo\"\n  },\n  \"template\": {\n    \"key\": \"appointment.reminder\"\n  },\n  \"variables\": {\n    \"appointment_at\": \"2026-10-02T13:00:00Z\"\n  },\n  \"parties\": {\n    \"professional\": \"prof_1042\"\n  },\n  \"channel_policy\": {\n    \"chain\": [\n      \"push\",\n      \"whatsapp\",\n      \"sms\"\n    ],\n    \"escalate_after_seconds\": 900\n  },\n  \"dedup_key\": \"evt_8f2c:reminder\",\n  \"schedule\": {\n    \"anchor_at\": \"2026-10-02T13:00:00Z\",\n    \"offsets\": [\n      \"-24h\",\n      \"-2h\"\n    ]\n  },\n  \"source\": {\n    \"system\": \"anam-calendar\",\n    \"event_id\": \"evt_8f2c\",\n    \"event_version\": 7\n  }\n}'"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/messages', {\n  method: 'POST',\n  headers: {\n    'content-type': 'application/json'\n  },\n  body: JSON.stringify({\n    recipient: {\n      external_ref: 'patient_77',\n      locale: 'pt-BR',\n      timezone: 'America/Sao_Paulo'\n    },\n    template: {\n      key: 'appointment.reminder'\n    },\n    variables: {\n      appointment_at: '2026-10-02T13:00:00Z'\n    },\n    parties: {\n      professional: 'prof_1042'\n    },\n    channel_policy: {\n      chain: ['push', 'whatsapp', 'sms'],\n      escalate_after_seconds: 900\n    },\n    dedup_key: 'evt_8f2c:reminder',\n    schedule: {\n      anchor_at: '2026-10-02T13:00:00Z',\n      offsets: ['-24h', '-2h']\n    },\n    source: {\n      system: 'anam-calendar',\n      event_id: 'evt_8f2c',\n      event_version: 7\n    }\n  })\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\nimport json\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\npayload = json.dumps({\n  \"recipient\": {\n    \"external_ref\": \"patient_77\",\n    \"locale\": \"pt-BR\",\n    \"timezone\": \"America/Sao_Paulo\"\n  },\n  \"template\": {\n    \"key\": \"appointment.reminder\"\n  },\n  \"variables\": {\n    \"appointment_at\": \"2026-10-02T13:00:00Z\"\n  },\n  \"parties\": {\n    \"professional\": \"prof_1042\"\n  },\n  \"channel_policy\": {\n    \"chain\": [\n      \"push\",\n      \"whatsapp\",\n      \"sms\"\n    ],\n    \"escalate_after_seconds\": 900\n  },\n  \"dedup_key\": \"evt_8f2c:reminder\",\n  \"schedule\": {\n    \"anchor_at\": \"2026-10-02T13:00:00Z\",\n    \"offsets\": [\n      \"-24h\",\n      \"-2h\"\n    ]\n  },\n  \"source\": {\n    \"system\": \"anam-calendar\",\n    \"event_id\": \"evt_8f2c\",\n    \"event_version\": 7\n  }\n})\nheaders = {\n  \"content-type\": \"application/json\"\n}\n\nconn.request(\n    \"POST\",\n    \"/v1/messages\",\n    body=payload,\n    headers=headers,\n)\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/messages', [\n  'headers' => [\n    'content-type' => 'application/json'\n  ],\n  'json' => [\n    'recipient' => [\n      'external_ref' => 'patient_77',\n      'locale' => 'pt-BR',\n      'timezone' => 'America/Sao_Paulo'\n    ],\n    'template' => [\n      'key' => 'appointment.reminder'\n    ],\n    'variables' => [\n      'appointment_at' => '2026-10-02T13:00:00Z'\n    ],\n    'parties' => [\n      'professional' => 'prof_1042'\n    ],\n    'channel_policy' => [\n      'chain' => [\n        'push',\n        'whatsapp',\n        'sms'\n      ],\n      'escalate_after_seconds' => 900\n    ],\n    'dedup_key' => 'evt_8f2c:reminder',\n    'schedule' => [\n      'anchor_at' => '2026-10-02T13:00:00Z',\n      'offsets' => [\n        '-24h',\n        '-2h'\n      ]\n    ],\n    'source' => [\n      'system' => 'anam-calendar',\n      'event_id' => 'evt_8f2c',\n      'event_version' => 7\n    ]\n  ]\n]);"
          }
        ]
      }
    },
    "/v1/deliveries": {
      "get": {
        "operationId": "getV1Deliveries",
        "summary": "Histórico mínimo de entregas de um evento de origem",
        "tags": [
          "mensagens"
        ],
        "description": "Requer escopo read e contexto do tenant. Não decifra contatos nem conteúdo. O cursor é opaco para o cliente; a ordem é estável por identificador, não cronológica. Accept text/event-stream negocia apenas sinais de mudança do mesmo tenant e origem, sem conteúdo nem consulta ao provider. Há sinal inicial, heartbeat de 15s e duração máxima de 300s; ao reconectar, leia o snapshot JSON novamente.",
        "parameters": [
          {
            "name": "source_system",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 80
            }
          },
          {
            "name": "source_event_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          },
          {
            "name": "after",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          }
        ],
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Entregas isoladas pelo tenant autenticado",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string",
                  "description": "event changed with data {\"changed\":true}; comments are heartbeats. No durable cursor; reconnect requires a fresh JSON snapshot."
                }
              },
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "next_cursor"
                  ],
                  "properties": {
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uuid"
                    },
                    "data": {
                      "type": "array",
                      "maxItems": 100,
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "status",
                          "channel",
                          "attempt",
                          "scheduled_at",
                          "sent_at",
                          "delivered_at",
                          "failure_code",
                          "reason",
                          "contact_hint",
                          "template"
                        ],
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "status": {
                            "type": "string"
                          },
                          "channel": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "attempt": {
                            "type": "integer",
                            "minimum": 0
                          },
                          "scheduled_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "sent_at": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "delivered_at": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "failure_code": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "reason": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "contact_hint": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "description": "Destino mascarado utilizado no envio"
                          },
                          "template": {
                            "type": "string"
                          },
                          "engagement_kind": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "enum": [
                              "opened",
                              "read",
                              null
                            ]
                          },
                          "engagement_observed_at": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "receipt_check_at": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "receipt_check_state": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "enum": [
                              "receipt_check_requested",
                              "receipt_checked",
                              "receipt_check_failed",
                              null
                            ]
                          },
                          "delivery_mode": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "enum": [
                              "simulated",
                              "live_test",
                              null
                            ]
                          }
                        }
                      }
                    }
                  }
                },
                "examples": {
                  "exemplo": {
                    "summary": "Histórico mínimo de entregas de um evento de origem",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/deliveries"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/deliveries')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/v1/deliveries\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/v1/deliveries');"
          }
        ]
      }
    },
    "/v1/messages/{id}": {
      "get": {
        "operationId": "getV1MessagesId",
        "summary": "Estado e histórico de uma mensagem",
        "tags": [
          "mensagens"
        ],
        "description": "Estado e histórico de uma mensagem.",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "$ref": "#/components/parameters/MessageId"
          }
        ],
        "responses": {
          "200": {
            "description": "mensagem",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageView"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Estado e histórico de uma mensagem",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/messages/example"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/messages/example')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/v1/messages/example\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/v1/messages/example');"
          }
        ]
      }
    },
    "/v1/messages/{id}/cancel": {
      "post": {
        "operationId": "postV1MessagesIdCancel",
        "summary": "Cancela uma mensagem ainda pendente",
        "tags": [
          "mensagens"
        ],
        "description": "Cancela uma mensagem ainda pendente.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "default": "cancelled_by_client",
                    "type": "string",
                    "maxLength": 200
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "$ref": "#/components/parameters/MessageId"
          }
        ],
        "responses": {
          "200": {
            "description": "cancelada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "cancelled": {
                      "type": "boolean",
                      "const": true
                    }
                  }
                },
                "examples": {
                  "exemplo": {
                    "summary": "Cancela uma mensagem ainda pendente",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "409": {
            "description": "mensagem não está mais pendente (já enviada, cancelada ou vencida)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "cancelled": {
                      "type": "boolean",
                      "const": false
                    },
                    "reason": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/messages/example/cancel \\\n  --request POST"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/messages/example/cancel', {\n  method: 'POST'\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"POST\", \"/v1/messages/example/cancel\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/messages/example/cancel');"
          }
        ]
      }
    },
    "/v1/messages/reschedule-by-source": {
      "post": {
        "operationId": "postV1MessagesRescheduleBySource",
        "summary": "Move todos os agendamentos de um evento de origem",
        "tags": [
          "mensagens"
        ],
        "description": "Recalcula `anchor_at + offset` para cada mensagem pendente daquele `source.event_id`. Antecedência\nque caiu no passado vira `skipped_past_due`; mensagem já enviada não é tocada.\n\n`source.event_version` precisa ser monotônico, e **só versão que avança altera estado**. Os dois\nmodos de não avançar têm código próprio, porque apontam para causas opostas:\n\n| Resposta | Quando | O que fazer |\n| --- | --- | --- |\n| `{\"applied\": false, \"reason\": \"stale_event_version\"}` | versão **menor** que a aplicada | nada: é ordem invertida no transporte, e ignorar é o comportamento correto |\n| `{\"applied\": false, \"reason\": \"duplicate_event_version\"}` | versão **igual** à aplicada | se foi reentrega do mesmo comando, nada — o estado já é o desejado. Se você mudou o comando, **avance a versão**: sem isso a mudança é descartada |\n\nAmbos devolvem `200`: reentrega at-least-once é operação normal, não falha. O que **não** acontece\nmais é a versão igual ser reaplicada — antes, reenviar a versão 5 com outra âncora movia o\nagendamento e respondia `applied: true`, anulando a garantia do versionamento.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "object",
                    "properties": {
                      "system": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64
                      },
                      "event_id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      "event_version": {
                        "anyOf": [
                          {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 9007199254740991
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "occurrence_id": {
                        "anyOf": [
                          {
                            "type": "string",
                            "maxLength": 200
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    },
                    "required": [
                      "system",
                      "event_id"
                    ]
                  },
                  "replace_pending": {
                    "type": "boolean"
                  },
                  "anchor_at": {
                    "type": "string"
                  },
                  "variables": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  }
                },
                "required": [
                  "source",
                  "anchor_at"
                ],
                "additionalProperties": false
              },
              "examples": {
                "horario_mudou": {
                  "value": {
                    "source": {
                      "system": "anam-calendar",
                      "event_id": "evt_8f2c",
                      "event_version": 8
                    },
                    "anchor_at": "2026-10-08T15:00:00Z",
                    "variables": {
                      "appointment_at": "2026-10-08T15:00:00Z"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "resultado da aplicação",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SourceCommandResult"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Move todos os agendamentos de um evento de origem",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/messages/reschedule-by-source \\\n  --request POST \\\n  --header 'content-type: application/json' \\\n  --data '{\n  \"source\": {\n    \"system\": \"anam-calendar\",\n    \"event_id\": \"evt_8f2c\",\n    \"event_version\": 8\n  },\n  \"anchor_at\": \"2026-10-08T15:00:00Z\",\n  \"variables\": {\n    \"appointment_at\": \"2026-10-08T15:00:00Z\"\n  }\n}'"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/messages/reschedule-by-source', {\n  method: 'POST',\n  headers: {\n    'content-type': 'application/json'\n  },\n  body: JSON.stringify({\n    source: {\n      system: 'anam-calendar',\n      event_id: 'evt_8f2c',\n      event_version: 8\n    },\n    anchor_at: '2026-10-08T15:00:00Z',\n    variables: {\n      appointment_at: '2026-10-08T15:00:00Z'\n    }\n  })\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\nimport json\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\npayload = json.dumps({\n  \"source\": {\n    \"system\": \"anam-calendar\",\n    \"event_id\": \"evt_8f2c\",\n    \"event_version\": 8\n  },\n  \"anchor_at\": \"2026-10-08T15:00:00Z\",\n  \"variables\": {\n    \"appointment_at\": \"2026-10-08T15:00:00Z\"\n  }\n})\nheaders = {\n  \"content-type\": \"application/json\"\n}\n\nconn.request(\n    \"POST\",\n    \"/v1/messages/reschedule-by-source\",\n    body=payload,\n    headers=headers,\n)\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/messages/reschedule-by-source', [\n  'headers' => [\n    'content-type' => 'application/json'\n  ],\n  'json' => [\n    'source' => [\n      'system' => 'anam-calendar',\n      'event_id' => 'evt_8f2c',\n      'event_version' => 8\n    ],\n    'anchor_at' => '2026-10-08T15:00:00Z',\n    'variables' => [\n      'appointment_at' => '2026-10-08T15:00:00Z'\n    ]\n  ]\n]);"
          }
        ]
      }
    },
    "/v1/messages/cancel-by-source": {
      "post": {
        "operationId": "postV1MessagesCancelBySource",
        "summary": "Cancela todos os agendamentos de um evento de origem",
        "tags": [
          "mensagens"
        ],
        "description": "Mesma guarda de versão do reagendamento: só versão que avança altera estado. Repetir a versão já\naplicada devolve `200` com `duplicate_event_version` e não cancela nada de novo.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "object",
                    "properties": {
                      "system": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64
                      },
                      "event_id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      "event_version": {
                        "anyOf": [
                          {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 9007199254740991
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "occurrence_id": {
                        "anyOf": [
                          {
                            "type": "string",
                            "maxLength": 200
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    },
                    "required": [
                      "system",
                      "event_id"
                    ]
                  },
                  "reason": {
                    "default": "cancelled_by_source",
                    "type": "string",
                    "maxLength": 200
                  }
                },
                "required": [
                  "source"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "resultado da aplicação",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SourceCommandResult"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Cancela todos os agendamentos de um evento de origem",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/messages/cancel-by-source \\\n  --request POST"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/messages/cancel-by-source', {\n  method: 'POST'\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"POST\", \"/v1/messages/cancel-by-source\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/messages/cancel-by-source');"
          }
        ]
      }
    },
    "/v1/recipients/{externalRef}": {
      "put": {
        "operationId": "putV1RecipientsExternalRef",
        "summary": "Cria ou atualiza o cadastro do destinatário",
        "tags": [
          "destinatários"
        ],
        "description": "Este serviço é dono do dado de identificação e de contato. Contato e `profile` são cifrados em\nrepouso; a busca por contato usa blind index, então `+55 11 91234-5678` e `+5511912345678` são o\nmesmo contato sem nada ser decifrado.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "projection": {
                    "type": "object",
                    "properties": {
                      "source": {
                        "type": "string",
                        "pattern": "^[a-zA-Z0-9_.:-]{1,128}$"
                      },
                      "version": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 9007199254740991
                      }
                    },
                    "required": [
                      "source",
                      "version"
                    ],
                    "additionalProperties": false
                  },
                  "kind": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 40
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "locale": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 2,
                        "maxLength": 35
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "timezone": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 3,
                        "maxLength": 64
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "profile": {
                    "anyOf": [
                      {
                        "type": "object",
                        "propertyNames": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 41
                        },
                        "additionalProperties": {
                          "type": "string",
                          "maxLength": 200
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "clear_channels": {
                    "maxItems": 4,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "push",
                        "whatsapp",
                        "sms",
                        "email"
                      ]
                    }
                  },
                  "contacts": {
                    "anyOf": [
                      {
                        "maxItems": 8,
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "channel": {
                              "type": "string",
                              "enum": [
                                "push",
                                "whatsapp",
                                "sms",
                                "email"
                              ]
                            },
                            "value": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 320
                            },
                            "verified": {
                              "default": false,
                              "type": "boolean"
                            },
                            "priority": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": 1,
                                  "maximum": 1000
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "metadata": {
                              "default": {},
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {
                                "type": "string"
                              }
                            }
                          },
                          "required": [
                            "channel",
                            "value"
                          ]
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "additionalProperties": false
              },
              "examples": {
                "paciente_em_lisboa": {
                  "value": {
                    "locale": "pt-PT",
                    "timezone": "Europe/Lisbon",
                    "profile": {
                      "display_name": "Marina Alves",
                      "first_name": "Marina"
                    },
                    "contacts": [
                      {
                        "channel": "whatsapp",
                        "value": "+351912345678",
                        "verified": true
                      },
                      {
                        "channel": "push",
                        "value": "<device-token>",
                        "metadata": {
                          "platform": "android"
                        }
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "externalRef",
            "required": true
          },
          {
            "$ref": "#/components/parameters/ExternalRef"
          }
        ],
        "responses": {
          "200": {
            "description": "cadastro atualizado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecipientView"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Cria ou atualiza o cadastro do destinatário",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/recipients/example \\\n  --request PUT \\\n  --header 'content-type: application/json' \\\n  --data '{\n  \"locale\": \"pt-PT\",\n  \"timezone\": \"Europe/Lisbon\",\n  \"profile\": {\n    \"display_name\": \"Marina Alves\",\n    \"first_name\": \"Marina\"\n  },\n  \"contacts\": [\n    {\n      \"channel\": \"whatsapp\",\n      \"value\": \"+351912345678\",\n      \"verified\": true\n    },\n    {\n      \"channel\": \"push\",\n      \"value\": \"<device-token>\",\n      \"metadata\": {\n        \"platform\": \"android\"\n      }\n    }\n  ]\n}'"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/recipients/example', {\n  method: 'PUT',\n  headers: {\n    'content-type': 'application/json'\n  },\n  body: JSON.stringify({\n    locale: 'pt-PT',\n    timezone: 'Europe/Lisbon',\n    profile: {\n      display_name: 'Marina Alves',\n      first_name: 'Marina'\n    },\n    contacts: [\n      {\n        channel: 'whatsapp',\n        value: '+351912345678',\n        verified: true\n      },\n      {\n        channel: 'push',\n        value: '<device-token>',\n        metadata: {\n          platform: 'android'\n        }\n      }\n    ]\n  })\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\nimport json\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\npayload = json.dumps({\n  \"locale\": \"pt-PT\",\n  \"timezone\": \"Europe/Lisbon\",\n  \"profile\": {\n    \"display_name\": \"Marina Alves\",\n    \"first_name\": \"Marina\"\n  },\n  \"contacts\": [\n    {\n      \"channel\": \"whatsapp\",\n      \"value\": \"+351912345678\",\n      \"verified\": True\n    },\n    {\n      \"channel\": \"push\",\n      \"value\": \"<device-token>\",\n      \"metadata\": {\n        \"platform\": \"android\"\n      }\n    }\n  ]\n})\nheaders = {\n  \"content-type\": \"application/json\"\n}\n\nconn.request(\n    \"PUT\",\n    \"/v1/recipients/example\",\n    body=payload,\n    headers=headers,\n)\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('PUT', 'http://localhost:47311/v1/recipients/example', [\n  'headers' => [\n    'content-type' => 'application/json'\n  ],\n  'json' => [\n    'locale' => 'pt-PT',\n    'timezone' => 'Europe/Lisbon',\n    'profile' => [\n      'display_name' => 'Marina Alves',\n      'first_name' => 'Marina'\n    ],\n    'contacts' => [\n      [\n        'channel' => 'whatsapp',\n        'value' => '+351912345678',\n        'verified' => true\n      ],\n      [\n        'channel' => 'push',\n        'value' => '<device-token>',\n        'metadata' => [\n          'platform' => 'android'\n        ]\n      ]\n    ]\n  ]\n]);"
          }
        ]
      },
      "get": {
        "operationId": "getV1RecipientsExternalRef",
        "summary": "Consulta o cadastro, sem expor valores",
        "tags": [
          "destinatários"
        ],
        "description": "Devolve dica mascarada do contato e a lista de campos de `profile` existentes, nunca os valores.",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "externalRef",
            "required": true
          },
          {
            "$ref": "#/components/parameters/ExternalRef"
          }
        ],
        "responses": {
          "200": {
            "description": "cadastro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecipientView"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Consulta o cadastro, sem expor valores",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/recipients/example"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/recipients/example')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/v1/recipients/example\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/v1/recipients/example');"
          }
        ]
      },
      "delete": {
        "operationId": "deleteV1RecipientsExternalRef",
        "summary": "Expurga o dado pessoal do destinatário",
        "tags": [
          "destinatários"
        ],
        "description": "Atende pedido de eliminação do titular. Redige contato, `profile`, variáveis e texto renderizado, e\n**preserva** o histórico de entrega — o registro de que a comunicação aconteceu continua auditável.\n",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "externalRef",
            "required": true
          },
          {
            "$ref": "#/components/parameters/ExternalRef"
          }
        ],
        "responses": {
          "200": {
            "description": "expurgado",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "purged": {
                      "type": "boolean"
                    }
                  }
                },
                "examples": {
                  "exemplo": {
                    "summary": "Expurga o dado pessoal do destinatário",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/recipients/example \\\n  --request DELETE"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/recipients/example', {\n  method: 'DELETE'\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"DELETE\", \"/v1/recipients/example\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('DELETE', 'http://localhost:47311/v1/recipients/example');"
          }
        ]
      }
    },
    "/v1/recipients/{externalRef}/preferences": {
      "put": {
        "operationId": "putV1RecipientsExternalRefPreferences",
        "summary": "Opt-out por canal e por categoria, e janela de silêncio própria",
        "tags": [
          "destinatários"
        ],
        "description": "Opt-out por canal e por categoria, e janela de silêncio própria.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "channel_opt_out": {
                    "anyOf": [
                      {
                        "maxItems": 4,
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "push",
                            "whatsapp",
                            "sms",
                            "email"
                          ]
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "category_opt_out": {
                    "anyOf": [
                      {
                        "maxItems": 4,
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "utility",
                            "authentication",
                            "marketing"
                          ]
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "quiet_hours": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "start": {
                            "type": "string",
                            "pattern": "^\\d{2}:\\d{2}$"
                          },
                          "end": {
                            "type": "string",
                            "pattern": "^\\d{2}:\\d{2}$"
                          }
                        },
                        "required": [
                          "start",
                          "end"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "unsubscribed_all": {
                    "type": [
                      "boolean",
                      "null"
                    ]
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "externalRef",
            "required": true
          },
          {
            "$ref": "#/components/parameters/ExternalRef"
          }
        ],
        "responses": {
          "200": {
            "description": "preferências atualizadas",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "updated": {
                      "type": "boolean",
                      "const": true
                    }
                  }
                },
                "examples": {
                  "exemplo": {
                    "summary": "Opt-out por canal e por categoria, e janela de silêncio própria",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/recipients/example/preferences \\\n  --request PUT"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/recipients/example/preferences', {\n  method: 'PUT'\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"PUT\", \"/v1/recipients/example/preferences\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('PUT', 'http://localhost:47311/v1/recipients/example/preferences');"
          }
        ]
      }
    },
    "/v1/recipients/{externalRef}/consents": {
      "post": {
        "operationId": "postV1RecipientsExternalRefConsents",
        "summary": "Registra consentimento",
        "tags": [
          "destinatários"
        ],
        "description": "Append-only. Categoria que exige consentimento (marketing) sem registro concedido é suprimida antes\ndo envio, não enviada.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "purpose": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 64
                  },
                  "channel": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "push",
                          "whatsapp",
                          "sms",
                          "email"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "granted": {
                    "type": "boolean"
                  },
                  "source": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 64
                  },
                  "policy_version": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 40
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "evidence": {
                    "default": {},
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  },
                  "occurred_at": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "purpose",
                  "granted",
                  "source"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "externalRef",
            "required": true
          },
          {
            "$ref": "#/components/parameters/ExternalRef"
          }
        ],
        "responses": {
          "201": {
            "description": "consentimento registrado",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  }
                },
                "examples": {
                  "exemplo": {
                    "summary": "Registra consentimento",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/recipients/example/consents \\\n  --request POST"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/recipients/example/consents', {\n  method: 'POST'\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"POST\", \"/v1/recipients/example/consents\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/recipients/example/consents');"
          }
        ]
      }
    },
    "/v1/recipients/{externalRef}/history": {
      "get": {
        "operationId": "getV1RecipientsExternalRefHistory",
        "summary": "Histórico auditável do destinatário",
        "tags": [
          "destinatários"
        ],
        "description": "O acesso a esta rota é registrado na trilha de auditoria.",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "externalRef",
            "required": true
          },
          {
            "$ref": "#/components/parameters/ExternalRef"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "histórico",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecipientHistory"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Histórico auditável do destinatário",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/recipients/example/history"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/recipients/example/history')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/v1/recipients/example/history\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/v1/recipients/example/history');"
          }
        ]
      }
    },
    "/v1/templates": {
      "post": {
        "operationId": "postV1Templates",
        "summary": "Cria ou atualiza um template",
        "tags": [
          "templates"
        ],
        "description": "Cria ou atualiza um template.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "key": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  },
                  "category": {
                    "type": "string",
                    "enum": [
                      "utility",
                      "authentication",
                      "marketing"
                    ]
                  },
                  "content_class": {
                    "default": "minimal",
                    "type": "string",
                    "enum": [
                      "minimal",
                      "standard"
                    ]
                  },
                  "description": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 500
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "default_channel_chain": {
                    "anyOf": [
                      {
                        "minItems": 1,
                        "maxItems": 6,
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "push",
                            "whatsapp",
                            "sms",
                            "email"
                          ]
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "allowed_variables": {
                    "default": [],
                    "maxItems": 30,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string",
                          "pattern": "^[a-z][a-z0-9_]{0,40}$"
                        },
                        "source": {
                          "default": "payload",
                          "type": "string",
                          "enum": [
                            "payload",
                            "profile"
                          ]
                        },
                        "type": {
                          "default": "string",
                          "type": "string",
                          "enum": [
                            "string",
                            "number",
                            "datetime",
                            "url"
                          ]
                        },
                        "sensitive": {
                          "default": false,
                          "type": "boolean"
                        },
                        "required": {
                          "default": true,
                          "type": "boolean"
                        },
                        "profile_field": {
                          "anyOf": [
                            {
                              "type": "string",
                              "maxLength": 41
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "profile_field_fallback": {
                          "anyOf": [
                            {
                              "type": "string",
                              "maxLength": 41
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "subject": {
                          "anyOf": [
                            {
                              "type": "string",
                              "maxLength": 60
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "fallback": {
                          "anyOf": [
                            {
                              "type": "string",
                              "maxLength": 200
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "fallback_by_locale": {
                          "anyOf": [
                            {
                              "type": "object",
                              "propertyNames": {
                                "type": "string",
                                "minLength": 2,
                                "maxLength": 35
                              },
                              "additionalProperties": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 200
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "fallback_when": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "always",
                                "profile_incomplete"
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "name"
                      ]
                    }
                  }
                },
                "required": [
                  "key",
                  "category"
                ],
                "additionalProperties": false
              },
              "examples": {
                "lembrete": {
                  "value": {
                    "key": "appointment.reminder",
                    "category": "utility",
                    "content_class": "minimal",
                    "allowed_variables": [
                      {
                        "name": "recipient_first_name",
                        "source": "profile",
                        "profile_field": "first_name",
                        "profile_field_fallback": "display_name"
                      },
                      {
                        "name": "professional_name",
                        "source": "profile",
                        "profile_field": "display_name",
                        "subject": "party:professional"
                      },
                      {
                        "name": "appointment_at",
                        "source": "payload",
                        "type": "datetime"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "201": {
            "description": "template criado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateSummary"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Cria ou atualiza um template",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/templates \\\n  --request POST \\\n  --header 'content-type: application/json' \\\n  --data '{\n  \"key\": \"appointment.reminder\",\n  \"category\": \"utility\",\n  \"content_class\": \"minimal\",\n  \"allowed_variables\": [\n    {\n      \"name\": \"recipient_first_name\",\n      \"source\": \"profile\",\n      \"profile_field\": \"first_name\",\n      \"profile_field_fallback\": \"display_name\"\n    },\n    {\n      \"name\": \"professional_name\",\n      \"source\": \"profile\",\n      \"profile_field\": \"display_name\",\n      \"subject\": \"party:professional\"\n    },\n    {\n      \"name\": \"appointment_at\",\n      \"source\": \"payload\",\n      \"type\": \"datetime\"\n    }\n  ]\n}'"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/templates', {\n  method: 'POST',\n  headers: {\n    'content-type': 'application/json'\n  },\n  body: JSON.stringify({\n    key: 'appointment.reminder',\n    category: 'utility',\n    content_class: 'minimal',\n    allowed_variables: [\n      {\n        name: 'recipient_first_name',\n        source: 'profile',\n        profile_field: 'first_name',\n        profile_field_fallback: 'display_name'\n      },\n      {\n        name: 'professional_name',\n        source: 'profile',\n        profile_field: 'display_name',\n        subject: 'party:professional'\n      },\n      {\n        name: 'appointment_at',\n        source: 'payload',\n        type: 'datetime'\n      }\n    ]\n  })\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\nimport json\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\npayload = json.dumps({\n  \"key\": \"appointment.reminder\",\n  \"category\": \"utility\",\n  \"content_class\": \"minimal\",\n  \"allowed_variables\": [\n    {\n      \"name\": \"recipient_first_name\",\n      \"source\": \"profile\",\n      \"profile_field\": \"first_name\",\n      \"profile_field_fallback\": \"display_name\"\n    },\n    {\n      \"name\": \"professional_name\",\n      \"source\": \"profile\",\n      \"profile_field\": \"display_name\",\n      \"subject\": \"party:professional\"\n    },\n    {\n      \"name\": \"appointment_at\",\n      \"source\": \"payload\",\n      \"type\": \"datetime\"\n    }\n  ]\n})\nheaders = {\n  \"content-type\": \"application/json\"\n}\n\nconn.request(\n    \"POST\",\n    \"/v1/templates\",\n    body=payload,\n    headers=headers,\n)\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/templates', [\n  'headers' => [\n    'content-type' => 'application/json'\n  ],\n  'json' => [\n    'key' => 'appointment.reminder',\n    'category' => 'utility',\n    'content_class' => 'minimal',\n    'allowed_variables' => [\n      [\n        'name' => 'recipient_first_name',\n        'source' => 'profile',\n        'profile_field' => 'first_name',\n        'profile_field_fallback' => 'display_name'\n      ],\n      [\n        'name' => 'professional_name',\n        'source' => 'profile',\n        'profile_field' => 'display_name',\n        'subject' => 'party:professional'\n      ],\n      [\n        'name' => 'appointment_at',\n        'source' => 'payload',\n        'type' => 'datetime'\n      ]\n    ]\n  ]\n]);"
          }
        ]
      },
      "get": {
        "operationId": "getV1Templates",
        "summary": "Lista templates e versões ativas",
        "tags": [
          "templates"
        ],
        "description": "Lista templates e versões ativas.",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "templates",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TemplateListItem"
                  }
                },
                "examples": {
                  "exemplo": {
                    "summary": "Lista templates e versões ativas",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/templates"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/templates')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/v1/templates\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/v1/templates');"
          }
        ]
      }
    },
    "/v1/templates/{key}/versions": {
      "post": {
        "operationId": "postV1TemplatesKeyVersions",
        "summary": "Publica uma versão para um canal e locale",
        "tags": [
          "templates"
        ],
        "description": "Versão ativa é imutável: mudar texto cria versão nova e aposenta a anterior. Versão de WhatsApp\nexige `provider_bindings` apontando para o template já aprovado (Content SID na Twilio, nome do\ntemplate na Meta), e o `variable_map` precisa cobrir `{{1}}…{{n}}` sem buracos.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "channel": {
                    "type": "string",
                    "enum": [
                      "push",
                      "whatsapp",
                      "sms",
                      "email"
                    ]
                  },
                  "locale": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 35
                  },
                  "subject_icu": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 400
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "body_icu": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100000
                  },
                  "provider_bindings": {
                    "default": {},
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {}
                    }
                  },
                  "activate": {
                    "default": true,
                    "type": "boolean"
                  }
                },
                "required": [
                  "channel",
                  "locale",
                  "body_icu"
                ],
                "additionalProperties": false
              },
              "examples": {
                "whatsapp_pt_br": {
                  "value": {
                    "channel": "whatsapp",
                    "locale": "pt-BR",
                    "body_icu": "Olá {recipient_first_name}, sua consulta com {professional_name} é em {appointment_at, date, medium} às {appointment_at, time, short}.",
                    "provider_bindings": {
                      "twilio_whatsapp": {
                        "content_sid": "HX0123456789abcdef0123456789abcdef",
                        "variable_map": {
                          "1": "recipient_first_name",
                          "2": "professional_name",
                          "3": "appointment_at_date_local",
                          "4": "appointment_at_time_local"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "key",
            "required": true
          },
          {
            "$ref": "#/components/parameters/TemplateKey"
          }
        ],
        "responses": {
          "201": {
            "description": "versão publicada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateVersion"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Publica uma versão para um canal e locale",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/templates/example/versions \\\n  --request POST \\\n  --header 'content-type: application/json' \\\n  --data '{\n  \"channel\": \"whatsapp\",\n  \"locale\": \"pt-BR\",\n  \"body_icu\": \"Olá {recipient_first_name}, sua consulta com {professional_name} é em {appointment_at, date, medium} às {appointment_at, time, short}.\",\n  \"provider_bindings\": {\n    \"twilio_whatsapp\": {\n      \"content_sid\": \"HX0123456789abcdef0123456789abcdef\",\n      \"variable_map\": {\n        \"1\": \"recipient_first_name\",\n        \"2\": \"professional_name\",\n        \"3\": \"appointment_at_date_local\",\n        \"4\": \"appointment_at_time_local\"\n      }\n    }\n  }\n}'"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/templates/example/versions', {\n  method: 'POST',\n  headers: {\n    'content-type': 'application/json'\n  },\n  body: JSON.stringify({\n    channel: 'whatsapp',\n    locale: 'pt-BR',\n    body_icu: 'Olá {recipient_first_name}, sua consulta com {professional_name} é em {appointment_at, date, medium} às {appointment_at, time, short}.',\n    provider_bindings: {\n      twilio_whatsapp: {\n        content_sid: 'HX0123456789abcdef0123456789abcdef',\n        variable_map: {\n          '1': 'recipient_first_name',\n          '2': 'professional_name',\n          '3': 'appointment_at_date_local',\n          '4': 'appointment_at_time_local'\n        }\n      }\n    }\n  })\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\nimport json\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\npayload = json.dumps({\n  \"channel\": \"whatsapp\",\n  \"locale\": \"pt-BR\",\n  \"body_icu\": \"Olá {recipient_first_name}, sua consulta com {professional_name} é em {appointment_at, date, medium} às {appointment_at, time, short}.\",\n  \"provider_bindings\": {\n    \"twilio_whatsapp\": {\n      \"content_sid\": \"HX0123456789abcdef0123456789abcdef\",\n      \"variable_map\": {\n        \"1\": \"recipient_first_name\",\n        \"2\": \"professional_name\",\n        \"3\": \"appointment_at_date_local\",\n        \"4\": \"appointment_at_time_local\"\n      }\n    }\n  }\n})\nheaders = {\n  \"content-type\": \"application/json\"\n}\n\nconn.request(\n    \"POST\",\n    \"/v1/templates/example/versions\",\n    body=payload,\n    headers=headers,\n)\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/templates/example/versions', [\n  'headers' => [\n    'content-type' => 'application/json'\n  ],\n  'json' => [\n    'channel' => 'whatsapp',\n    'locale' => 'pt-BR',\n    'body_icu' => 'Olá {recipient_first_name}, sua consulta com {professional_name} é em {appointment_at, date, medium} às {appointment_at, time, short}.',\n    'provider_bindings' => [\n      'twilio_whatsapp' => [\n        'content_sid' => 'HX0123456789abcdef0123456789abcdef',\n        'variable_map' => [\n          '1' => 'recipient_first_name',\n          '2' => 'professional_name',\n          '3' => 'appointment_at_date_local',\n          '4' => 'appointment_at_time_local'\n        ]\n      ]\n    ]\n  ]\n]);"
          }
        ]
      }
    },
    "/v1/templates/{key}/retire": {
      "post": {
        "operationId": "retireSharedTemplate",
        "summary": "Retire shared template versions",
        "tags": [
          "Templates"
        ],
        "description": "Organization admin only. Stops future active-version resolution and preserves immutable version and delivery history. Repeating the operation has the same final state.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {},
                "additionalProperties": false
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "key",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Shared versions retired"
          },
          "403": {
            "description": "Organization admin required"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/templates/example/retire \\\n  --request POST"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/templates/example/retire', {\n  method: 'POST'\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"POST\", \"/v1/templates/example/retire\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/templates/example/retire');"
          }
        ]
      }
    },
    "/v1/templates/{key}/preview": {
      "post": {
        "operationId": "postV1TemplatesKeyPreview",
        "summary": "Pré-visualiza a renderização",
        "tags": [
          "templates"
        ],
        "description": "Mesma renderização do envio, com avisos operacionais (contagem de segmentos de SMS, locale sem\nversão ativa, binding ausente) e os parâmetros posicionais que iriam para cada provider.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "channel": {
                    "type": "string",
                    "enum": [
                      "push",
                      "whatsapp",
                      "sms",
                      "email"
                    ]
                  },
                  "locale": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 35
                  },
                  "timezone": {
                    "default": "America/Sao_Paulo",
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 64
                  },
                  "variables": {
                    "default": {},
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  },
                  "identity_values": {
                    "default": {},
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "channel",
                  "locale"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "key",
            "required": true
          },
          {
            "$ref": "#/components/parameters/TemplateKey"
          }
        ],
        "responses": {
          "200": {
            "description": "pré-visualização",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PreviewResponse"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Pré-visualiza a renderização",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/templates/example/preview \\\n  --request POST"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/templates/example/preview', {\n  method: 'POST'\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"POST\", \"/v1/templates/example/preview\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/templates/example/preview');"
          }
        ]
      }
    },
    "/v1/tenants": {
      "get": {
        "operationId": "getV1Tenants",
        "summary": "Tenants da organização",
        "tags": [
          "conformidade"
        ],
        "description": "O que a chave pode endereçar em `X-Anam-Tenant`. Uma organização não vê tenant de outra. Cada item traz\n`external_ref`, o `id` interno e o valor pronto de header em `tenant_header`.\n",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "tenants da organização",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "organization_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "key_scope": {
                      "type": "string",
                      "enum": [
                        "organization",
                        "tenant"
                      ]
                    },
                    "tenants": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "external_ref": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "example": "CRP-06/123456",
                            "description": "A sua referência do profissional. É o que vai no header, na forma `ref:<valor>`."
                          },
                          "slug": {
                            "type": "string",
                            "example": "psi-helena"
                          },
                          "name": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "active",
                              "suspended"
                            ]
                          },
                          "tenant_header": {
                            "type": "string",
                            "example": "ref:CRP-06/123456",
                            "description": "Valor pronto para o header, já na forma recomendada."
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/tenants"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/tenants')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/v1/tenants\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/v1/tenants');"
          }
        ]
      },
      "post": {
        "operationId": "postV1Tenants",
        "summary": "Provisiona um tenant (um profissional) na organização",
        "tags": [
          "conformidade"
        ],
        "description": "Exige escopo `admin`. `external_ref` é **o identificador que você já usa** para o profissional; é por ele\nque o tenant é endereçado depois, sem você precisar guardar e sincronizar um id nosso. Único por\norganização, não globalmente: duas organizações podem usar o mesmo código.\n\n`slug` é opcional e derivado do `external_ref` com o prefixo da organização quando omitido, porque slug é\núnico globalmente.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "external_ref": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "slug": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 60,
                        "pattern": "^[a-z0-9-]+$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "name": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "settings": {
                    "anyOf": [
                      {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {}
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "external_ref"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "201": {
            "description": "tenant provisionado",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "external_ref": {
                      "type": "string"
                    },
                    "slug": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "tenant_header": {
                      "type": "string",
                      "example": "ref:CRP-06/123456"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "escopo insuficiente",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "`tenant_ref_conflict` — esta organização já usa essa referência externa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/tenants \\\n  --request POST"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/tenants', {\n  method: 'POST'\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"POST\", \"/v1/tenants\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/tenants');"
          }
        ]
      }
    },
    "/v1/tenants/{tenantRef}": {
      "put": {
        "operationId": "putV1TenantsTenantRef",
        "summary": "Define ou corrige a referência externa de um tenant",
        "tags": [
          "conformidade"
        ],
        "description": "Exige escopo `admin`. `tenantRef` no caminho segue a mesma regra do header: prefixo explícito\n(`ref:`, `id:` ou `slug:`).\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "external_ref": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "name": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "tenantRef",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "slug:psi-helena"
          }
        ],
        "responses": {
          "200": {
            "description": "tenant atualizado",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "external_ref": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "slug": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "tenant_header": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/tenants/slug%3Apsi-helena \\\n  --request PUT"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/tenants/slug%3Apsi-helena', {\n  method: 'PUT'\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"PUT\", \"/v1/tenants/slug%3Apsi-helena\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('PUT', 'http://localhost:47311/v1/tenants/slug%3Apsi-helena');"
          }
        ]
      }
    },
    "/v1/settings": {
      "get": {
        "operationId": "getV1Settings",
        "summary": "Configuração efetiva do tenant, com procedência",
        "tags": [
          "configuração"
        ],
        "description": "Valor efetivo de cada configuração e **de onde ele veio**. A organização define o default e pode travar\num subconjunto; o tenant sobrepõe o que não estiver travado.\n\nA procedência existe para depuração: sem ela, descobrir por que um lembrete saiu num horário exige\nadivinhar se o valor veio da organização, de um travamento ou do próprio tenant.\n",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "configuração efetiva",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EffectiveSettings"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Configuração efetiva do tenant, com procedência",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "description": "chave de organização sem `X-Anam-Tenant`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/settings"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/settings')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/v1/settings\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/v1/settings');"
          }
        ]
      },
      "put": {
        "operationId": "putV1Settings",
        "summary": "Sobreposições do tenant",
        "tags": [
          "configuração"
        ],
        "description": "Mescla chave por chave. Chave travada pela organização é **recusada** com `403`\n`setting_locked_by_organization`, não silenciosamente ignorada. Use `clear` para abrir mão de uma\nsobreposição e voltar a herdar.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "settings": {
                    "anyOf": [
                      {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {}
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "clear": {
                    "anyOf": [
                      {
                        "maxItems": 30,
                        "type": "array",
                        "items": {
                          "type": "string",
                          "maxLength": 60
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "additionalProperties": false
              },
              "examples": {
                "janela_propria": {
                  "value": {
                    "settings": {
                      "defaultQuietHours": {
                        "start": "23:00",
                        "end": "07:00"
                      }
                    }
                  }
                },
                "voltar_a_herdar": {
                  "value": {
                    "clear": [
                      "defaultQuietHours"
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "sobreposições atualizadas",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "overrides": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  }
                },
                "examples": {
                  "exemplo": {
                    "summary": "Sobreposições do tenant",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "a organização travou a configuração",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/settings \\\n  --request PUT \\\n  --header 'content-type: application/json' \\\n  --data '{\n  \"settings\": {\n    \"defaultQuietHours\": {\n      \"start\": \"23:00\",\n      \"end\": \"07:00\"\n    }\n  }\n}'"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/settings', {\n  method: 'PUT',\n  headers: {\n    'content-type': 'application/json'\n  },\n  body: JSON.stringify({\n    settings: {\n      defaultQuietHours: {\n        start: '23:00',\n        end: '07:00'\n      }\n    }\n  })\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\nimport json\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\npayload = json.dumps({\n  \"settings\": {\n    \"defaultQuietHours\": {\n      \"start\": \"23:00\",\n      \"end\": \"07:00\"\n    }\n  }\n})\nheaders = {\n  \"content-type\": \"application/json\"\n}\n\nconn.request(\n    \"PUT\",\n    \"/v1/settings\",\n    body=payload,\n    headers=headers,\n)\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('PUT', 'http://localhost:47311/v1/settings', [\n  'headers' => [\n    'content-type' => 'application/json'\n  ],\n  'json' => [\n    'settings' => [\n      'defaultQuietHours' => [\n        'start' => '23:00',\n        'end' => '07:00'\n      ]\n    ]\n  ]\n]);"
          }
        ]
      }
    },
    "/v1/settings/catalogue": {
      "get": {
        "operationId": "getV1SettingsCatalogue",
        "summary": "Catálogo de configurações, com natureza e o que dá para travar",
        "tags": [
          "configuração"
        ],
        "description": "`preference` é preferência do profissional e nunca pode ser travada. `policy` é decisão da organização —\nconformidade e custo — e pode ser travada.\n",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "catálogo",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "settings": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "key": {
                            "type": "string"
                          },
                          "nature": {
                            "type": "string",
                            "enum": [
                              "preference",
                              "policy"
                            ]
                          },
                          "lockable": {
                            "type": "boolean"
                          },
                          "why": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                },
                "examples": {
                  "exemplo": {
                    "summary": "Catálogo de configurações, com natureza e o que dá para travar",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/settings/catalogue"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/settings/catalogue')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/v1/settings/catalogue\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/v1/settings/catalogue');"
          }
        ]
      }
    },
    "/v1/organizations/settings": {
      "put": {
        "operationId": "putV1OrganizationsSettings",
        "summary": "Default da organização, numa operação",
        "tags": [
          "configuração"
        ],
        "description": "Exige escopo `admin`. Muda o default para **todos** os tenants da organização sem materializar nada por\ntenant — é o que faz ajustar política de 700 profissionais ser uma chamada, e não um laço.\n\n`settings` é mesclada chave por chave. `locked` é a lista completa de chaves travadas; travar chave de\nnatureza `preference` é recusado com `422 setting_not_lockable`.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "settings": {
                    "anyOf": [
                      {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {}
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "locked": {
                    "anyOf": [
                      {
                        "maxItems": 30,
                        "type": "array",
                        "items": {
                          "type": "string",
                          "maxLength": 60
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "additionalProperties": false
              },
              "examples": {
                "politica_de_margem": {
                  "summary": "Travar a ordenação da cadeia, que é decisão de margem",
                  "value": {
                    "settings": {
                      "defaultChannelChain": {
                        "utility": [
                          "push",
                          "whatsapp",
                          "sms"
                        ]
                      },
                      "rateLimit": {
                        "organizationCapacity": 600,
                        "organizationRefillPerSecond": 20
                      }
                    },
                    "locked": [
                      "defaultChannelChain",
                      "rateLimit"
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "default atualizado",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "settings": {
                      "type": "object",
                      "additionalProperties": true
                    },
                    "locked": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "applies_to": {
                      "type": "string"
                    }
                  }
                },
                "examples": {
                  "exemplo": {
                    "summary": "Default da organização, numa operação",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "escopo insuficiente",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/organizations/settings \\\n  --request PUT \\\n  --header 'content-type: application/json' \\\n  --data '{\n  \"settings\": {\n    \"defaultChannelChain\": {\n      \"utility\": [\n        \"push\",\n        \"whatsapp\",\n        \"sms\"\n      ]\n    },\n    \"rateLimit\": {\n      \"organizationCapacity\": 600,\n      \"organizationRefillPerSecond\": 20\n    }\n  },\n  \"locked\": [\n    \"defaultChannelChain\",\n    \"rateLimit\"\n  ]\n}'"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/organizations/settings', {\n  method: 'PUT',\n  headers: {\n    'content-type': 'application/json'\n  },\n  body: JSON.stringify({\n    settings: {\n      defaultChannelChain: {\n        utility: ['push', 'whatsapp', 'sms']\n      },\n      rateLimit: {\n        organizationCapacity: 600,\n        organizationRefillPerSecond: 20\n      }\n    },\n    locked: ['defaultChannelChain', 'rateLimit']\n  })\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\nimport json\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\npayload = json.dumps({\n  \"settings\": {\n    \"defaultChannelChain\": {\n      \"utility\": [\n        \"push\",\n        \"whatsapp\",\n        \"sms\"\n      ]\n    },\n    \"rateLimit\": {\n      \"organizationCapacity\": 600,\n      \"organizationRefillPerSecond\": 20\n    }\n  },\n  \"locked\": [\n    \"defaultChannelChain\",\n    \"rateLimit\"\n  ]\n})\nheaders = {\n  \"content-type\": \"application/json\"\n}\n\nconn.request(\n    \"PUT\",\n    \"/v1/organizations/settings\",\n    body=payload,\n    headers=headers,\n)\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('PUT', 'http://localhost:47311/v1/organizations/settings', [\n  'headers' => [\n    'content-type' => 'application/json'\n  ],\n  'json' => [\n    'settings' => [\n      'defaultChannelChain' => [\n        'utility' => [\n          'push',\n          'whatsapp',\n          'sms'\n        ]\n      ],\n      'rateLimit' => [\n        'organizationCapacity' => 600,\n        'organizationRefillPerSecond' => 20\n      ]\n    ],\n    'locked' => [\n      'defaultChannelChain',\n      'rateLimit'\n    ]\n  ]\n]);"
          }
        ]
      }
    },
    "/v1/compliance/transfers": {
      "get": {
        "operationId": "getV1ComplianceTransfers",
        "summary": "Mapa de transferência internacional do tenant",
        "tags": [
          "conformidade"
        ],
        "description": "Quem recebe dado, em que jurisdição, com quais instrumentos assinados e o que falta. Existe porque\na verificação é obrigação do controlador (art. 4º do Regulamento de Transferência Internacional da\nANPD) e, num SaaS de saúde, o controlador é o profissional — que não consegue montá-la sozinho.\n",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "mapa de transferência",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransferReport"
                },
                "examples": {
                  "exemplo": {
                    "summary": "Mapa de transferência internacional do tenant",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/compliance/transfers"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/compliance/transfers')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/v1/compliance/transfers\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/v1/compliance/transfers');"
          }
        ]
      }
    },
    "/v1/providers/{providerId}/credentials": {
      "put": {
        "operationId": "putV1ProvidersProviderIdCredentials",
        "summary": "Registra credencial de provider e os instrumentos de transferência",
        "tags": [
          "conformidade"
        ],
        "description": "Exige escopo `admin`. Habilitar um provider fora do Brasil e do EEE sem os instrumentos assinados é\nrecusado com `403 transfer_safeguards_missing` em produção: fornecedor americano exige DPA, as\ncláusulas-padrão do Anexo II da ANPD **e** as cláusulas-tipo da UE — mecanismos distintos, e nenhum\nsubstitui o outro.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "config": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  },
                  "enabled": {
                    "default": true,
                    "type": "boolean"
                  },
                  "processor_jurisdiction": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "BR",
                          "EU",
                          "US",
                          "OTHER"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "transfer_safeguards": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "dpa": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "anpd_annex_ii": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "eu_scc": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "importer_entity": {
                            "anyOf": [
                              {
                                "type": "string",
                                "maxLength": 200
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "notes": {
                            "anyOf": [
                              {
                                "type": "string",
                                "maxLength": 1000
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "config"
                ],
                "additionalProperties": false
              },
              "examples": {
                "twilio_com_instrumentos": {
                  "value": {
                    "config": {
                      "account_sid": "AC…",
                      "auth_token": "…",
                      "messaging_service_sid": "MG…"
                    },
                    "processor_jurisdiction": "US",
                    "transfer_safeguards": {
                      "dpa": "2026-03-01",
                      "anpd_annex_ii": "2026-03-05",
                      "eu_scc": "2026-03-05",
                      "importer_entity": "Twilio Inc."
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "providerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "twilio_whatsapp"
          }
        ],
        "responses": {
          "200": {
            "description": "credencial registrada, com a avaliação da transferência",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransferAssessment"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "escopo insuficiente ou instrumentos de transferência faltando",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "faltam_instrumentos": {
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "o provider twilio_whatsapp trata dados em US e faltam instrumentos contratuais: …",
                        "detail": {
                          "failure_code": "transfer_safeguards_missing",
                          "provider_id": "twilio_whatsapp",
                          "jurisdiction": "US",
                          "missing": [
                            "anpd_annex_ii",
                            "eu_scc"
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/providers/twilio_whatsapp/credentials \\\n  --request PUT \\\n  --header 'content-type: application/json' \\\n  --data '{\n  \"config\": {\n    \"account_sid\": \"AC…\",\n    \"auth_token\": \"…\",\n    \"messaging_service_sid\": \"MG…\"\n  },\n  \"processor_jurisdiction\": \"US\",\n  \"transfer_safeguards\": {\n    \"dpa\": \"2026-03-01\",\n    \"anpd_annex_ii\": \"2026-03-05\",\n    \"eu_scc\": \"2026-03-05\",\n    \"importer_entity\": \"Twilio Inc.\"\n  }\n}'"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/providers/twilio_whatsapp/credentials', {\n  method: 'PUT',\n  headers: {\n    'content-type': 'application/json'\n  },\n  body: JSON.stringify({\n    config: {\n      account_sid: 'AC…',\n      auth_token: '…',\n      messaging_service_sid: 'MG…'\n    },\n    processor_jurisdiction: 'US',\n    transfer_safeguards: {\n      dpa: '2026-03-01',\n      anpd_annex_ii: '2026-03-05',\n      eu_scc: '2026-03-05',\n      importer_entity: 'Twilio Inc.'\n    }\n  })\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\nimport json\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\npayload = json.dumps({\n  \"config\": {\n    \"account_sid\": \"AC…\",\n    \"auth_token\": \"…\",\n    \"messaging_service_sid\": \"MG…\"\n  },\n  \"processor_jurisdiction\": \"US\",\n  \"transfer_safeguards\": {\n    \"dpa\": \"2026-03-01\",\n    \"anpd_annex_ii\": \"2026-03-05\",\n    \"eu_scc\": \"2026-03-05\",\n    \"importer_entity\": \"Twilio Inc.\"\n  }\n})\nheaders = {\n  \"content-type\": \"application/json\"\n}\n\nconn.request(\n    \"PUT\",\n    \"/v1/providers/twilio_whatsapp/credentials\",\n    body=payload,\n    headers=headers,\n)\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('PUT', 'http://localhost:47311/v1/providers/twilio_whatsapp/credentials', [\n  'headers' => [\n    'content-type' => 'application/json'\n  ],\n  'json' => [\n    'config' => [\n      'account_sid' => 'AC…',\n      'auth_token' => '…',\n      'messaging_service_sid' => 'MG…'\n    ],\n    'processor_jurisdiction' => 'US',\n    'transfer_safeguards' => [\n      'dpa' => '2026-03-01',\n      'anpd_annex_ii' => '2026-03-05',\n      'eu_scc' => '2026-03-05',\n      'importer_entity' => 'Twilio Inc.'\n    ]\n  ]\n]);"
          }
        ]
      }
    },
    "/v1/dlq": {
      "get": {
        "operationId": "getV1Dlq",
        "summary": "Itens na fila de mensagens mortas",
        "tags": [
          "operação"
        ],
        "description": "Itens na fila de mensagens mortas.",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "itens aguardando reprocessamento",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DeadLetter"
                  }
                },
                "examples": {
                  "exemplo": {
                    "summary": "Itens na fila de mensagens mortas",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/dlq"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/dlq')"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"GET\", \"/v1/dlq\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('GET', 'http://localhost:47311/v1/dlq');"
          }
        ]
      }
    },
    "/v1/dlq/{id}/replay": {
      "post": {
        "operationId": "postV1DlqIdReplay",
        "summary": "Reprocessa um item da DLQ",
        "tags": [
          "operação"
        ],
        "description": "Revive também a mensagem que estava em estado terminal; sem isso o reprocessamento não teria efeito.",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "reenfileirado",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "replayed": {
                      "type": "boolean",
                      "const": true
                    },
                    "job_id": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uuid"
                    }
                  }
                },
                "examples": {
                  "exemplo": {
                    "summary": "Reprocessa um item da DLQ",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        },
        "x-codeSamples": [
          {
            "lang": "shell",
            "label": "curl",
            "source": "curl http://localhost:47311/v1/dlq/example/replay \\\n  --request POST"
          },
          {
            "lang": "node",
            "label": "undici",
            "source": "import { request } from 'undici'\n\nconst { statusCode, body } = await request('http://localhost:47311/v1/dlq/example/replay', {\n  method: 'POST'\n})"
          },
          {
            "lang": "python",
            "label": "python3",
            "source": "import http.client\n\nconn = http.client.HTTPConnection(\"localhost:47311\")\n\nconn.request(\"POST\", \"/v1/dlq/example/replay\")\n\nresponse = conn.getresponse()\nprint(response.read().decode())\n\nconn.close()"
          },
          {
            "lang": "php",
            "label": "guzzle",
            "source": "$client = new GuzzleHttp\\Client();\n\n$response = $client->request('POST', 'http://localhost:47311/v1/dlq/example/replay');"
          }
        ]
      }
    }
  },
  "servers": [
    {
      "url": "/",
      "description": "origem desta página"
    },
    {
      "url": "http://localhost:47311",
      "description": "desenvolvimento local (docker compose ou pnpm run dev)"
    },
    {
      "url": "https://svc.notifications.anaeme.app",
      "description": "homologação (staging). Callbacks usam este nome, igual a PUBLIC_BASE_URL."
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "tags": [
    {
      "name": "mensagens",
      "description": "envio, agendamento, reagendamento e cancelamento"
    },
    {
      "name": "destinatários",
      "description": "cadastro, preferências, consentimento e histórico"
    },
    {
      "name": "templates",
      "description": "templates versionados por canal e locale"
    },
    {
      "name": "configuração",
      "description": "herança de configuração entre organização e tenant"
    },
    {
      "name": "conformidade",
      "description": "transferência internacional e credenciais de provider"
    },
    {
      "name": "central de notificações",
      "description": "inbox nativa, grants curtos e Web Push"
    },
    {
      "name": "operação",
      "description": "DLQ, saúde, contrato e página de referência"
    }
  ],
  "x-tagGroups": [
    {
      "name": "Entrega",
      "tags": [
        "mensagens",
        "destinatários",
        "templates"
      ]
    },
    {
      "name": "Conta",
      "tags": [
        "configuração",
        "conformidade"
      ]
    },
    {
      "name": "Caixa de entrada",
      "tags": [
        "central de notificações"
      ]
    },
    {
      "name": "Plataforma",
      "tags": [
        "operação"
      ]
    }
  ],
  "webhooks": {
    "messageEvent": {
      "post": {
        "summary": "Evento de entrega enviado ao cliente",
        "description": "Gravado no mesmo commit que mudou o estado (outbox transacional) e entregue por um worker separado.\n\nO endpoint pertence à **organização** e recebe os eventos de todos os tenants dela; o campo\n`tenant` diz de qual. Um endpoint, não um por profissional.\n\n**Verificação:** HMAC-SHA256 sobre `\"{timestamp}.{corpo bruto}\"`, com o segredo do endpoint.\nRecuse timestamp fora de ±5 minutos (proteção de replay). Durante rotação, dois segredos são\naceitos.\n\n**Entrega é at-least-once e não ordenada.** Deduplique por `x-anam-event-id` e aplique\nlast-write-wins por `message_id`.\n",
        "parameters": [
          {
            "name": "x-anam-event-id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Estável entre reentregas. É a chave de dedup do consumidor."
          },
          {
            "name": "x-anam-event-type",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-anam-tenant",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "ref:CRP-06/123456",
            "description": "Mesma forma prefixada aceita na entrada, para o evento poder ser devolvido ao tenant certo\nsem tradução. Igual a `tenant` no corpo.\n"
          },
          {
            "name": "x-anam-timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-anam-signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "t=1790000000,v1=9f86d0818884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a0"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "id",
                  "type",
                  "occurred_at",
                  "tenant",
                  "data"
                ],
                "properties": {
                  "id": {
                    "type": "string",
                    "description": "Igual ao header `x-anam-event-id`."
                  },
                  "tenant": {
                    "type": "object",
                    "description": "De qual tenant é o evento. O endpoint é registrado na organização e recebe os eventos de\ntodos os tenants dela, então roteie por este campo — não por ter um endpoint por profissional.\n",
                    "required": [
                      "id",
                      "external_ref"
                    ],
                    "properties": {
                      "id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "external_ref": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "description": "A referência do integrador. `null` só em tenant provisionado antes dela existir."
                      }
                    }
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "message.accepted",
                      "message.scheduled",
                      "message.rescheduled",
                      "message.cancelled",
                      "message.sent",
                      "message.delivered",
                      "message.read",
                      "message.failed",
                      "message.suppressed",
                      "recipient.opted_out"
                    ]
                  },
                  "occurred_at": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "data": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              },
              "examples": {
                "falha_permanente": {
                  "value": {
                    "id": "evt_01JD7M9K2P",
                    "type": "message.failed",
                    "occurred_at": "2026-10-01T13:00:04Z",
                    "tenant": {
                      "id": "22bb7808-31d5-474b-9ca5-997bef1da71c",
                      "external_ref": "CRP-06/123456"
                    },
                    "data": {
                      "message_id": "8f14e45f-ceea-467a-9f6a-1f1bb0d9d0ff",
                      "recipient_external_ref": "patient_77",
                      "channel": "whatsapp",
                      "provider": "twilio_whatsapp",
                      "error": {
                        "class": "permanent",
                        "code": "63024",
                        "message": "invalid recipient"
                      },
                      "source": {
                        "system": "anam-calendar",
                        "event_id": "evt_8f2c",
                        "event_version": 7
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Responda 2xx para confirmar. Qualquer outra resposta faz o serviço reentregar com backoff."
          }
        }
      }
    }
  }
}
