{
  "openapi": "3.1.0",
  "jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
  "info": {
    "title": "BORA Transport API",
    "version": "1.0.9",
    "summary": "Autenticação pela palma para catracas de transporte (BORA for Transport).",
    "contact": {
      "name": "BORA",
      "url": "https://bora.id"
    },
    "description": "API do BORA Access, prova de conceito. Documentação: https://docs.bora.id/pt/api/access/ (tudo em Markdown em https://docs.bora.id/pt/llms-full.txt).\n\n## Autenticação\n\nTodo endpoint usa `Authorization: Bearer <API key>`, no formato `bora_<live|test>_<key_id>_<secret>`. Cada API key pertence a uma organização (a conta da sua empresa na BORA); usuários, aparelhos, keys e passagens ficam separados por organização. Cada endpoint diz o escopo que precisa.\n\n## Como o produto funciona\n\nO BORA ACCESS GATE 01 fica na catraca, reconhece a palma offline e manda a passagem pelo cabo USB ao Validator\nDevice da operadora. O Validator Device decide (saldo, bloqueio, categoria) e libera a catraca. O cadastro da palma\nacontece uma vez, no BORA ACCESS TOTEM 01 (o Enrollment Totem). A BORA API guarda os cadastros, mantém a base de\npalmas dos aparelhos e guarda as passagens para conciliação. Todos os dados são criptografados em trânsito e em\nrepouso.\n\n## Identificadores\n\n- `subject_id`: id do usuário, gerado pela BORA.\n- `external_ref`: a chave do usuário no seu sistema, no formato da sua organização (numérico por padrão, o CPF do\n  usuário ou um padrão combinado com a BORA). Única na sua organização.\n- `cpf`: opcional. Evita cadastro duplicado. Só os 11 dígitos, sem pontuação. Entra só no corpo do\n  `POST /v1/subjects`, fica criptografado e não volta nas respostas.\n- `subject_ref`: pseudônimo do usuário que aparece nas passagens.\n- `onboard_ref`: opcional, uma referência sua que volta nas passagens aceitas.\n- `device_id`: id do aparelho; começa com `gate-` (catraca) ou `totem-` (Enrollment Totem).\n- `verdict_id`: id da passagem.\n\n## Tempo\n\nRFC 3339 em UTC com milissegundos (`2026-10-01T10:20:00.840Z`).\n\n## Erros\n\nRFC 9457 (`application/problem+json`) com `code` estável. Trate pelo `code`; o `detail` é para humanos e pode\nmudar.\n\n## Versionamento\n\nVersão maior no caminho (`/v1`). Dentro do v1 só entram mudanças aditivas: campo novo, rota nova, valor novo\nde enum. Ignore campos desconhecidos. Uma mudança que quebra vai para `/v2`, anunciada com pelo menos 12 meses de\nantecedência.\n\n## Limites de taxa\n\n| quem | limite |\n|---|---|\n| API key, leitura | 100 req/s, rajada 200 |\n| API key, escrita | 20 req/s, rajada 40 |\n| `POST /v1/enrollment-sessions` | 60 por minuto por organização |\n\nAs respostas trazem `RateLimit-Limit`, `RateLimit-Remaining` e `RateLimit-Reset`; o `429` traz `Retry-After`.\n\n## LGPD\n\nNenhuma rota recebe ou devolve imagem da mão. O CPF só entra, nunca sai. Todos os dados são criptografados em\ntrânsito e em repouso. O que passa do prazo de retenção é apagado de fato.\n"
  },
  "externalDocs": {
    "description": "Referência da API do BORA Access",
    "url": "https://docs.bora.id/pt/api/access/"
  },
  "servers": [
    {
      "url": "https://api.bora.id",
      "description": "Produção (proposta)"
    },
    {
      "url": "http://127.0.0.1:8710",
      "description": "Servidor de referência local (FastAPI)"
    }
  ],
  "tags": [
    {
      "name": "Health",
      "description": "Estado do serviço. Público."
    },
    {
      "name": "Subjects",
      "description": "Usuários, identificados pelo `external_ref`, a chave do usuário no seu sistema."
    },
    {
      "name": "Enrollment sessions",
      "description": "Abre o cadastro da palma no Enrollment Totem e acompanha o resultado."
    },
    {
      "name": "Devices",
      "description": "Aparelhos da sua organização: BORA ACCESS GATE 01 na catraca e BORA ACCESS TOTEM 01 no cadastro."
    },
    {
      "name": "Verdicts",
      "description": "Passagens com prova assinada, para conciliar com o seu backend."
    },
    {
      "name": "Mail",
      "description": "Mailbox: registros entre a BORA e os aparelhos, levados pelo seu backend e pelo Validator Device."
    }
  ],
  "x-tagGroups": [
    {
      "name": "Público",
      "tags": [
        "Health"
      ]
    },
    {
      "name": "Parceiro",
      "tags": [
        "Subjects",
        "Enrollment sessions",
        "Devices",
        "Mail",
        "Verdicts"
      ]
    }
  ],
  "security": [],
  "paths": {
    "/v1/health": {
      "get": {
        "tags": [
          "Health"
        ],
        "operationId": "getHealth",
        "x-bora-poc": true,
        "summary": "Estado do serviço",
        "security": [],
        "responses": {
          "200": {
            "description": "Serviço no ar.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "Bora-Server-Time": {
                "$ref": "#/components/headers/Bora-Server-Time"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                },
                "examples": {
                  "ok": {
                    "value": {
                      "status": "ok",
                      "api_version": "v1",
                      "contract_version": "1.0.9",
                      "server_time": "2026-10-01T10:20:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/v1/subjects": {
      "get": {
        "tags": [
          "Subjects"
        ],
        "operationId": "listSubjects",
        "x-bora-poc": true,
        "summary": "Listar usuários",
        "description": "Com `external_ref`, devolve 0 ou 1 usuário. Se a chave da sua organização é o CPF, use `POST\n/v1/subjects/search`, porque o CPF não vai na URL.",
        "security": [
          {
            "PartnerApiKey": [
              "subjects:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "external_ref",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/ExternalRef"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/SubjectStatus"
            }
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Página de usuários.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubjectPage"
                },
                "examples": {
                  "busca": {
                    "value": {
                      "data": [
                        {
                          "subject_id": "3f6c2a9e-8b1d-4e7a-9c3f-5d2e1a0b7c64",
                          "external_ref": "000482913",
                          "subject_ref": "2a16ce69bc964deda2b740bfe43edf4b",
                          "onboard_ref": "obr-7Q2m9X",
                          "status": "active",
                          "block": null,
                          "enrollment": {
                            "hands": [
                              "L",
                              "R"
                            ],
                            "model_id": "bora-palm-ir-v1",
                            "enrolled_at": "2026-10-01T10:02:41.120Z"
                          },
                          "gallery_seq": 15873,
                          "created_at": "2026-10-01T09:55:00.000Z",
                          "updated_at": "2026-10-01T10:02:41.120Z",
                          "livemode": true
                        }
                      ],
                      "has_more": false,
                      "next_cursor": null
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "410": {
            "$ref": "#/components/responses/Gone"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "tags": [
          "Subjects"
        ],
        "operationId": "createSubject",
        "x-bora-poc": true,
        "summary": "Criar usuário",
        "description": "Cria o usuário, ainda sem palma (status `pending_enrollment`). Identifique o usuário pelo\n`external_ref`, a chave dele no seu sistema, no formato da sua organização. O `cpf` é opcional. O\ncadastro da palma vem depois, em `POST /v1/enrollment-sessions`.",
        "security": [
          {
            "PartnerApiKey": [
              "subjects:write"
            ]
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/ClientRequestId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubjectCreate"
              },
              "examples": {
                "minimo": {
                  "summary": "Só o ID da conta do cliente",
                  "value": {
                    "external_ref": "000482913"
                  }
                },
                "com_cpf": {
                  "summary": "Com CPF e onboard_ref",
                  "value": {
                    "external_ref": "000482913",
                    "cpf": "52998224725",
                    "onboard_ref": "obr-7Q2m9X"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Usuário criado.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "Location": {
                "$ref": "#/components/headers/Location"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Subject"
                },
                "examples": {
                  "criado": {
                    "$ref": "#/components/examples/SubjectPending"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/v1/subjects/search": {
      "post": {
        "tags": [
          "Subjects"
        ],
        "operationId": "searchSubjects",
        "x-bora-poc": true,
        "summary": "Buscar usuário",
        "description": "Mesma busca do `GET /v1/subjects?external_ref=`, com o valor no corpo da request. Use quando a chave da\nsua organização é o CPF. Devolve 0 ou 1 usuário.",
        "security": [
          {
            "PartnerApiKey": [
              "subjects:read"
            ]
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/ClientRequestId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubjectSearch"
              },
              "examples": {
                "busca": {
                  "value": {
                    "external_ref": "000482913"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "0 ou 1 usuário.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubjectPage"
                },
                "examples": {
                  "vazio": {
                    "value": {
                      "data": [],
                      "has_more": false,
                      "next_cursor": null
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/v1/subjects/{subject_id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/SubjectId"
        }
      ],
      "get": {
        "tags": [
          "Subjects"
        ],
        "operationId": "getSubject",
        "x-bora-poc": true,
        "summary": "Consultar usuário",
        "security": [
          {
            "PartnerApiKey": [
              "subjects:read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "O usuário.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Subject"
                },
                "examples": {
                  "ativo": {
                    "$ref": "#/components/examples/SubjectActive"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/enrollment-sessions": {
      "post": {
        "tags": [
          "Enrollment sessions"
        ],
        "operationId": "createEnrollmentSession",
        "x-bora-poc": true,
        "summary": "Abrir cadastro",
        "description": "Abre o cadastro da palma de um usuário já criado. Devolve o `qr_payload`, que o ABT app mostra como QR\ncode, e o `short_code`, para digitar no Enrollment Totem. No Totem, o passageiro aceita o consentimento\nna tela e apoia as palmas; o consentimento fica registrado sozinho. Limite: 60 cadastros abertos por\nminuto por organização.",
        "security": [
          {
            "PartnerApiKey": [
              "subjects:write"
            ]
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EnrollmentSessionCreate"
              },
              "examples": {
                "duas_maos": {
                  "value": {
                    "subject_id": "3f6c2a9e-8b1d-4e7a-9c3f-5d2e1a0b7c64",
                    "hands_required": [
                      "L",
                      "R"
                    ],
                    "expires_in_s": 300
                  }
                },
                "por_external_ref": {
                  "value": {
                    "external_ref": "000482913",
                    "hands_required": [
                      "L",
                      "R"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Cadastro aberto.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "Location": {
                "$ref": "#/components/headers/Location"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnrollmentSession"
                },
                "examples": {
                  "aberta": {
                    "$ref": "#/components/examples/EnrollmentSessionOpen"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/enrollment-sessions/{session_id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/SessionId"
        }
      ],
      "get": {
        "tags": [
          "Enrollment sessions"
        ],
        "operationId": "getEnrollmentSession",
        "x-bora-poc": true,
        "summary": "Consultar cadastro",
        "description": "Estado do cadastro. Se a captura não deu certo, `failure_code` vem como `capture_rejected`: abra um\ncadastro novo.",
        "security": [
          {
            "PartnerApiKey": [
              "subjects:read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Estado do cadastro.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnrollmentSession"
                },
                "examples": {
                  "concluida": {
                    "$ref": "#/components/examples/EnrollmentSessionCompleted"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/devices": {
      "get": {
        "tags": [
          "Devices"
        ],
        "operationId": "listDevices",
        "x-bora-poc": true,
        "summary": "Listar aparelhos",
        "security": [
          {
            "PartnerApiKey": [
              "devices:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/DeviceStatus"
            }
          },
          {
            "name": "gate_id",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/AsciiRef"
            }
          },
          {
            "name": "kind",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/DeviceKind"
            }
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Página de aparelhos.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DevicePage"
                },
                "examples": {
                  "um_aparelho": {
                    "value": {
                      "data": [
                        {
                          "device_id": "gate-central-03",
                          "kind": "gate",
                          "status": "active",
                          "gate_id": "central-gate-03",
                          "dbd_id": "validator-central-03",
                          "app": {
                            "pkg": "id.bora.access.gate",
                            "version": "2.1.4"
                          },
                          "model_id": "bora-palm-ir-v1",
                          "gallery": {
                            "stream": "main",
                            "epoch": 3,
                            "seq": 15873,
                            "synced_at": "2026-10-01T10:19:58.000Z"
                          },
                          "keys": [
                            {
                              "purpose": "verdict",
                              "alg": "ed25519",
                              "kid": "300290aeb182952c1337b227be5fe728"
                            },
                            {
                              "purpose": "http",
                              "alg": "ed25519",
                              "kid": "d1ab5521bfd29c9326bcc0912595d2d2"
                            }
                          ],
                          "trust": {
                            "attest_level": "none",
                            "verified": false
                          },
                          "health": [
                            "KEY_UNATTESTED"
                          ],
                          "last_seen_at": "2026-10-01T10:20:01.000Z",
                          "registered_at": "2026-09-30T18:00:00.000Z",
                          "revoked_at": null,
                          "livemode": true
                        }
                      ],
                      "has_more": false,
                      "next_cursor": null
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/devices/{device_id}/inbox": {
      "parameters": [
        {
          "$ref": "#/components/parameters/DeviceIdPath"
        }
      ],
      "get": {
        "tags": [
          "Mail"
        ],
        "operationId": "listDeviceInbox",
        "x-bora-poc": true,
        "summary": "Fetch da Inbox",
        "description": "Registros que a BORA preparou para este aparelho. O seu backend busca aqui e entrega ao Validator\nDevice, que repassa ao BORA Access. Peça sempre a partir do último `seq` entregue (`after_seq`) e\nentregue na ordem.",
        "security": [
          {
            "PartnerApiKey": [
              "devices:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "after_seq",
            "in": "query",
            "required": false,
            "description": "Devolve só registros com `seq` maior que este. Padrão 0 (desde o início).",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991,
              "default": 0
            }
          },
          {
            "$ref": "#/components/parameters/Limit"
          }
        ],
        "responses": {
          "200": {
            "description": "Registros pendentes para o aparelho, em ordem de `seq`.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceInbox"
                },
                "examples": {
                  "um_registro": {
                    "value": {
                      "device_id": "gate-bh-eldorado-03",
                      "data": [
                        {
                          "post": {
                            "v": 1,
                            "rid": "c41f2a9be07d4d3f9a6e5b2c1d0e8f7a",
                            "box": "in",
                            "src": "bora",
                            "dst": "gate-bh-eldorado-03",
                            "seq": 88,
                            "created_ms": 1790849000000,
                            "suite": "hpke-x25519-sha256-chacha20poly1305",
                            "ct_len": 144,
                            "ct_sha256": "7d8bbc540bbbfc01881f4becb42f2ff14c72d372a889bf04e3e0a07019e365fc"
                          },
                          "ct_b64": "TAc0sssnInErGpzmvTRKQb1f5wNinoQEfZvKHfG8DrjbuN1sZ3oAIPAOl1u/UG3lbMMpi9l756LtnMyruTrLn9PYmK5g1C7F3rI3xTWKOR5sbbVg+L2Z6V7MNLDnKKqxiPclJu5KxrYKxErFd1yleZcuCnC4aWnex4JcyE+D3UupqQN8hyyjLD4mJWsuIWBo",
                          "alg": "ed25519",
                          "signer_kid": "d9bf8bfe11bc109cb5687c77a5bf6581",
                          "sig_b64": "5jX0VjNhwjUWHyiuX8AOmnbvKTvvYG4sY7XEkPwTriQsZuKxptnrEmv3h3/3DT8UJ1YCJX447ZU/TPcvi0eDCQ==",
                          "signer_cert_b64": "kvCBJCkO7mgC+XHfZDDByN6Nkz2+zpLxXeQBnT3vemEAAAGixmd6QBQuCyvnDKjwbNqTrEAThAEsCj79FV04k648hrD4XcsbBS9kg8rvOZ6GUMWK38vKc0BIqjHSvQ8MeJ9UXLkoeAw="
                        }
                      ],
                      "has_more": false,
                      "next_after_seq": 88
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/devices/{device_id}/outbox": {
      "parameters": [
        {
          "$ref": "#/components/parameters/DeviceIdPath"
        }
      ],
      "post": {
        "tags": [
          "Mail"
        ],
        "operationId": "submitDeviceOutbox",
        "x-bora-poc": true,
        "summary": "Deliver da Outbox",
        "description": "Registros que voltam do aparelho. O Validator Device recebe do BORA Access, e o seu backend entrega aqui\ndo jeito que recebeu. `acked_upto_seq` diz até onde a BORA já recebeu. Reenviar o mesmo registro não tem\nproblema.",
        "security": [
          {
            "PartnerApiKey": [
              "devices:write"
            ]
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OutboxSubmit"
              },
              "examples": {
                "um_registro": {
                  "value": {
                    "records": [
                      {
                        "post": {
                          "v": 1,
                          "rid": "43f942747a684f61764a6b589e5a0557",
                          "box": "out",
                          "src": "gate-bh-eldorado-03",
                          "dst": "bora",
                          "seq": 41,
                          "created_ms": 1790849100000,
                          "suite": "hpke-x25519-sha256-chacha20poly1305",
                          "ct_len": 96,
                          "ct_sha256": "86f4584fac1a57bdd67f82b98d8da05a97c715571097f7c70167b4deeefe0629"
                        },
                        "ct_b64": "NL6ht3TgTTzJjPh8cwUgSiJ+0fEHSRs0zGT8ItLRnJE0vqG3dOBNPMmM+HxzBSBKIn7R8QdJGzTMZPwi0tGckTS+obd04E08yYz4fHMFIEoiftHxB0kbNMxk/CLS0ZyR",
                        "alg": "ed25519",
                        "signer_kid": "300290aeb182952c1337b227be5fe728",
                        "sig_b64": "MZjoQolUFxtqvOrFELGWJ2pC4/vVEUe+YMLV/odkfjIKTRDEDGOQVbWkt+oSV3ytJCovfKFzNxJgDFed/qY4Bg=="
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Resultado por registro.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OutboxResult"
                },
                "examples": {
                  "aceito": {
                    "value": {
                      "device_id": "gate-bh-eldorado-03",
                      "accepted": [
                        41
                      ],
                      "duplicates": [],
                      "rejected": [],
                      "acked_upto_seq": 41
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/verdicts": {
      "get": {
        "tags": [
          "Verdicts"
        ],
        "operationId": "listVerdicts",
        "x-bora-poc": true,
        "summary": "Listar passagens",
        "description": "Passagens registradas pelos aparelhos, com o usuário (`subject_id` e `external_ref`, só em `accept`) e a\ndecisão do Validator Device quando ela chega. As mais recentes vêm primeiro. Ficam disponíveis por 13\nmeses.",
        "security": [
          {
            "PartnerApiKey": [
              "verdicts:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "device_id",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/AsciiRef"
            }
          },
          {
            "name": "gate_id",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/AsciiRef"
            }
          },
          {
            "name": "subject_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "decision",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/LinkDecision"
            }
          },
          {
            "name": "reconciliation",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/ReconciliationStatus"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "Início inclusivo (decided_at).",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "Fim exclusivo (decided_at).",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "desc",
                "asc"
              ],
              "default": "desc"
            }
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Página de passagens.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VerdictPage"
                },
                "examples": {
                  "pagina": {
                    "value": {
                      "data": [
                        {
                          "verdict_id": "42e1d185c8245b5cd45dfaae19194886",
                          "txn_id": "7f3c9a1e5b2d4c6f8a0b1c2d3e4f5a6b",
                          "device_id": "gate-central-03",
                          "gate_id": "central-gate-03",
                          "dbd_id": "validator-central-03",
                          "verdict_seq": 1042,
                          "decision": "accept",
                          "result": "MATCH",
                          "subject_id": "3f6c2a9e-8b1d-4e7a-9c3f-5d2e1a0b7c64",
                          "external_ref": "000482913",
                          "hand": "R",
                          "pad_res": "pass",
                          "quality_q": 9120,
                          "model_id": "bora-palm-ir-v1",
                          "decided_at": "2026-10-01T10:20:00.840Z",
                          "received_at": "2026-10-01T10:20:03.112Z",
                          "dbd": {
                            "reason": "ok",
                            "outcome": "LIBERAR",
                            "actuated": true,
                            "decision_seq": 88123,
                            "decided_at": "2026-10-01T10:20:00.861Z"
                          },
                          "passage": {
                            "passed": true,
                            "cause": "giro",
                            "at": "2026-10-01T10:20:02.400Z"
                          },
                          "reconciliation": "complete"
                        }
                      ],
                      "has_more": true,
                      "next_cursor": "eyJrIjoiZGVjaWRlZF9hdCIsInYiOjE3OTA4NTAwMDA4NDB9"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "410": {
            "$ref": "#/components/responses/Gone"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/verdicts/{verdict_id}": {
      "parameters": [
        {
          "name": "verdict_id",
          "in": "path",
          "required": true,
          "description": "Id da passagem.",
          "schema": {
            "$ref": "#/components/schemas/LinkHex32"
          }
        }
      ],
      "get": {
        "tags": [
          "Verdicts"
        ],
        "operationId": "getVerdict",
        "x-bora-poc": true,
        "summary": "Consultar passagem",
        "description": "A passagem com a prova assinada pelo aparelho e, quando chegaram, a decisão e o giro registrados pelo\nValidator Device. Use para conciliar com o seu backend e para contestar uma cobrança.",
        "security": [
          {
            "PartnerApiKey": [
              "verdicts:read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "A passagem com a prova.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VerdictProof"
                },
                "examples": {
                  "aprovado": {
                    "$ref": "#/components/examples/VerdictProof"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "PartnerApiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "bora_<live|test>_<key_id>_<secret>",
        "description": "API key da sua organização. Cada endpoint diz o escopo que precisa."
      }
    },
    "parameters": {
      "ClientRequestId": {
        "name": "X-Request-Id",
        "in": "header",
        "required": false,
        "description": "Id de correlação do cliente (ecoado na resposta). Se ausente, a BORA gera um.",
        "schema": {
          "type": "string",
          "maxLength": 64,
          "pattern": "^[A-Za-z0-9._:-]{1,64}$"
        }
      },
      "SubjectId": {
        "name": "subject_id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "SessionId": {
        "name": "session_id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "DeviceIdPath": {
        "name": "device_id",
        "in": "path",
        "required": true,
        "schema": {
          "$ref": "#/components/schemas/DeviceId"
        }
      },
      "Limit": {
        "name": "limit",
        "in": "query",
        "required": false,
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 200,
          "default": 50
        }
      },
      "Cursor": {
        "name": "cursor",
        "in": "query",
        "required": false,
        "description": "Cursor opaco (next_cursor da página anterior).",
        "schema": {
          "type": "string",
          "maxLength": 512,
          "pattern": "^[A-Za-z0-9_=-]+$"
        }
      }
    },
    "headers": {
      "X-Request-Id": {
        "description": "Id da requisição (o do cliente ou um gerado). Também vai no `instance` dos erros.",
        "schema": {
          "type": "string"
        }
      },
      "Location": {
        "description": "URL do recurso criado.",
        "schema": {
          "type": "string"
        }
      },
      "Bora-Server-Time": {
        "description": "Hora do servidor, em epoch ms.",
        "schema": {
          "type": "string",
          "pattern": "^[0-9]{13}$"
        }
      },
      "RateLimit-Limit": {
        "schema": {
          "type": "integer"
        }
      },
      "RateLimit-Remaining": {
        "schema": {
          "type": "integer"
        }
      },
      "RateLimit-Reset": {
        "description": "Segundos até a janela reabrir.",
        "schema": {
          "type": "integer"
        }
      },
      "Retry-After": {
        "description": "Segundos para tentar de novo.",
        "schema": {
          "type": "integer"
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Requisição malformada (JSON inválido, cursor inválido, parâmetro com formato errado).",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            },
            "examples": {
              "json": {
                "value": {
                  "type": "https://bora.id/transport/documentation#erro-malformed_json",
                  "title": "JSON malformado",
                  "status": 400,
                  "code": "malformed_json",
                  "detail": "O corpo não é um JSON válido.",
                  "instance": "req_01J9Z8X7W6V5",
                  "retryable": false
                }
              }
            }
          }
        }
      },
      "Unauthenticated": {
        "description": "API key ausente ou inválida.",
        "headers": {
          "Bora-Server-Time": {
            "$ref": "#/components/headers/Bora-Server-Time"
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            },
            "examples": {
              "generico": {
                "value": {
                  "type": "https://bora.id/transport/documentation#erro-unauthenticated",
                  "title": "Não autenticado",
                  "status": 401,
                  "code": "unauthenticated",
                  "instance": "req_01J9Z8X7W6V6",
                  "retryable": false
                }
              }
            }
          }
        }
      },
      "Forbidden": {
        "description": "A key não tem permissão (escopo ou ambiente test/live).",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            },
            "examples": {
              "escopo": {
                "value": {
                  "type": "https://bora.id/transport/documentation#erro-insufficient_scope",
                  "title": "Escopo insuficiente",
                  "status": 403,
                  "code": "insufficient_scope",
                  "detail": "A API key não tem o escopo subjects:write.",
                  "instance": "req_01J9Z8X7W6V7",
                  "retryable": false
                }
              }
            }
          }
        }
      },
      "NotFound": {
        "description": "Recurso não encontrado.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            },
            "examples": {
              "pessoa": {
                "value": {
                  "type": "https://bora.id/transport/documentation#erro-subject_not_found",
                  "title": "Pessoa não encontrada",
                  "status": 404,
                  "code": "subject_not_found",
                  "instance": "req_01J9Z8X7W6V8",
                  "retryable": false
                }
              }
            }
          }
        }
      },
      "Conflict": {
        "description": "Conflito com o estado atual.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            },
            "examples": {
              "external_ref": {
                "value": {
                  "type": "https://bora.id/transport/documentation#erro-external_ref_conflict",
                  "title": "external_ref já usado",
                  "status": 409,
                  "code": "external_ref_conflict",
                  "detail": "Já existe um usuário com este external_ref na sua organização.",
                  "instance": "req_01J9Z8X7W6V9",
                  "retryable": false
                }
              }
            }
          }
        }
      },
      "Gone": {
        "description": "Recurso ou histórico fora da retenção.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            },
            "examples": {}
          }
        }
      },
      "UnsupportedMediaType": {
        "description": "Content-Type diferente de application/json.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "ValidationFailed": {
        "description": "JSON válido, mas fora do contrato.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            },
            "examples": {
              "cpf_como_ref": {
                "value": {
                  "type": "https://bora.id/transport/documentation#erro-external_ref_looks_like_cpf",
                  "title": "external_ref parece um CPF",
                  "status": 422,
                  "code": "external_ref_looks_like_cpf",
                  "detail": "Use o ID da conta no seu sistema; o CPF vai só no campo cpf.",
                  "instance": "req_01J9Z8X7W6VB",
                  "retryable": false,
                  "errors": [
                    {
                      "pointer": "/external_ref",
                      "code": "external_ref_looks_like_cpf"
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "RateLimited": {
        "description": "Limite de taxa estourado.",
        "headers": {
          "Retry-After": {
            "$ref": "#/components/headers/Retry-After"
          },
          "RateLimit-Limit": {
            "$ref": "#/components/headers/RateLimit-Limit"
          },
          "RateLimit-Remaining": {
            "$ref": "#/components/headers/RateLimit-Remaining"
          },
          "RateLimit-Reset": {
            "$ref": "#/components/headers/RateLimit-Reset"
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            },
            "examples": {
              "limite": {
                "value": {
                  "type": "https://bora.id/transport/documentation#erro-rate_limited",
                  "title": "Muitas requisições",
                  "status": 429,
                  "code": "rate_limited",
                  "instance": "req_01J9Z8X7W6VD",
                  "retryable": true
                }
              }
            }
          }
        }
      },
      "InternalError": {
        "description": "Erro interno. Pode repetir a requisição.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "ServiceUnavailable": {
        "description": "Serviço indisponível.",
        "headers": {
          "Retry-After": {
            "$ref": "#/components/headers/Retry-After"
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      }
    },
    "schemas": {
      "AsciiRef": {
        "type": "string",
        "pattern": "^[A-Za-z0-9._:-]{1,64}$"
      },
      "DeviceId": {
        "description": "Id do aparelho. Começa com `gate-` (BORA ACCESS GATE 01, na catraca) ou `totem-` (BORA ACCESS TOTEM 01,\no Enrollment Totem).",
        "type": "string",
        "pattern": "^[A-Za-z0-9._:-]{1,64}$",
        "not": {
          "enum": [
            "self",
            "register",
            "attest"
          ]
        }
      },
      "ExternalRef": {
        "description": "Chave única do usuário no seu sistema (por exemplo, o número da conta). Segue o formato da sua\norganização: numérico por padrão (só dígitos, até 32), o CPF do usuário (11 dígitos, sem pontuação) ou\num padrão combinado com a BORA. Fora do formato, a API devolve `422 external_ref_invalid` com o formato\nesperado. Se a chave é o CPF, busque com `POST /v1/subjects/search`.",
        "type": "string",
        "pattern": "^[A-Za-z0-9._:@-]{1,128}$"
      },
      "Timestamp": {
        "type": "string",
        "format": "date-time"
      },
      "PageMeta": {
        "type": "object",
        "required": [
          "has_more",
          "next_cursor"
        ],
        "properties": {
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "ReasonCode": {
        "description": "Códigos estáveis de erro HTTP (campo `code` do problem+json). Novos códigos podem entrar no v1; o cliente trata código desconhecido pelo `status`.\n\n| code | status | quando | repetir? |\n|---|---|---|---|\n| `malformed_json` | 400 | corpo não é JSON válido | não |\n| `invalid_request` | 400 | parâmetro de query ou header com formato errado | não |\n| `invalid_cursor` | 400 | cursor inválido ou de outra lista | não |\n| `unauthenticated` | 401 | API key ausente, inválida ou revogada | não |\n| `forbidden` | 403 | a key não tem acesso ao recurso | não |\n| `insufficient_scope` | 403 | API key sem o escopo da rota | não |\n| `livemode_mismatch` | 403 | key `test` em recurso `live` ou o contrário | não |\n| `subject_not_found` | 404 | usuário não encontrado | não |\n| `device_not_found` | 404 | aparelho não encontrado | não |\n| `verdict_not_found` | 404 | passagem não encontrada | não |\n| `enrollment_session_not_found` | 404 | cadastro não encontrado | não |\n| `external_ref_conflict` | 409 | external_ref já usado na sua organização | não |\n| `cpf_conflict` | 409 | CPF já ligado a outro usuário ativo da sua organização | não |\n| `cursor_expired` | 410 | cursor fora da retenção | não |\n| `payload_too_large` | 413 | corpo acima do limite | não |\n| `unsupported_media_type` | 415 | Content-Type errado | não |\n| `validation_failed` | 422 | JSON fora do contrato; detalhes em `errors[]` | não |\n| `external_ref_looks_like_cpf` | 422 | o external_ref parece um CPF; use o id da conta (o CPF vai no campo `cpf`) | não |\n| `onboard_ref_looks_like_cpf` | 422 | o onboard_ref parece um CPF | não |\n| `external_ref_invalid` | 422 | external_ref fora do formato da sua organização; o `detail` diz o formato | não |\n| `cpf_invalid` | 422 | CPF fora do formato: 11 dígitos, sem pontuação, com dígitos verificadores válidos | não |\n| `use_search_endpoint` | 422 | busca pelo external_ref na URL quando a chave é o CPF; use `POST /v1/subjects/search` | não |\n| `rate_limited` | 429 | limite de taxa | sim, depois do Retry-After |\n| `internal_error` | 500 | erro interno | sim |\n| `service_unavailable` | 503 | manutenção ou sobrecarga | sim, depois do Retry-After |\n| `device_overheated` | 503 | O aparelho pausou o reconhecimento da palma por temperatura alta. Ele volta sozinho quando esfria. | sim |",
        "type": "string",
        "x-extensible-enum": true,
        "enum": [
          "malformed_json",
          "invalid_request",
          "invalid_cursor",
          "unauthenticated",
          "forbidden",
          "insufficient_scope",
          "livemode_mismatch",
          "subject_not_found",
          "device_not_found",
          "verdict_not_found",
          "enrollment_session_not_found",
          "external_ref_conflict",
          "cpf_conflict",
          "cursor_expired",
          "payload_too_large",
          "unsupported_media_type",
          "validation_failed",
          "external_ref_looks_like_cpf",
          "onboard_ref_looks_like_cpf",
          "external_ref_invalid",
          "cpf_invalid",
          "use_search_endpoint",
          "rate_limited",
          "internal_error",
          "service_unavailable",
          "device_overheated"
        ]
      },
      "DeviceInbox": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "device_id",
          "data",
          "has_more",
          "next_after_seq"
        ],
        "properties": {
          "device_id": {
            "$ref": "#/components/schemas/DeviceId"
          },
          "data": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/LinkMailboxRecord"
            }
          },
          "has_more": {
            "type": "boolean"
          },
          "next_after_seq": {
            "description": "Passe em `after_seq` na próxima chamada.",
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          }
        }
      },
      "OutboxSubmit": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "records"
        ],
        "properties": {
          "records": {
            "type": "array",
            "minItems": 1,
            "maxItems": 32,
            "items": {
              "$ref": "#/components/schemas/LinkMailboxRecord"
            }
          }
        }
      },
      "OutboxResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "device_id",
          "accepted",
          "duplicates",
          "rejected",
          "acked_upto_seq"
        ],
        "properties": {
          "device_id": {
            "$ref": "#/components/schemas/DeviceId"
          },
          "accepted": {
            "type": "array",
            "items": {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            }
          },
          "duplicates": {
            "type": "array",
            "items": {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            }
          },
          "rejected": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "seq",
                "code"
              ],
              "properties": {
                "seq": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "code": {
                  "type": "string",
                  "enum": [
                    "wrong_box",
                    "wrong_device",
                    "unknown_signer",
                    "bad_signature",
                    "bad_hash",
                    "seq_conflict"
                  ]
                }
              }
            }
          },
          "acked_upto_seq": {
            "description": "Maior `seq` contíguo (a partir de 1) já guardado pela BORA para este aparelho.",
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          }
        }
      },
      "Problem": {
        "description": "Erro no formato RFC 9457. Trate pelo `code`.",
        "type": "object",
        "required": [
          "type",
          "title",
          "status",
          "code",
          "instance",
          "retryable"
        ],
        "properties": {
          "type": {
            "type": "string",
            "format": "uri"
          },
          "title": {
            "type": "string",
            "maxLength": 120
          },
          "status": {
            "type": "integer",
            "minimum": 400,
            "maximum": 599
          },
          "code": {
            "$ref": "#/components/schemas/ReasonCode"
          },
          "detail": {
            "type": "string",
            "maxLength": 300
          },
          "instance": {
            "description": "Id da requisição (mesmo do X-Request-Id).",
            "type": "string"
          },
          "retryable": {
            "type": "boolean"
          },
          "errors": {
            "description": "Só em 422 validation_failed e afins. `pointer` = JSON Pointer (RFC 6901) do campo.",
            "type": "array",
            "maxItems": 50,
            "items": {
              "type": "object",
              "required": [
                "pointer",
                "code"
              ],
              "properties": {
                "pointer": {
                  "type": "string",
                  "maxLength": 200
                },
                "code": {
                  "type": "string",
                  "pattern": "^[a-z0-9_]{1,64}$"
                }
              }
            }
          },
          "snapshot_seq": {
            "description": "Só em 410 history_expired.",
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "Health": {
        "type": "object",
        "required": [
          "status",
          "api_version",
          "contract_version",
          "server_time"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "ok",
              "degraded"
            ]
          },
          "api_version": {
            "const": "v1"
          },
          "contract_version": {
            "type": "string"
          },
          "server_time": {
            "$ref": "#/components/schemas/Timestamp"
          }
        }
      },
      "Ed25519Pub": {
        "description": "Chave pública em base64.",
        "type": "string",
        "pattern": "^[A-Za-z0-9+/]{43}=$"
      },
      "SubjectStatus": {
        "type": "string",
        "enum": [
          "pending_enrollment",
          "active",
          "blocked"
        ]
      },
      "Subject": {
        "type": "object",
        "required": [
          "subject_id",
          "external_ref",
          "subject_ref",
          "status",
          "enrollment",
          "created_at",
          "updated_at",
          "livemode"
        ],
        "properties": {
          "subject_id": {
            "type": "string",
            "format": "uuid",
            "readOnly": true
          },
          "external_ref": {
            "$ref": "#/components/schemas/ExternalRef"
          },
          "subject_ref": {
            "description": "Pseudônimo do usuário que aparece nas passagens. Também é dado pessoal pela LGPD.",
            "allOf": [
              {
                "$ref": "#/components/schemas/LinkHex32"
              }
            ],
            "readOnly": true
          },
          "onboard_ref": {
            "$ref": "#/components/schemas/OnboardRef"
          },
          "status": {
            "$ref": "#/components/schemas/SubjectStatus"
          },
          "block": {
            "type": [
              "object",
              "null"
            ],
            "required": [
              "reason",
              "blocked_at"
            ],
            "properties": {
              "reason": {
                "$ref": "#/components/schemas/BlockReason"
              },
              "blocked_at": {
                "$ref": "#/components/schemas/Timestamp"
              }
            }
          },
          "enrollment": {
            "type": [
              "object",
              "null"
            ],
            "required": [
              "hands",
              "model_id",
              "enrolled_at"
            ],
            "properties": {
              "hands": {
                "type": "array",
                "minItems": 1,
                "maxItems": 2,
                "uniqueItems": true,
                "items": {
                  "type": "string",
                  "enum": [
                    "L",
                    "R"
                  ]
                }
              },
              "model_id": {
                "$ref": "#/components/schemas/AsciiRef"
              },
              "enrolled_at": {
                "$ref": "#/components/schemas/Timestamp"
              }
            }
          },
          "gallery_seq": {
            "description": "Versão da base de palmas que já inclui a última mudança deste usuário.",
            "type": [
              "integer",
              "null"
            ]
          },
          "created_at": {
            "$ref": "#/components/schemas/Timestamp"
          },
          "updated_at": {
            "$ref": "#/components/schemas/Timestamp"
          },
          "livemode": {
            "type": "boolean"
          }
        }
      },
      "OnboardRef": {
        "description": "Opcional. Uma referência sua que volta nas passagens aceitas. Não use CPF nem nome.",
        "type": "string",
        "pattern": "^[A-Za-z0-9._:+/=-]{1,128}$"
      },
      "SubjectCreate": {
        "type": "object",
        "required": [
          "external_ref"
        ],
        "additionalProperties": false,
        "properties": {
          "external_ref": {
            "$ref": "#/components/schemas/ExternalRef"
          },
          "cpf": {
            "description": "Opcional. CPF do usuário: 11 dígitos, sem pontos, traços ou espaços, com dígitos verificadores\nválidos. Fora disso, a API devolve `422 cpf_invalid`. Evita cadastro duplicado, fica criptografado e\nnão volta nas respostas.",
            "type": "string",
            "pattern": "^[0-9]{11}$",
            "writeOnly": true
          },
          "onboard_ref": {
            "$ref": "#/components/schemas/OnboardRef"
          }
        }
      },
      "SubjectSearch": {
        "type": "object",
        "required": [
          "external_ref"
        ],
        "additionalProperties": false,
        "properties": {
          "external_ref": {
            "$ref": "#/components/schemas/ExternalRef"
          }
        }
      },
      "SubjectPage": {
        "allOf": [
          {
            "$ref": "#/components/schemas/PageMeta"
          },
          {
            "type": "object",
            "required": [
              "data"
            ],
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Subject"
                }
              }
            }
          }
        ]
      },
      "BlockReason": {
        "type": "string",
        "enum": [
          "partner_request",
          "suspected_fraud",
          "account_closed",
          "lost_access",
          "other"
        ]
      },
      "EnrollmentSessionCreate": {
        "type": "object",
        "additionalProperties": false,
        "oneOf": [
          {
            "required": [
              "subject_id"
            ]
          },
          {
            "required": [
              "external_ref"
            ]
          }
        ],
        "properties": {
          "subject_id": {
            "type": "string",
            "format": "uuid"
          },
          "external_ref": {
            "$ref": "#/components/schemas/ExternalRef"
          },
          "hands_required": {
            "type": "array",
            "minItems": 1,
            "maxItems": 2,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "enum": [
                "L",
                "R"
              ]
            },
            "default": [
              "L",
              "R"
            ]
          },
          "device_id": {
            "description": "Opcional. Limita o cadastro a um Enrollment Totem. Sem ele, qualquer Totem da sua organização conclui.",
            "$ref": "#/components/schemas/DeviceId"
          },
          "expires_in_s": {
            "type": "integer",
            "minimum": 60,
            "maximum": 900,
            "default": 300
          }
        }
      },
      "EnrollmentSessionStatus": {
        "type": "string",
        "enum": [
          "open",
          "in_progress",
          "completed",
          "review",
          "expired",
          "cancelled",
          "failed"
        ]
      },
      "EnrollmentSession": {
        "type": "object",
        "required": [
          "session_id",
          "subject_id",
          "status",
          "hands_required",
          "expires_at",
          "created_at"
        ],
        "properties": {
          "session_id": {
            "type": "string",
            "format": "uuid"
          },
          "subject_id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "$ref": "#/components/schemas/EnrollmentSessionStatus"
          },
          "failure_code": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "capture_rejected",
              "duplicate_rejected",
              null
            ]
          },
          "hands_required": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "L",
                "R"
              ]
            }
          },
          "device_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "completed_by_device_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "enrollment_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "token": {
            "description": "Código de uso único da sessão. Só na resposta da criação. Não guarde em log.",
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{43}$",
            "readOnly": true
          },
          "qr_payload": {
            "description": "Conteúdo do QR code que o ABT app mostra ao passageiro. Só na resposta da criação.",
            "type": "string",
            "pattern": "^BORA1:ENR:[0-9a-f-]{36}:[A-Za-z0-9_-]{43}$",
            "readOnly": true
          },
          "short_code": {
            "description": "Código de 8 caracteres para digitar no Enrollment Totem, se não der para ler o QR code. Uso único,\nvale até `expires_at`. Só na resposta da criação.",
            "type": "string",
            "pattern": "^[A-HJ-NP-Z2-9]{8}$",
            "readOnly": true
          },
          "expires_at": {
            "$ref": "#/components/schemas/Timestamp"
          },
          "created_at": {
            "$ref": "#/components/schemas/Timestamp"
          },
          "completed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "DeviceKind": {
        "type": "string",
        "enum": [
          "gate",
          "totem"
        ]
      },
      "DeviceStatus": {
        "type": "string",
        "enum": [
          "active",
          "revoked",
          "wiped"
        ]
      },
      "DeviceHealthFlag": {
        "description": "Alerta de saúde do aparelho.",
        "type": "string",
        "x-extensible-enum": true,
        "enum": [
          "SENSOR_MISSING",
          "GALLERY_STALE",
          "KEY_UNATTESTED",
          "CLOCK_UNTRUSTED",
          "PAD_OFF",
          "QUEUE_HIGH",
          "TEMP_HIGH",
          "ADB_ON",
          "SELINUX_PERMISSIVE",
          "SENSOR_CHANGED",
          "USB_FOREIGN",
          "LINK_DOWN",
          "LEASE_EXPIRED"
        ]
      },
      "Device": {
        "type": "object",
        "required": [
          "device_id",
          "kind",
          "status",
          "keys",
          "trust",
          "registered_at",
          "livemode"
        ],
        "properties": {
          "device_id": {
            "$ref": "#/components/schemas/DeviceId"
          },
          "kind": {
            "$ref": "#/components/schemas/DeviceKind"
          },
          "status": {
            "$ref": "#/components/schemas/DeviceStatus"
          },
          "gate_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "dbd_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "app": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "pkg": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "model_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "gallery": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "stream": {
                "type": "string"
              },
              "epoch": {
                "type": "integer"
              },
              "seq": {
                "type": "integer"
              },
              "synced_at": {
                "$ref": "#/components/schemas/Timestamp"
              }
            }
          },
          "keys": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "purpose",
                "alg",
                "kid"
              ],
              "properties": {
                "purpose": {
                  "$ref": "#/components/schemas/DeviceKeyPurpose"
                },
                "alg": {
                  "$ref": "#/components/schemas/DeviceKeyAlg"
                },
                "kid": {
                  "$ref": "#/components/schemas/LinkHex32"
                }
              }
            }
          },
          "trust": {
            "$ref": "#/components/schemas/DeviceTrust"
          },
          "health": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DeviceHealthFlag"
            }
          },
          "last_seen_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "registered_at": {
            "$ref": "#/components/schemas/Timestamp"
          },
          "revoked_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "passage_sensor": {
            "description": "A catraca confirma o giro. Nesse caso, a passagem só fica `complete` depois da confirmação.",
            "type": "boolean"
          },
          "livemode": {
            "type": "boolean"
          }
        }
      },
      "DeviceTrust": {
        "description": "Nível de confiança do aparelho, verificado pela BORA.",
        "type": "object",
        "required": [
          "attest_level",
          "verified"
        ],
        "properties": {
          "attest_level": {
            "type": "string",
            "enum": [
              "none",
              "sw",
              "tee",
              "strongbox"
            ]
          },
          "verified": {
            "type": "boolean"
          }
        }
      },
      "DevicePage": {
        "allOf": [
          {
            "$ref": "#/components/schemas/PageMeta"
          },
          {
            "type": "object",
            "required": [
              "data"
            ],
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Device"
                }
              }
            }
          }
        ]
      },
      "ReconciliationStatus": {
        "description": "`complete`: passagem conciliada. `awaiting_decision`: falta a decisão do Validator Device.\n`awaiting_passage`: a catraca liberou e falta a confirmação do giro. `outcome_unknown`: o resultado da\npassagem se perdeu. `conflict`: os registros da passagem não batem entre si.",
        "type": "string",
        "enum": [
          "complete",
          "awaiting_decision",
          "awaiting_passage",
          "outcome_unknown",
          "conflict"
        ]
      },
      "VerdictRecord": {
        "type": "object",
        "required": [
          "verdict_id",
          "txn_id",
          "device_id",
          "gate_id",
          "dbd_id",
          "verdict_seq",
          "decision",
          "result",
          "decided_at",
          "received_at",
          "reconciliation"
        ],
        "properties": {
          "verdict_id": {
            "$ref": "#/components/schemas/LinkHex32"
          },
          "txn_id": {
            "$ref": "#/components/schemas/LinkHex32"
          },
          "device_id": {
            "$ref": "#/components/schemas/DeviceId"
          },
          "gate_id": {
            "$ref": "#/components/schemas/AsciiRef"
          },
          "dbd_id": {
            "$ref": "#/components/schemas/AsciiRef"
          },
          "verdict_seq": {
            "type": "integer",
            "minimum": 1
          },
          "decision": {
            "$ref": "#/components/schemas/LinkDecision"
          },
          "result": {
            "$ref": "#/components/schemas/LinkVerdictResult"
          },
          "subject_id": {
            "description": "Só em `accept`.",
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "external_ref": {
            "description": "Só em `accept`.",
            "type": [
              "string",
              "null"
            ]
          },
          "hand": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "L",
              "R",
              null
            ]
          },
          "pad_res": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "pass",
              "fail",
              "off",
              "inconclusive",
              null
            ]
          },
          "quality_q": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "maximum": 10000
          },
          "model_id": {
            "type": "string"
          },
          "decided_at": {
            "$ref": "#/components/schemas/Timestamp"
          },
          "received_at": {
            "$ref": "#/components/schemas/Timestamp"
          },
          "dbd": {
            "type": [
              "object",
              "null"
            ],
            "required": [
              "reason",
              "outcome",
              "actuated",
              "decision_seq",
              "decided_at"
            ],
            "properties": {
              "reason": {
                "$ref": "#/components/schemas/LinkDecisionReason"
              },
              "outcome": {
                "$ref": "#/components/schemas/LinkDecisionOutcome"
              },
              "actuated": {
                "type": "boolean"
              },
              "decision_seq": {
                "type": "integer",
                "minimum": 0
              },
              "decided_at": {
                "$ref": "#/components/schemas/Timestamp"
              }
            }
          },
          "passage": {
            "type": [
              "object",
              "null"
            ],
            "required": [
              "passed",
              "cause",
              "at"
            ],
            "properties": {
              "passed": {
                "type": "boolean"
              },
              "cause": {
                "type": "string",
                "enum": [
                  "giro",
                  "timeout",
                  "reversao",
                  "forcada"
                ]
              },
              "at": {
                "$ref": "#/components/schemas/Timestamp"
              }
            }
          },
          "reconciliation": {
            "$ref": "#/components/schemas/ReconciliationStatus"
          }
        }
      },
      "VerdictPage": {
        "allOf": [
          {
            "$ref": "#/components/schemas/PageMeta"
          },
          {
            "type": "object",
            "required": [
              "data"
            ],
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/VerdictRecord"
                }
              }
            }
          }
        ]
      },
      "VerdictProof": {
        "type": "object",
        "required": [
          "record",
          "signed_verdict",
          "signed_decision",
          "signed_passage",
          "verification"
        ],
        "properties": {
          "record": {
            "$ref": "#/components/schemas/VerdictRecord"
          },
          "signed_verdict": {
            "$ref": "#/components/schemas/LinkSignedVerdict"
          },
          "signed_decision": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/LinkSignedDecision"
              },
              {
                "type": "null"
              }
            ]
          },
          "signed_passage": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/LinkSignedPassage"
              },
              {
                "type": "null"
              }
            ]
          },
          "verification": {
            "type": "object",
            "required": [
              "verdict_ref",
              "device_verdict_key",
              "prefixes"
            ],
            "properties": {
              "verdict_ref": {
                "description": "Igual ao `verdict_id`.",
                "$ref": "#/components/schemas/LinkHex32"
              },
              "device_verdict_key": {
                "type": "object",
                "required": [
                  "kid",
                  "alg",
                  "pub_b64"
                ],
                "properties": {
                  "kid": {
                    "$ref": "#/components/schemas/LinkHex32"
                  },
                  "alg": {
                    "const": "ed25519"
                  },
                  "pub_b64": {
                    "$ref": "#/components/schemas/Ed25519Pub"
                  }
                }
              },
              "dbd_sign_key": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "kid": {
                    "$ref": "#/components/schemas/LinkHex32"
                  },
                  "alg": {
                    "const": "ed25519"
                  },
                  "pub_b64": {
                    "$ref": "#/components/schemas/Ed25519Pub"
                  }
                }
              },
              "prefixes": {
                "type": "object",
                "properties": {
                  "verdict": {
                    "const": "bora.gate.verdict.v1"
                  },
                  "decision": {
                    "const": "bora.gate.decision.v1"
                  },
                  "passage": {
                    "const": "bora.gate.passage.v1"
                  }
                }
              }
            }
          }
        }
      },
      "DeviceKeyPurpose": {
        "description": "Uso da chave do aparelho.",
        "type": "string",
        "enum": [
          "verdict",
          "http",
          "noise_static",
          "identity",
          "tls"
        ]
      },
      "DeviceKeyAlg": {
        "type": "string",
        "enum": [
          "ed25519",
          "x25519",
          "es256"
        ]
      },
      "LinkUInt53": {
        "type": "integer",
        "minimum": 0,
        "maximum": 9007199254740991
      },
      "LinkEpochMs": {
        "type": "integer",
        "minimum": 0,
        "maximum": 253402300799999
      },
      "LinkQ": {
        "type": "integer",
        "minimum": 0,
        "maximum": 10000
      },
      "LinkRef": {
        "type": "string",
        "pattern": "^[A-Za-z0-9._:-]{1,64}$"
      },
      "LinkHex32": {
        "type": "string",
        "pattern": "^[0-9a-f]{32}$"
      },
      "LinkNonce16": {
        "type": "string",
        "pattern": "^[A-Za-z0-9+/]{22}==$"
      },
      "LinkEd25519Sig": {
        "type": "string",
        "pattern": "^[A-Za-z0-9+/]{86}==$"
      },
      "LinkMsgId": {
        "type": "integer",
        "minimum": 1,
        "maximum": 9007199254740991
      },
      "LinkHex64": {
        "type": "string",
        "pattern": "^[0-9a-f]{64}$"
      },
      "LinkB64": {
        "type": "string",
        "pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"
      },
      "LinkSignerCertB64": {
        "type": "string",
        "pattern": "^[A-Za-z0-9+/]{139}=$"
      },
      "LinkDecision": {
        "type": "string",
        "enum": [
          "accept",
          "reject",
          "abstain"
        ],
        "description": "Resultado do reconhecimento: `accept`, `reject` ou `abstain`."
      },
      "LinkVerdictResult": {
        "type": "string",
        "enum": [
          "MATCH",
          "NO_MATCH",
          "LIVENESS_FAIL",
          "NOT_ENROLLED",
          "AMBIGUOUS",
          "LOW_QUALITY",
          "TIMEOUT",
          "CANCELLED",
          "RATE_LIMITED",
          "BIOMETRIC_DISABLED",
          "GALLERY_STALE",
          "MODEL_MISMATCH",
          "DEVICE_NOT_READY"
        ],
        "description": "Motivo do resultado do reconhecimento."
      },
      "LinkDecisionReason": {
        "type": "string",
        "enum": [
          "ok",
          "malformed",
          "kid_unknown",
          "kid_mismatch",
          "device_killed",
          "bad_signature",
          "nonce_unknown",
          "nonce_reused",
          "nonce_expired",
          "gate_mismatch",
          "clock_skew",
          "bundle_expired",
          "result_incoherent",
          "cert_mismatch",
          "seq_rollback",
          "pin_expired",
          "attest_below_min",
          "proto_below_min",
          "app_below_min",
          "gallery_below_min"
        ]
      },
      "LinkDecisionOutcome": {
        "type": "string",
        "enum": [
          "LIBERAR",
          "REJEITAR_SALDO",
          "REJEITAR_BLOQUEADO",
          "REJEITAR_CATEGORIA",
          "REJEITAR_ANTIPASSBACK",
          "USAR_OUTRO_MEIO",
          "FALHA_TECNICA",
          "NAO_AVALIADO"
        ],
        "description": "Decisão do Validator Device (saldo, bloqueio, categoria)."
      },
      "LinkGalleryPos": {
        "type": "object",
        "required": [
          "stream",
          "epoch",
          "seq",
          "head16"
        ],
        "properties": {
          "stream": {
            "$ref": "#/components/schemas/LinkRef"
          },
          "epoch": {
            "$ref": "#/components/schemas/LinkUInt53"
          },
          "seq": {
            "$ref": "#/components/schemas/LinkUInt53"
          },
          "head16": {
            "$ref": "#/components/schemas/LinkHex32"
          }
        }
      },
      "LinkPad": {
        "type": "object",
        "required": [
          "res"
        ],
        "properties": {
          "res": {
            "type": "string",
            "enum": [
              "pass",
              "fail",
              "off",
              "inconclusive"
            ]
          },
          "mech": {
            "type": "string",
            "pattern": "^[A-Za-z0-9._:+/=-]{1,24}$"
          },
          "score_q": {
            "$ref": "#/components/schemas/LinkQ"
          }
        }
      },
      "LinkVerdict": {
        "type": "object",
        "required": [
          "v",
          "txn_id",
          "gate_id",
          "dbd_id",
          "nonce_b64",
          "issued_at_ms",
          "ttl_ms",
          "decided_at_ms",
          "device_id",
          "decision",
          "result",
          "verdict_seq",
          "prev_ref",
          "model_id",
          "thr_id",
          "gallery"
        ],
        "properties": {
          "v": {
            "const": 1
          },
          "txn_id": {
            "$ref": "#/components/schemas/LinkHex32"
          },
          "gate_id": {
            "$ref": "#/components/schemas/LinkRef"
          },
          "dbd_id": {
            "$ref": "#/components/schemas/LinkRef"
          },
          "nonce_b64": {
            "$ref": "#/components/schemas/LinkNonce16"
          },
          "issued_at_ms": {
            "$ref": "#/components/schemas/LinkEpochMs"
          },
          "ttl_ms": {
            "type": "integer",
            "minimum": 2000,
            "maximum": 10000
          },
          "decided_at_ms": {
            "$ref": "#/components/schemas/LinkEpochMs"
          },
          "device_id": {
            "$ref": "#/components/schemas/LinkRef"
          },
          "decision": {
            "$ref": "#/components/schemas/LinkDecision"
          },
          "result": {
            "$ref": "#/components/schemas/LinkVerdictResult"
          },
          "verdict_seq": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991
          },
          "prev_ref": {
            "$ref": "#/components/schemas/LinkHex32"
          },
          "subject_ref": {
            "$ref": "#/components/schemas/LinkHex32"
          },
          "onboard_ref": {
            "type": "string",
            "pattern": "^[A-Za-z0-9._:+/=-]{1,128}$"
          },
          "hand": {
            "type": "string",
            "enum": [
              "L",
              "R"
            ]
          },
          "score_q": {
            "$ref": "#/components/schemas/LinkQ"
          },
          "margin_q": {
            "$ref": "#/components/schemas/LinkQ"
          },
          "quality_q": {
            "$ref": "#/components/schemas/LinkQ"
          },
          "pad": {
            "$ref": "#/components/schemas/LinkPad"
          },
          "attempts": {
            "type": "integer",
            "minimum": 1,
            "maximum": 255
          },
          "model_id": {
            "$ref": "#/components/schemas/LinkRef"
          },
          "thr_id": {
            "$ref": "#/components/schemas/LinkRef"
          },
          "gallery": {
            "$ref": "#/components/schemas/LinkGalleryPos"
          },
          "bundle_seq": {
            "$ref": "#/components/schemas/LinkUInt53"
          },
          "cert_ref": {
            "$ref": "#/components/schemas/LinkHex32"
          },
          "reasons": {
            "type": "array",
            "maxItems": 8,
            "items": {
              "type": "string",
              "pattern": "^[A-Za-z0-9._:+/=-]{1,64}$"
            }
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "decision": {
                  "const": "accept"
                }
              },
              "required": [
                "decision"
              ]
            },
            "then": {
              "required": [
                "subject_ref"
              ],
              "properties": {
                "result": {
                  "const": "MATCH"
                }
              }
            }
          },
          {
            "if": {
              "properties": {
                "decision": {
                  "const": "reject"
                }
              },
              "required": [
                "decision"
              ]
            },
            "then": {
              "properties": {
                "result": {
                  "enum": [
                    "NO_MATCH",
                    "LIVENESS_FAIL",
                    "NOT_ENROLLED"
                  ]
                }
              },
              "not": {
                "anyOf": [
                  {
                    "required": [
                      "subject_ref"
                    ]
                  },
                  {
                    "required": [
                      "onboard_ref"
                    ]
                  }
                ]
              }
            }
          },
          {
            "if": {
              "properties": {
                "decision": {
                  "const": "abstain"
                }
              },
              "required": [
                "decision"
              ]
            },
            "then": {
              "properties": {
                "result": {
                  "enum": [
                    "AMBIGUOUS",
                    "LOW_QUALITY",
                    "TIMEOUT",
                    "CANCELLED",
                    "RATE_LIMITED",
                    "BIOMETRIC_DISABLED",
                    "GALLERY_STALE",
                    "MODEL_MISMATCH",
                    "DEVICE_NOT_READY"
                  ]
                }
              },
              "not": {
                "anyOf": [
                  {
                    "required": [
                      "subject_ref"
                    ]
                  },
                  {
                    "required": [
                      "onboard_ref"
                    ]
                  }
                ]
              }
            }
          }
        ],
        "description": "Dados da passagem registrados pelo aparelho."
      },
      "LinkSignedVerdict": {
        "type": "object",
        "required": [
          "verdict",
          "alg",
          "signer_kid",
          "sig_b64"
        ],
        "properties": {
          "verdict": {
            "$ref": "#/components/schemas/LinkVerdict"
          },
          "alg": {
            "const": "ed25519"
          },
          "signer_kid": {
            "$ref": "#/components/schemas/LinkHex32"
          },
          "sig_b64": {
            "$ref": "#/components/schemas/LinkEd25519Sig"
          }
        },
        "description": "A passagem assinada pelo aparelho."
      },
      "LinkDecisionObj": {
        "type": "object",
        "required": [
          "v",
          "txn_id",
          "gate_id",
          "dbd_id",
          "nonce_b64",
          "verdict_ref",
          "reason",
          "outcome",
          "actuated",
          "decision_seq",
          "decided_at_ms"
        ],
        "properties": {
          "v": {
            "const": 1
          },
          "txn_id": {
            "$ref": "#/components/schemas/LinkHex32"
          },
          "gate_id": {
            "$ref": "#/components/schemas/LinkRef"
          },
          "dbd_id": {
            "$ref": "#/components/schemas/LinkRef"
          },
          "nonce_b64": {
            "$ref": "#/components/schemas/LinkNonce16"
          },
          "verdict_ref": {
            "$ref": "#/components/schemas/LinkHex32"
          },
          "reason": {
            "$ref": "#/components/schemas/LinkDecisionReason"
          },
          "outcome": {
            "$ref": "#/components/schemas/LinkDecisionOutcome"
          },
          "actuated": {
            "type": "boolean"
          },
          "decision_seq": {
            "$ref": "#/components/schemas/LinkUInt53"
          },
          "decided_at_ms": {
            "$ref": "#/components/schemas/LinkEpochMs"
          }
        },
        "if": {
          "properties": {
            "actuated": {
              "const": true
            }
          },
          "required": [
            "actuated"
          ]
        },
        "then": {
          "properties": {
            "reason": {
              "const": "ok"
            },
            "outcome": {
              "const": "LIBERAR"
            }
          }
        },
        "description": "Decisão do Validator Device sobre a passagem."
      },
      "LinkSignedDecision": {
        "type": "object",
        "required": [
          "decision_obj",
          "alg",
          "signer_kid",
          "sig_b64"
        ],
        "properties": {
          "decision_obj": {
            "$ref": "#/components/schemas/LinkDecisionObj"
          },
          "alg": {
            "const": "ed25519"
          },
          "signer_kid": {
            "$ref": "#/components/schemas/LinkHex32"
          },
          "sig_b64": {
            "$ref": "#/components/schemas/LinkEd25519Sig"
          }
        }
      },
      "LinkPassage": {
        "type": "object",
        "required": [
          "v",
          "txn_id",
          "dbd_id",
          "gate_id",
          "verdict_ref",
          "passed",
          "cause",
          "at_ms",
          "dbd_event_seq"
        ],
        "properties": {
          "v": {
            "const": 1
          },
          "txn_id": {
            "$ref": "#/components/schemas/LinkHex32"
          },
          "dbd_id": {
            "$ref": "#/components/schemas/LinkRef"
          },
          "gate_id": {
            "$ref": "#/components/schemas/LinkRef"
          },
          "verdict_ref": {
            "$ref": "#/components/schemas/LinkHex32"
          },
          "passed": {
            "type": "boolean"
          },
          "cause": {
            "type": "string",
            "enum": [
              "giro",
              "timeout",
              "reversao",
              "forcada"
            ]
          },
          "at_ms": {
            "$ref": "#/components/schemas/LinkEpochMs"
          },
          "dbd_event_seq": {
            "$ref": "#/components/schemas/LinkUInt53"
          }
        },
        "description": "Confirmação do giro da catraca."
      },
      "LinkSignedPassage": {
        "type": "object",
        "required": [
          "passage",
          "alg",
          "signer_kid",
          "sig_b64"
        ],
        "properties": {
          "passage": {
            "$ref": "#/components/schemas/LinkPassage"
          },
          "alg": {
            "const": "ed25519"
          },
          "signer_kid": {
            "$ref": "#/components/schemas/LinkHex32"
          },
          "sig_b64": {
            "$ref": "#/components/schemas/LinkEd25519Sig"
          }
        }
      },
      "LinkMailboxRecord": {
        "type": "object",
        "required": [
          "post",
          "ct_b64",
          "alg",
          "signer_kid",
          "sig_b64"
        ],
        "properties": {
          "post": {
            "type": "object",
            "required": [
              "v",
              "rid",
              "box",
              "src",
              "dst",
              "seq",
              "created_ms",
              "suite",
              "ct_len",
              "ct_sha256"
            ],
            "properties": {
              "v": {
                "const": 1
              },
              "rid": {
                "$ref": "#/components/schemas/LinkHex32"
              },
              "box": {
                "type": "string",
                "enum": [
                  "in",
                  "out"
                ]
              },
              "src": {
                "$ref": "#/components/schemas/LinkRef"
              },
              "dst": {
                "$ref": "#/components/schemas/LinkRef"
              },
              "seq": {
                "$ref": "#/components/schemas/LinkMsgId"
              },
              "created_ms": {
                "$ref": "#/components/schemas/LinkEpochMs"
              },
              "suite": {
                "type": "string",
                "enum": [
                  "hpke-x25519-sha256-chacha20poly1305"
                ]
              },
              "ct_len": {
                "type": "integer",
                "minimum": 48,
                "maximum": 67108864
              },
              "ct_sha256": {
                "$ref": "#/components/schemas/LinkHex64"
              }
            }
          },
          "ct_b64": {
            "$ref": "#/components/schemas/LinkB64"
          },
          "alg": {
            "const": "ed25519"
          },
          "signer_kid": {
            "$ref": "#/components/schemas/LinkHex32"
          },
          "sig_b64": {
            "$ref": "#/components/schemas/LinkEd25519Sig"
          },
          "signer_cert_b64": {
            "$ref": "#/components/schemas/LinkSignerCertB64"
          }
        },
        "allOf": [
          {
            "if": {
              "required": [
                "post"
              ],
              "properties": {
                "post": {
                  "required": [
                    "box"
                  ],
                  "properties": {
                    "box": {
                      "const": "in"
                    }
                  }
                }
              }
            },
            "then": {
              "required": [
                "signer_cert_b64"
              ],
              "properties": {
                "post": {
                  "properties": {
                    "src": {
                      "const": "bora"
                    }
                  }
                }
              }
            }
          },
          {
            "if": {
              "required": [
                "post"
              ],
              "properties": {
                "post": {
                  "required": [
                    "box"
                  ],
                  "properties": {
                    "box": {
                      "const": "out"
                    }
                  }
                }
              }
            },
            "then": {
              "not": {
                "required": [
                  "signer_cert_b64"
                ]
              },
              "properties": {
                "post": {
                  "properties": {
                    "dst": {
                      "const": "bora"
                    }
                  }
                }
              }
            }
          }
        ],
        "examples": [
          {
            "post": {
              "v": 1,
              "rid": "c41f2a9be07d4d3f9a6e5b2c1d0e8f7a",
              "box": "in",
              "src": "bora",
              "dst": "gate-bh-eldorado-03",
              "seq": 88,
              "created_ms": 1790849000000,
              "suite": "hpke-x25519-sha256-chacha20poly1305",
              "ct_len": 144,
              "ct_sha256": "7d8bbc540bbbfc01881f4becb42f2ff14c72d372a889bf04e3e0a07019e365fc"
            },
            "ct_b64": "TAc0sssnInErGpzmvTRKQb1f5wNinoQEfZvKHfG8DrjbuN1sZ3oAIPAOl1u/UG3lbMMpi9l756LtnMyruTrLn9PYmK5g1C7F3rI3xTWKOR5sbbVg+L2Z6V7MNLDnKKqxiPclJu5KxrYKxErFd1yleZcuCnC4aWnex4JcyE+D3UupqQN8hyyjLD4mJWsuIWBo",
            "alg": "ed25519",
            "signer_kid": "d9bf8bfe11bc109cb5687c77a5bf6581",
            "sig_b64": "5jX0VjNhwjUWHyiuX8AOmnbvKTvvYG4sY7XEkPwTriQsZuKxptnrEmv3h3/3DT8UJ1YCJX447ZU/TPcvi0eDCQ==",
            "signer_cert_b64": "kvCBJCkO7mgC+XHfZDDByN6Nkz2+zpLxXeQBnT3vemEAAAGixmd6QBQuCyvnDKjwbNqTrEAThAEsCj79FV04k648hrD4XcsbBS9kg8rvOZ6GUMWK38vKc0BIqjHSvQ8MeJ9UXLkoeAw="
          }
        ],
        "description": "Registro criptografado da Mailbox. Entregue do jeito que recebeu."
      }
    },
    "examples": {
      "SubjectPending": {
        "value": {
          "subject_id": "3f6c2a9e-8b1d-4e7a-9c3f-5d2e1a0b7c64",
          "external_ref": "000482913",
          "subject_ref": "2a16ce69bc964deda2b740bfe43edf4b",
          "onboard_ref": "obr-7Q2m9X",
          "status": "pending_enrollment",
          "block": null,
          "enrollment": null,
          "gallery_seq": null,
          "created_at": "2026-10-01T09:55:00.000Z",
          "updated_at": "2026-10-01T09:55:00.000Z",
          "livemode": true
        }
      },
      "SubjectActive": {
        "value": {
          "subject_id": "3f6c2a9e-8b1d-4e7a-9c3f-5d2e1a0b7c64",
          "external_ref": "000482913",
          "subject_ref": "2a16ce69bc964deda2b740bfe43edf4b",
          "onboard_ref": "obr-7Q2m9X",
          "status": "active",
          "block": null,
          "enrollment": {
            "hands": [
              "L",
              "R"
            ],
            "model_id": "bora-palm-ir-v1",
            "enrolled_at": "2026-10-01T10:02:41.120Z"
          },
          "gallery_seq": 15873,
          "created_at": "2026-10-01T09:55:00.000Z",
          "updated_at": "2026-10-01T10:02:41.120Z",
          "livemode": true
        }
      },
      "EnrollmentSessionOpen": {
        "value": {
          "session_id": "51d3e9a2-7c4b-4f1e-9a8d-2b3c4d5e6f70",
          "subject_id": "3f6c2a9e-8b1d-4e7a-9c3f-5d2e1a0b7c64",
          "status": "open",
          "failure_code": null,
          "hands_required": [
            "L",
            "R"
          ],
          "device_id": null,
          "completed_by_device_id": null,
          "enrollment_id": null,
          "token": "kJ3n9Qx2Lm8Vb7Rt5Yp1Zc4Wd6Fh0Gs2Aa9Ee3Ii7Oo",
          "qr_payload": "BORA1:ENR:51d3e9a2-7c4b-4f1e-9a8d-2b3c4d5e6f70:kJ3n9Qx2Lm8Vb7Rt5Yp1Zc4Wd6Fh0Gs2Aa9Ee3Ii7Oo",
          "short_code": "K7M2Q9XA",
          "expires_at": "2026-10-01T10:05:00.000Z",
          "created_at": "2026-10-01T10:00:00.000Z",
          "completed_at": null
        }
      },
      "EnrollmentSessionCompleted": {
        "value": {
          "session_id": "51d3e9a2-7c4b-4f1e-9a8d-2b3c4d5e6f70",
          "subject_id": "3f6c2a9e-8b1d-4e7a-9c3f-5d2e1a0b7c64",
          "status": "completed",
          "failure_code": null,
          "hands_required": [
            "L",
            "R"
          ],
          "device_id": null,
          "completed_by_device_id": "totem-central-01",
          "enrollment_id": "9b2f4c1e-7a3d-4e8b-a1c2-3d4e5f6a7b8c",
          "expires_at": "2026-10-01T10:05:00.000Z",
          "created_at": "2026-10-01T10:00:00.000Z",
          "completed_at": "2026-10-01T10:02:41.120Z"
        }
      },
      "VerdictProof": {
        "value": {
          "record": {
            "verdict_id": "42e1d185c8245b5cd45dfaae19194886",
            "txn_id": "7f3c9a1e5b2d4c6f8a0b1c2d3e4f5a6b",
            "device_id": "gate-bh-eldorado-03",
            "gate_id": "bh-eldorado-cat-03",
            "dbd_id": "dbd-bh-eldorado-03",
            "verdict_seq": 1042,
            "decision": "accept",
            "result": "MATCH",
            "subject_id": "3f6c2a9e-8b1d-4e7a-9c3f-5d2e1a0b7c64",
            "external_ref": "000482913",
            "hand": "R",
            "pad_res": "pass",
            "quality_q": 9120,
            "model_id": "bora-palm-ir-v1",
            "decided_at": "2026-10-01T10:20:00.840Z",
            "received_at": "2026-10-01T10:20:03.112Z",
            "dbd": {
              "reason": "ok",
              "outcome": "LIBERAR",
              "actuated": true,
              "decision_seq": 88123,
              "decided_at": "2026-10-01T10:20:00.861Z"
            },
            "passage": {
              "passed": true,
              "cause": "giro",
              "at": "2026-10-01T10:20:02.400Z"
            },
            "reconciliation": "complete"
          },
          "signed_verdict": {
            "verdict": {
              "v": 1,
              "txn_id": "7f3c9a1e5b2d4c6f8a0b1c2d3e4f5a6b",
              "gate_id": "bh-eldorado-cat-03",
              "dbd_id": "dbd-bh-eldorado-03",
              "nonce_b64": "nj8VYyTULw6ktvT86B1W+w==",
              "issued_at_ms": 1790850000000,
              "ttl_ms": 5000,
              "decided_at_ms": 1790850000840,
              "device_id": "gate-bh-eldorado-03",
              "decision": "accept",
              "result": "MATCH",
              "verdict_seq": 1042,
              "prev_ref": "be1ccf680c02a5ca3847db9540093045",
              "subject_ref": "2a16ce69bc964deda2b740bfe43edf4b",
              "onboard_ref": "obr-7Q2m9X",
              "hand": "R",
              "score_q": 8712,
              "margin_q": 2104,
              "quality_q": 9120,
              "pad": {
                "res": "pass",
                "mech": "ir-depth-v1",
                "score_q": 9650
              },
              "attempts": 1,
              "model_id": "bora-palm-ir-v1",
              "thr_id": "thr-2026-09-a",
              "gallery": {
                "stream": "main",
                "epoch": 3,
                "seq": 15872,
                "head16": "9f2e6d33a3717ee826353a404ba4618d"
              }
            },
            "alg": "ed25519",
            "signer_kid": "300290aeb182952c1337b227be5fe728",
            "sig_b64": "KLbRKtvRvNl4YHjXBdAvdJtsbUQbnChWSpFaEZkLnYJqd9yy/o6bgvnt3BEJgjj4KBvh9En7xNjwr83BSjxrCQ=="
          },
          "signed_decision": {
            "decision_obj": {
              "v": 1,
              "txn_id": "7f3c9a1e5b2d4c6f8a0b1c2d3e4f5a6b",
              "gate_id": "bh-eldorado-cat-03",
              "dbd_id": "dbd-bh-eldorado-03",
              "nonce_b64": "nj8VYyTULw6ktvT86B1W+w==",
              "verdict_ref": "42e1d185c8245b5cd45dfaae19194886",
              "reason": "ok",
              "outcome": "LIBERAR",
              "actuated": true,
              "decision_seq": 88123,
              "decided_at_ms": 1790850000861
            },
            "alg": "ed25519",
            "signer_kid": "4678808aef484c079515f89dbe4e1ef3",
            "sig_b64": "d255CvDFXFCpel1Sd50RAu7f8zVuwuY/4Aqf8JcLLJhQQDgWOp9UQvGLlcx4Ekjmdxk1SFWeIld/EU2pw1RpBw=="
          },
          "signed_passage": {
            "passage": {
              "v": 1,
              "txn_id": "7f3c9a1e5b2d4c6f8a0b1c2d3e4f5a6b",
              "dbd_id": "dbd-bh-eldorado-03",
              "gate_id": "bh-eldorado-cat-03",
              "verdict_ref": "42e1d185c8245b5cd45dfaae19194886",
              "passed": true,
              "cause": "giro",
              "at_ms": 1790850002400,
              "dbd_event_seq": 401220
            },
            "alg": "ed25519",
            "signer_kid": "4678808aef484c079515f89dbe4e1ef3",
            "sig_b64": "3efziP6G8MRTbeWSa6RyH9AAwizZExEdv1MXrhQWbpxVB56Hq1WnJYKovaJT0OcXtWcIS8jbnMBF6/B8rX91Aw=="
          },
          "verification": {
            "verdict_ref": "42e1d185c8245b5cd45dfaae19194886",
            "device_verdict_key": {
              "kid": "300290aeb182952c1337b227be5fe728",
              "alg": "ed25519",
              "pub_b64": "0mZcYF+l54oAZ/8dAsbliiXUbumVlpIjXGc8EDb6qO0="
            },
            "dbd_sign_key": {
              "kid": "4678808aef484c079515f89dbe4e1ef3",
              "alg": "ed25519",
              "pub_b64": "/EorC2SHripynSbtWpO3y0kvagTLyjyo+9rKeg/+YGs="
            },
            "prefixes": {
              "verdict": "bora.gate.verdict.v1",
              "decision": "bora.gate.decision.v1",
              "passage": "bora.gate.passage.v1"
            }
          }
        }
      }
    }
  }
}
