{
  "info": {
    "name": "Belfort Persons Vault API",
    "description": "Colección de Postman (BEL-450) para el hello-world de la Persons Vault API -- crea una Person de sandbox, verifica con el CURP mágico, revela la PII, busca, exporta (ARCO) y registra un webhook. Ver docs/api/persons-vault-quickstart.md para el paso a paso narrado y docs/api/core-idv-openapi.yaml para el contrato completo de verificación.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    { "key": "baseUrl", "value": "https://api.belfort.ai", "type": "string" },
    { "key": "apiKey", "value": "belfort_test_sk_...", "type": "string" },
    { "key": "personId", "value": "", "type": "string" },
    { "key": "personIdRaw", "value": "", "type": "string" },
    { "key": "sessionId", "value": "", "type": "string" },
    { "key": "endpointId", "value": "", "type": "string" }
  ],
  "auth": {
    "type": "bearer",
    "bearer": [{ "key": "token", "value": "{{apiKey}}", "type": "string" }]
  },
  "item": [
    {
      "name": "Persons",
      "item": [
        {
          "name": "Create sandbox Person (magic CURP)",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "url": { "raw": "{{baseUrl}}/v1/persons", "host": ["{{baseUrl}}"], "path": ["v1", "persons"] },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"pii\": {\n    \"curp\": \"TESTCURP0APPROVED0\",\n    \"fullName\": \"Ada Lovelace\"\n  }\n}"
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "const body = pm.response.json();",
                  "pm.collectionVariables.set('personId', body.id);",
                  "pm.collectionVariables.set('personIdRaw', String(body.id).replace(/^per_/, ''));"
                ]
              }
            }
          ]
        },
        {
          "name": "Search persons (structured)",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "url": { "raw": "{{baseUrl}}/v1/persons/search", "host": ["{{baseUrl}}"], "path": ["v1", "persons", "search"] },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"field\": \"curp\",\n  \"value\": \"TESTCURP0APPROVED0\"\n}"
            }
          }
        },
        {
          "name": "Get Person detail (masked)",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/v1/persons/{{personId}}",
              "host": ["{{baseUrl}}"],
              "path": ["v1", "persons", "{{personId}}"]
            }
          }
        },
        {
          "name": "Decrypt (reveal verified PII)",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "url": {
              "raw": "{{baseUrl}}/v1/persons/{{personId}}/decrypt",
              "host": ["{{baseUrl}}"],
              "path": ["v1", "persons", "{{personId}}", "decrypt"]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"fields\": [\"curp\", \"full_name\"],\n  \"purpose\": \"identity_verification\",\n  \"reason\": \"Retención del expediente KYC post-verificación\"\n}"
            }
          }
        },
        {
          "name": "Export (ARCO -- derecho de acceso)",
          "request": {
            "method": "POST",
            "url": {
              "raw": "{{baseUrl}}/v1/persons/{{personId}}/export?reason=Solicitud ARCO del titular",
              "host": ["{{baseUrl}}"],
              "path": ["v1", "persons", "{{personId}}", "export"],
              "query": [{ "key": "reason", "value": "Solicitud ARCO del titular" }]
            }
          }
        }
      ]
    },
    {
      "name": "Verify (cross-ref core-idv-openapi.yaml)",
      "item": [
        {
          "name": "Create verification session (channel=api)",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "url": {
              "raw": "{{baseUrl}}/v1/verification-sessions",
              "host": ["{{baseUrl}}"],
              "path": ["v1", "verification-sessions"]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"channel\": \"api\",\n  \"personId\": \"{{personIdRaw}}\"\n}"
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "const body = pm.response.json();",
                  "pm.collectionVariables.set('sessionId', body.id);"
                ]
              }
            }
          ]
        },
        {
          "name": "Submit (dispara la evaluación)",
          "request": {
            "method": "POST",
            "url": {
              "raw": "{{baseUrl}}/v1/verification-sessions/{{sessionId}}/submit",
              "host": ["{{baseUrl}}"],
              "path": ["v1", "verification-sessions", "{{sessionId}}", "submit"]
            }
          }
        }
      ]
    },
    {
      "name": "Webhooks",
      "item": [
        {
          "name": "Register webhook endpoint",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "url": {
              "raw": "{{baseUrl}}/v1/developer/webhooks",
              "host": ["{{baseUrl}}"],
              "path": ["v1", "developer", "webhooks"]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"url\": \"https://example.com/webhooks/belfort\",\n  \"events\": [\"person.*\"],\n  \"environment\": \"test\"\n}"
            }
          }
        },
        {
          "name": "List webhook endpoints",
          "request": {
            "method": "GET",
            "url": { "raw": "{{baseUrl}}/v1/developer/webhooks", "host": ["{{baseUrl}}"], "path": ["v1", "developer", "webhooks"] }
          }
        },
        {
          "name": "Send test event (belfort.test ping)",
          "request": {
            "method": "POST",
            "url": {
              "raw": "{{baseUrl}}/v1/developer/webhooks/{{endpointId}}/test",
              "host": ["{{baseUrl}}"],
              "path": ["v1", "developer", "webhooks", "{{endpointId}}", "test"]
            }
          }
        }
      ]
    }
  ]
}
