{
  "info": {
    "name": "VeriKYC — Public API",
    "_postman_id": "f0d1831e-09bb-4c47-a5c8-b4cd4220d5f8",
    "description": "Collection chính thức cho VeriKYC (kyc.baylenvietnam.com).\n\nBiến môi trường:\n- base_url: https://kyc.baylenvietnam.com\n- api_key: lk_live_...\n- verify_code: mã verify để test GET /verify/:code\n- webhook_secret: secret của webhook (dùng cho /verify-signature)\n- webhook_payload: raw JSON body để test signature\n- webhook_signature: chuỗi hex HMAC để test signature",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    { "key": "base_url", "value": "https://kyc.baylenvietnam.com" },
    { "key": "api_key", "value": "lk_live_REPLACE_ME" },
    { "key": "verify_code", "value": "abc123def456" },
    { "key": "webhook_secret", "value": "whsec_demo_secret_change_me" },
    { "key": "webhook_payload", "value": "{\"event\":\"session.completed\",\"workspace_id\":\"ws-uuid\",\"delivered_at\":\"2026-01-12T08:30:00Z\",\"data\":{\"session_id\":\"8b1f24a0-1a2b-4c3d-9e8f-aabbccddeeff\",\"verify_code\":\"abc123def456\",\"check_url\":\"https://kyc.baylenvietnam.com/check/abc123def456\",\"verify_api_url\":\"https://kyc.baylenvietnam.com/api/public/v1/verify/abc123def456\",\"verify_expires_at\":\"2027-01-12T08:30:00Z\",\"status\":\"Approved\",\"verify_state\":\"verified\",\"decision\":{\"id_verifications\":[{\"first_name\":\"Nguyen Van\",\"last_name\":\"A\"}]}}}" },
    { "key": "webhook_signature", "value": "875e58667d47970a42418e9bcd27b4232ae2c4acfbbec27db0641a8548a1a43b" }
  ],
  "item": [
    {
      "name": "Sessions — Create",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Authorization", "value": "Bearer {{api_key}}" },
          { "key": "Content-Type", "value": "application/json" }
        ],
        "url": { "raw": "{{base_url}}/api/public/v1/sessions", "host": ["{{base_url}}"], "path": ["api","public","v1","sessions"] },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"vendor_data\": \"user-123\",\n  \"callback_url\": \"https://your-app.com/kyc/done\",\n  \"language\": \"vi\"\n}"
        },
        "description": "Tạo phiên KYC mới. Trả về `url` để redirect end-user, kèm `verify_code` / `check_url` / `verify_api_url`."
      }
    },
    {
      "name": "Verify — GET by code",
      "request": {
        "method": "GET",
        "header": [],
        "url": { "raw": "{{base_url}}/api/public/v1/verify/{{verify_code}}", "host": ["{{base_url}}"], "path": ["api","public","v1","verify","{{verify_code}}"] },
        "description": "Kiểm tra trạng thái xác minh public. Không cần auth. Trả state: verified | pending | declined | expired | revoked | not_found | invalid."
      }
    },
    {
      "name": "Webhook — Verify signature",
      "request": {
        "method": "POST",
        "header": [{ "key": "Content-Type", "value": "application/json" }],
        "url": { "raw": "{{base_url}}/api/public/v1/verify-signature", "host": ["{{base_url}}"], "path": ["api","public","v1","verify-signature"] },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"secret\": \"{{webhook_secret}}\",\n  \"payload\": {{webhook_payload}},\n  \"signature\": \"{{webhook_signature}}\"\n}"
        },
        "description": "Helper để kiểm tra header X-Lovable-Signature có khớp với HMAC-SHA256(payload, secret) hay không. Trả {valid, expected}."
      }
    },
    {
      "name": "Webhook samples (reference — không gọi)",
      "item": [
        {
          "name": "session.created",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" },
              { "key": "X-Lovable-Event", "value": "session.created" },
              { "key": "X-Lovable-Signature", "value": "a18999f17beaf420801d8ea1c8c3d6708fa265de78913853c467f644fb8705ef" },
              { "key": "X-Lovable-Attempt", "value": "1" }
            ],
            "url": { "raw": "https://your-app.com/webhooks/kyc", "host": ["your-app","com"], "path": ["webhooks","kyc"] },
            "body": {
              "mode": "raw",
              "raw": "{\"event\":\"session.created\",\"workspace_id\":\"ws-uuid\",\"delivered_at\":\"2026-01-12T08:30:00Z\",\"data\":{\"session_id\":\"8b1f24a0-1a2b-4c3d-9e8f-aabbccddeeff\",\"verify_code\":\"abc123def456\",\"check_url\":\"https://kyc.baylenvietnam.com/check/abc123def456\",\"verify_api_url\":\"https://kyc.baylenvietnam.com/api/public/v1/verify/abc123def456\",\"verify_expires_at\":\"2027-01-12T08:30:00Z\",\"status\":\"Not Started\",\"verify_state\":\"pending\"}}"
            },
            "description": "Mẫu payload + signature (secret demo = whsec_demo_secret_change_me)."
          }
        },
        {
          "name": "session.updated",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" },
              { "key": "X-Lovable-Event", "value": "session.updated" },
              { "key": "X-Lovable-Signature", "value": "530b809bafd302865e4798e6b414faa933faee4d4dfadcc7985a910798482f17" },
              { "key": "X-Lovable-Attempt", "value": "1" }
            ],
            "url": { "raw": "https://your-app.com/webhooks/kyc", "host": ["your-app","com"], "path": ["webhooks","kyc"] },
            "body": {
              "mode": "raw",
              "raw": "{\"event\":\"session.updated\",\"workspace_id\":\"ws-uuid\",\"delivered_at\":\"2026-01-12T08:30:00Z\",\"data\":{\"session_id\":\"8b1f24a0-1a2b-4c3d-9e8f-aabbccddeeff\",\"verify_code\":\"abc123def456\",\"check_url\":\"https://kyc.baylenvietnam.com/check/abc123def456\",\"verify_api_url\":\"https://kyc.baylenvietnam.com/api/public/v1/verify/abc123def456\",\"verify_expires_at\":\"2027-01-12T08:30:00Z\",\"status\":\"In Progress\",\"verify_state\":\"pending\"}}"
            }
          }
        },
        {
          "name": "session.completed",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" },
              { "key": "X-Lovable-Event", "value": "session.completed" },
              { "key": "X-Lovable-Signature", "value": "875e58667d47970a42418e9bcd27b4232ae2c4acfbbec27db0641a8548a1a43b" },
              { "key": "X-Lovable-Attempt", "value": "1" }
            ],
            "url": { "raw": "https://your-app.com/webhooks/kyc", "host": ["your-app","com"], "path": ["webhooks","kyc"] },
            "body": {
              "mode": "raw",
              "raw": "{\"event\":\"session.completed\",\"workspace_id\":\"ws-uuid\",\"delivered_at\":\"2026-01-12T08:30:00Z\",\"data\":{\"session_id\":\"8b1f24a0-1a2b-4c3d-9e8f-aabbccddeeff\",\"verify_code\":\"abc123def456\",\"check_url\":\"https://kyc.baylenvietnam.com/check/abc123def456\",\"verify_api_url\":\"https://kyc.baylenvietnam.com/api/public/v1/verify/abc123def456\",\"verify_expires_at\":\"2027-01-12T08:30:00Z\",\"status\":\"Approved\",\"verify_state\":\"verified\",\"decision\":{\"id_verifications\":[{\"first_name\":\"Nguyen Van\",\"last_name\":\"A\"}]}}}"
            }
          }
        },
        {
          "name": "session.failed",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" },
              { "key": "X-Lovable-Event", "value": "session.failed" },
              { "key": "X-Lovable-Signature", "value": "4b5dea7199114d8b9612090b31abf0fde1603bf2320fdf27b0aeffebd0873dcc" },
              { "key": "X-Lovable-Attempt", "value": "1" }
            ],
            "url": { "raw": "https://your-app.com/webhooks/kyc", "host": ["your-app","com"], "path": ["webhooks","kyc"] },
            "body": {
              "mode": "raw",
              "raw": "{\"event\":\"session.failed\",\"workspace_id\":\"ws-uuid\",\"delivered_at\":\"2026-01-12T08:30:00Z\",\"data\":{\"session_id\":\"8b1f24a0-1a2b-4c3d-9e8f-aabbccddeeff\",\"verify_code\":\"abc123def456\",\"check_url\":\"https://kyc.baylenvietnam.com/check/abc123def456\",\"verify_api_url\":\"https://kyc.baylenvietnam.com/api/public/v1/verify/abc123def456\",\"verify_expires_at\":\"2027-01-12T08:30:00Z\",\"status\":\"Failed\",\"verify_state\":\"pending\"}}"
            }
          }
        }
      ]
    }
  ]
}
