{
  "info": {
    "name": "ERPDocs API v1",
    "description": "ERPDocs public REST API v1 — template-driven e-signature sending, bulk send, and webhooks.\n\nFull reference: https://www.erpdocs.com/developers\n\n## Setup\n1. Build a template in the UI first (Templates → Create a template). Sending is template-driven by default, but raw-PDF sending is also available: drop anchor tags (e.g. `{{sig:Role}}`, `{{text:Role:Label}}`) into the document and POST it to `/signpacks`. Without anchor tags, use embedded placement (requests 22-25: upload, place the fields in an iframe, send) or a template.\n2. Create API keys in **Admin → API & Webhooks** — `/admin/api/keys`.\n3. Create one **sandbox** key and one **live** key, both with all scopes.\n4. Set the `live_key` and `sandbox_key` collection variables.\n5. Set `base_url` to your host (`https://www.erpdocs.com`, or your staging host).\n6. Run `00 — Ping` first. It confirms the key, the org and the granted scopes before you debug anything else.\n\n## Try without signup\nA public demo key is printed on https://www.erpdocs.com/developers#try-it-now. It is a read-only sandbox key pointing at a synthetic demo org (sample templates, signpacks, users). Set `demo_key` to that value and run the \"Demo\" folder — no signup needed. Writes return `403 sandbox_write_blocked`; rate-limited to 30 req/min.\n\n## Pagination\nList endpoints use **`limit` and `offset`**. There is no `page` / `per_page`, and no cursor pagination.\n\n## Status filters are case-sensitive\n`GET /signpacks?status=` matches the envelope status **exactly**, and envelope statuses are capitalised: `Draft`, `Sent`, `In Progress`, `Completed`, `Declined`, `Expired`, `Cancelled`, `Correction Requested`, `Recalled`, `Imported`. An unknown or misspelled status is rejected with `400 invalid_status` (with an `allowed` list) — it does not silently return an empty list.\n\nBulk-send **row** statuses are different and lowercase: `pending`, `sent`, `failed`. An unknown row status is rejected with `400 invalid_status`.\n\n## New in v1.1\nRaw-PDF anchor-tag sending (`POST /signpacks`), envelope void (`POST /signpacks/{id}/void`), embedded signing (`POST /signpacks/{id}/recipients/{rid}/embed-token`) and brand profile management (`GET|POST|PATCH|DELETE /brands`, `POST /brands/{id}/set-default`) are all available and included in this collection. Drop anchor tags like `{{sig:Role}}` or `{{text:Role:Label}}` into your generated PDF and send without a template.\n\nBrand profile field names are `name`, `primary_color`, `email_sender_name`, `reply_to_email`, `email_header_html`, `email_footer_html` and `logo_path`. Upload a logo as a `logo` file part (`multipart/form-data`): a PNG, JPEG or WebP image up to 2 MB, otherwise `400 invalid_logo`. `logo_path` accepts only the `logo_path` of one of your own brands, or `null` to remove the logo. Responses also carry a read-only, permanent `logo_url`. Earlier revisions of the reference listed `logo_url` as writable and used `email_from_name` / `email_reply_to`; those names are silently ignored by the API.\n\n## Scopes\n- `signpack.read` — read envelopes and their recipients\n- `signpack.write` — create, send and remind on single envelopes\n- `signpack.bulk` — queue bulk sends (up to 1000 envelopes per request)\n- `signpack.embed` — mint embedded-signing tokens for iframe hosting\n- `template.read` — list templates and read their role/field contract\n- `workspace.read` — list workspaces\n- `user.read` — list organization members\n- `brand.read` — list and read brand profiles\n- `brand.write` — create, update and delete brand profiles, and set the default\n\n## Before you send\nReplace `sender_email` with an active user in **your** organization, and replace the role names (`Supplier`) and prefill labels (`Supplier Legal Name`) with the ones your own template actually defines. Run `02 — Get Template Contract` to read them.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    {
      "key": "demo_key",
      "value": "PASTE_DEMO_KEY_FROM_DEVELOPERS_PAGE",
      "type": "string"
    },
    {
      "key": "base_url",
      "value": "https://www.erpdocs.com",
      "type": "string"
    },
    {
      "key": "live_key",
      "value": "YOUR_LIVE_API_KEY",
      "type": "string"
    },
    {
      "key": "sandbox_key",
      "value": "YOUR_SANDBOX_API_KEY",
      "type": "string"
    },
    {
      "key": "sender_email",
      "value": "you@yourcompany.com",
      "type": "string"
    },
    {
      "key": "role_name",
      "value": "Supplier",
      "type": "string"
    },
    {
      "key": "prefill_label",
      "value": "Supplier Legal Name",
      "type": "string"
    },
    {
      "key": "template_id",
      "value": "1",
      "type": "string"
    },
    {
      "key": "signpack_id",
      "value": "1",
      "type": "string"
    },
    {
      "key": "recipient_id",
      "value": "",
      "description": "A recipient id from GET /signpacks/{id} -> recipients[].id. Required by the embedded-signing request."
    },
    {
      "key": "batch_id",
      "value": "1",
      "type": "string"
    },
    {
      "key": "brand_id",
      "value": "",
      "type": "string"
    },
    {
      "key": "verify_key",
      "value": "YOUR_VERIFY_SANDBOX_KEY",
      "type": "string",
      "description": "Sandbox key with verify.* scopes (Admin -> API & Webhooks). Sandbox never calls a government system."
    },
    {
      "key": "verify_session_id",
      "value": "",
      "type": "string",
      "description": "Set automatically by 'Create consent session'."
    },
    {
      "key": "verify_hosted_url",
      "value": "",
      "type": "string",
      "description": "Set automatically. Open it in a browser and approve to complete the session."
    },
    {
      "key": "verify_download_path",
      "value": "",
      "type": "string",
      "description": "Set automatically by 'Get session'. Single use."
    },
    {
      "key": "verify_request_id",
      "value": "",
      "type": "string",
      "description": "Set automatically by the lookups."
    },
    {
      "key": "subject_name",
      "value": "",
      "description": "The real name of the person this run is for. With a live key a made-up name fails the check against their DigiLocker documents. To test a failed check on a sandbox key, put the word mismatch in it.",
      "type": "string"
    },
    {
      "key": "subject_email",
      "value": "",
      "description": "The person's real email. Review results go here, so never use someone else's address with a live key.",
      "type": "string"
    },
    {
      "key": "journey_id",
      "value": "1",
      "type": "string",
      "description": "A flow id: the number at the end of the Studio address (Verify -> Flows -> the flow), or the id from GET /onboard/journeys."
    },
    {
      "key": "onboard_run_id",
      "value": "",
      "type": "string",
      "description": "Set automatically by 'Create Onboard run'."
    },
    {
      "key": "watch_id",
      "value": "",
      "type": "string",
      "description": "Set automatically by 'Add GSTIN to watchlist'."
    },
    {
      "key": "file_key",
      "value": ""
    },
    {
      "key": "placement_origin",
      "value": "https://app.yourcompany.com",
      "type": "string",
      "description": "The https origin of the page that will frame the placement screen. Register it on the API key first (Admin -> API & Webhooks)."
    },
    {
      "key": "placement_url",
      "value": "",
      "type": "string",
      "description": "Set automatically by requests 22 and 23. One-time link: open it in an iframe (see the guide), do not paste it in a browser tab you need later."
    }
  ],
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{live_key}}",
        "type": "string"
      }
    ]
  },
  "item": [
    {
      "name": "00 — Ping (credential check)",
      "request": {
        "method": "GET",
        "url": "{{base_url}}/api/v1/ping",
        "description": "Smoke test. Confirms key validity, organization, environment (`sandbox` or `live`) and granted scopes. Requires no scope — only a valid key.\n\nRun this before anything else. A 401 here means the key is wrong or revoked; nothing further will work."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('200 OK', () => pm.response.to.have.status(200));",
              "pm.test('rate-limit headers present', () => pm.response.to.have.header('X-RateLimit-Limit'));",
              "const b = pm.response.json();",
              "console.log('org:', b.org_name, '| env:', b.environment, '| scopes:', (b.scopes || []).join(', '));"
            ]
          }
        }
      ]
    },
    {
      "name": "01 — List Templates",
      "request": {
        "method": "GET",
        "url": "{{base_url}}/api/v1/templates",
        "description": "Templates this organization can send from. Scope: `template.read`.\n\nThis endpoint takes **no query parameters** — it returns every visible template in one `data` array. `type` is `user_template` or `document_template`; ids are only unique within a type."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('200 OK', () => pm.response.to.have.status(200));",
              "const rows = pm.response.json().data || [];",
              "if (rows.length) {",
              "  pm.collectionVariables.set('template_id', rows[0].id);",
              "  console.log('Using template', rows[0].id, '-', rows[0].name);",
              "} else {",
              "  console.warn('No templates. Build one in the UI (Templates -> Create a template) before sending.');",
              "}"
            ]
          }
        }
      ]
    },
    {
      "name": "02 — Get Template Contract",
      "request": {
        "method": "GET",
        "url": "{{base_url}}/api/v1/templates/{{template_id}}",
        "description": "The send contract for one template. Scope: `template.read`.\n\nReturns `roles[].name` (address these in `recipients`) and `prefillable_fields` (labels you may prefill). Build your mapping from this response, not from screenshots.\n\nSignature, DSC, attachment and checkbox fields can never be prefilled and are excluded from `prefillable_fields`."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('200 OK', () => pm.response.to.have.status(200));",
              "const b = pm.response.json();",
              "const roles = (b.roles || []).map(r => r.name);",
              "console.log('Roles to address:', roles.join(', ') || '(none - template is not sendable)');",
              "console.log('Prefillable labels:', (b.prefillable_fields || []).join(', ') || '(none)');",
              "if (roles.length) { pm.collectionVariables.set('role_name', roles[0]); }",
              "if ((b.prefillable_fields || []).length) { pm.collectionVariables.set('prefill_label', b.prefillable_fields[0]); }"
            ]
          }
        }
      ]
    },
    {
      "name": "03 — Send Single Envelope from Template",
      "request": {
        "method": "POST",
        "url": "{{base_url}}/api/v1/templates/{{template_id}}/send",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "options": {
            "raw": {
              "language": "json"
            }
          },
          "raw": "{\n  \"sender_email\": \"{{sender_email}}\",\n  \"title\": \"API Test \\u2014 Supplier Terms\",\n  \"recipients\": {\n    \"{{role_name}}\": {\n      \"name\": \"Jane Client\",\n      \"email\": \"jane.client@example.com\"\n    }\n  },\n  \"prefill\": {\n    \"{{prefill_label}}\": \"Northwind Ltd\"\n  },\n  \"expires_in_days\": 30,\n  \"send\": true,\n  \"brand_id\": null\n}"
        },
        "description": "Creates and immediately sends **one** envelope. Scope: `signpack.write`. Requires a **live** key — a sandbox key returns `403 sandbox_write_blocked` after the scope check but before the function body.\n\n`sender_email` is **required** and must be an active member of your org; envelopes with no sender break completion notifications.\n\n`expires_in_days` must be 1–365 — outside that range is rejected with `400 invalid_expiry`, not clamped.\n\nSet `\"send\": false` to stop at a Draft. `workspace_id` and `idempotency_key` are **not** accepted here (bulk-send only).\n\nRoles you omit fall back to the template's `default_name` / `default_email`.\n\n**`brand_id`** is optional. Omit it (or leave it `null`) to use the organization's default brand profile. Set it to a profile id from `16 — List Brand Profiles` to override branding for this envelope only. A non-integer returns `400 invalid_brand_id`; an id from another org returns `404 brand_not_found`."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "if (pm.response.code === 201) {",
              "  const b = pm.response.json();",
              "  pm.collectionVariables.set('signpack_id', b.id);",
              "  pm.test('no unmatched prefill labels', function () {",
              "    pm.expect(b.prefill_unmatched, 'these labels matched no prefillable field').to.eql([]);",
              "  });",
              "} else {",
              "  console.warn('Send failed:', pm.response.code, JSON.stringify(pm.response.json()));",
              "}"
            ]
          }
        }
      ]
    },
    {
      "name": "04 — Bulk Send (many recipients)",
      "request": {
        "method": "POST",
        "url": "{{base_url}}/api/v1/bulk-send",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "Idempotency-Key",
            "value": "bulk-test-{{$timestamp}}",
            "description": "Always send one. Without it, a network timeout you retry sends every envelope twice. A repeat with the same key returns 200 + idempotent_replay instead of re-sending."
          }
        ],
        "body": {
          "mode": "raw",
          "options": {
            "raw": {
              "language": "json"
            }
          },
          "raw": "{\n  \"template_id\": {{template_id}},\n  \"sender_email\": \"{{sender_email}}\",\n  \"expires_in_days\": 30,\n  \"rows\": [\n    {\n      \"reference\": \"SUP-1001\",\n      \"recipients\": {\n        \"{{role_name}}\": { \"name\": \"Client One\", \"email\": \"client1@example.com\" }\n      },\n      \"prefill\": { \"{{prefill_label}}\": \"Client One LLC\" }\n    },\n    {\n      \"reference\": \"SUP-1002\",\n      \"recipients\": {\n        \"{{role_name}}\": { \"name\": \"Client Two\", \"email\": \"client2@example.com\" }\n      },\n      \"prefill\": { \"{{prefill_label}}\": \"Client Two Inc\" }\n    }\n  ]\n}"
        },
        "description": "Queues up to 1000 envelopes from one template. Scope: `signpack.bulk` (deliberately separate from `signpack.write`). Requires a **live** key — a sandbox key returns `403 sandbox_write_blocked`.\n\nReturns `202` with a `batch_id` as soon as the batch is persisted; envelopes are created and mailed by background workers.\n\n**Validation is all-or-nothing.** One bad row rejects the whole batch with `400` and no batch is created; the 1-based row number is in `error.row`. Template-level problems (a signer with no fields, a DSC ordering violation) surface later as per-row failures instead.\n\nRate limit: **10 requests / minute** per key, separate from the 300/min default bucket.\n\n`recipients` also accepts a list: `[{\"role\": \"Supplier\", \"name\": \"...\", \"email\": \"...\"}]`. Every assignment needs a non-empty `email`."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "if (pm.response.code === 202) {",
              "  pm.collectionVariables.set('batch_id', pm.response.json().batch_id);",
              "  console.log('Batch queued:', pm.response.json().batch_id);",
              "} else if (pm.response.code === 200 && pm.response.json().idempotent_replay) {",
              "  console.log('Idempotent replay — original batch returned, nothing re-sent.');",
              "  pm.collectionVariables.set('batch_id', pm.response.json().batch_id);",
              "} else {",
              "  console.warn('Bulk send failed:', pm.response.code, JSON.stringify(pm.response.json()));",
              "}"
            ]
          }
        }
      ]
    },
    {
      "name": "05 — Get Batch Status",
      "request": {
        "method": "GET",
        "url": "{{base_url}}/api/v1/bulk-send/{{batch_id}}",
        "description": "Poll batch progress. Scope: `signpack.read`.\n\nLifecycle: `queued` → `processing` → `completed` | `partial` | `failed`. Status is derived from the row counters, never set by hand.\n\n**`partial` is a success and a failure at once.** The successful envelopes are already out and legally in flight — do not re-send the whole batch. Pull the failed rows, fix the cause, and re-submit only those with a new idempotency key.\n\nPrefer webhooks (`bulk_send.completed`) over tight polling."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('200 OK', () => pm.response.to.have.status(200));",
              "const b = pm.response.json();",
              "console.log(`status=${b.status} sent=${b.sent_count}/${b.total_rows} errors=${b.error_count}`);"
            ]
          }
        }
      ]
    },
    {
      "name": "06 — Get Batch Rows (per-envelope)",
      "request": {
        "method": "GET",
        "url": {
          "raw": "{{base_url}}/api/v1/bulk-send/{{batch_id}}/rows?limit=100&offset=0",
          "host": [
            "{{base_url}}"
          ],
          "path": [
            "api",
            "v1",
            "bulk-send",
            "{{batch_id}}",
            "rows"
          ],
          "query": [
            {
              "key": "limit",
              "value": "100",
              "description": "Default 100, clamped to 1-500."
            },
            {
              "key": "offset",
              "value": "0",
              "description": "Default 0."
            },
            {
              "key": "status",
              "value": "failed",
              "disabled": true,
              "description": "Row status filter: pending | sent | failed (lowercase). An unknown value returns 400 invalid_status rather than an empty page."
            }
          ]
        },
        "description": "Per-row status. Scope: `signpack.read`. Paged with **`limit` / `offset`**.\n\nReconcile against your own records via `reference`.\n\n**Read every row — do not filter to `status=failed` and stop.** `prefill_unmatched` is independent of `status`: a row can be `sent` and still report unmatched labels, meaning the envelope reached the counterparty with those fields blank. Treat any non-empty `prefill_unmatched` as a bug in your mapping (usually a label typo or a renamed template label).\n\nA `failed` row may still carry a `signpack_id` — the Draft was created but the send was rejected, and is kept deliberately so the org can fix and send it from the UI."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('200 OK', () => pm.response.to.have.status(200));",
              "const rows = pm.response.json().data || [];",
              "const unmatched = rows.filter(r => (r.prefill_unmatched || []).length);",
              "pm.test('no row has unmatched prefill labels', function () {",
              "  if (unmatched.length) {",
              "    console.warn('Rows sent with blank fields:', JSON.stringify(unmatched.map(r => ({ row: r.row, status: r.status, unmatched: r.prefill_unmatched }))));",
              "  }",
              "  pm.expect(unmatched.length, 'rows whose prefill labels matched nothing').to.eql(0);",
              "});"
            ]
          }
        }
      ]
    },
    {
      "name": "07 — List SignPacks",
      "request": {
        "method": "GET",
        "url": {
          "raw": "{{base_url}}/api/v1/signpacks?limit=50&offset=0",
          "host": [
            "{{base_url}}"
          ],
          "path": [
            "api",
            "v1",
            "signpacks"
          ],
          "query": [
            {
              "key": "limit",
              "value": "50",
              "description": "Default 50, clamped to 1-200."
            },
            {
              "key": "offset",
              "value": "0",
              "description": "Default 0."
            },
            {
              "key": "status",
              "value": "Sent",
              "disabled": true,
              "description": "CASE-SENSITIVE exact match. Valid: Draft, Sent, In Progress, Completed, Declined, Expired, Cancelled, Correction Requested, Recalled, Imported. An unknown or misspelled status returns 400 invalid_status (with an allowed list), not an empty page."
            }
          ]
        },
        "description": "Envelopes in the calling organization, newest first by `created_at`. Scope: `signpack.read`. Paged with **`limit` / `offset`**.\n\nThe `status` filter is an exact, **case-sensitive** match — see the parameter description."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('200 OK', () => pm.response.to.have.status(200));",
              "const rows = pm.response.json().data || [];",
              "if (rows.length) { pm.collectionVariables.set('signpack_id', rows[0].id); }",
              "if (!rows.length && pm.request.url.query.get('status')) {",
              "  console.warn('Empty result with a status filter set. Envelope statuses are capitalised — check the casing.');",
              "}"
            ]
          }
        }
      ]
    },
    {
      "name": "08 — Get SignPack Detail",
      "request": {
        "method": "GET",
        "url": "{{base_url}}/api/v1/signpacks/{{signpack_id}}",
        "description": "One envelope plus its recipients. Scope: `signpack.read`.\n\n`recipients[].role` is the ERPDocs role (`Signer`, `Reviewer`, `CC`, `Viewer`). `recipients[].template_role` is the template role name you addressed in `recipients` — use that to map back to your own data.\n\nRecipient statuses: `Pending`, `Sent`, `Viewed`, `Signed`, `Declined`, `Expired`."
      }
    },
    {
      "name": "09 — Download Signed Document",
      "request": {
        "method": "GET",
        "url": "{{base_url}}/api/v1/signpacks/{{signpack_id}}/download",
        "description": "A time-limited URL for the PAdES-sealed PDF. Scope: `signpack.read`.\n\nOnly valid once status is `Completed`; otherwise `409 not_completed`. `documents` always holds exactly one entry (there is no `document_id`), with `filename`, `url`, `sha256`, `pades_valid` and `finalized_at`.\n\nFetch the file promptly — do not persist the URL. Verify your download against `sha256`.\n\nOther errors: `404 signed_pdf_unavailable` (sealing never produced a file), `500 download_url_failed` (storage could not mint a URL)."
      }
    },
    {
      "name": "10 — Send Reminder",
      "request": {
        "method": "POST",
        "url": "{{base_url}}/api/v1/signpacks/{{signpack_id}}/remind",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "options": {
            "raw": {
              "language": "json"
            }
          },
          "raw": "{\n  \"message\": \"Friendly reminder — please sign at your earliest convenience.\"\n}"
        },
        "description": "Queues reminder emails. Scope: `signpack.write`. Requires a **live** key — a sandbox key returns `403 sandbox_write_blocked`.\n\nAllowed only for envelopes that can still be signed: `Sent`, `In Progress`, `Correction Requested`. Anything else returns `409 not_remindable`.\n\nOptional `recipient_ids` (array of ints) limits who is reminded; omit to remind all outstanding recipients. `message` is truncated to 1000 characters.\n\nThe reminder is attributed to the **envelope's original creator**, not to the API key — the audit trail and the email both show the original sender.\n\n`{\"queued\": true}` means the job was accepted, not that mail was delivered.\n\n**Recipient gate.** Beyond the envelope status, at least one selected recipient must be emailable. CC recipients, anyone who already signed or declined, and **embedded signers** are all skipped. If nothing remains, the call returns `409 no_remindable_recipients` rather than reporting success and sending nothing. Chasing an embedded signer is the host application's job.\n\n`queued: true` means the job was accepted, not that mail was delivered.\n\nErrors: `404 signpack_not_found`, `409 not_remindable`, `409 no_remindable_recipients`, `503 queue_failed`."
      },
      "event": []
    },
    {
      "name": "10b — Mint Embed Token",
      "request": {
        "method": "POST",
        "url": "{{base_url}}/api/v1/signpacks/{{signpack_id}}/recipients/{{recipient_id}}/embed-token",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{live_key}}",
            "type": "text"
          },
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"origin\": \"https://app.yourcompany.com\",\n  \"redirect_url\": \"https://app.yourcompany.com/signing/done\",\n  \"ttl_seconds\": 300,\n  \"signer_authenticated\": {\n    \"method\": \"password\",\n    \"identifier\": \"user@example.com\",\n    \"at\": \"2026-03-10T14:30:00Z\"\n  }\n}"
        },
        "description": "Mints a short-lived, single-use embedded-signing URL. Scope: `signpack.embed`. Requires a **live** key — sandbox returns `403 sandbox_write_blocked`.\n\n**Register the origin first** in Admin → API & Webhooks. The origin must be an exact https origin (no wildcards, no paths) and becomes the sole `frame-ancestors` CSP value for the session.\n\nPut the returned `sign_url` in your iframe `src`. It dies on first use. The signing page posts `ready`, `complete`, `decline` and `redirect` events to the parent via `postMessage`, restricted to your origin. The authoritative completion signal is the `signpack.completed` webhook.\n\nErrors: `400 origin_required`, `400 invalid_origin`, `403 origin_not_allowed`, `409 not_embeddable`, `409 already_signed`, `409 already_declined`, `400 invalid_ttl`."
      }
    },
    {
      "name": "11 — List Workspaces",
      "request": {
        "method": "GET",
        "url": "{{base_url}}/api/v1/workspaces",
        "description": "Workspaces in the calling organization. Scope: `workspace.read`.\n\nUse an `id` from here as `workspace_id` on `POST /bulk-send`."
      }
    },
    {
      "name": "12 — List Teams (legacy alias)",
      "request": {
        "method": "GET",
        "url": "{{base_url}}/api/v1/teams",
        "description": "Legacy alias of `/workspaces` — same handler, identical response. The model was renamed from Team to Workspace after this path shipped. Kept for existing integrations; build new code against `/workspaces`."
      }
    },
    {
      "name": "13 — List Users",
      "request": {
        "method": "GET",
        "url": "{{base_url}}/api/v1/users",
        "description": "Active members of the calling organization. Scope: `user.read`.\n\nUse this to find a valid `sender_email` — sends are rejected with `400 sender_not_found` if the address is not an active member."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('200 OK', () => pm.response.to.have.status(200));",
              "const rows = pm.response.json().data || [];",
              "if (rows.length) { console.log('Valid sender_email values:', rows.map(u => u.email).join(', ')); }"
            ]
          }
        }
      ]
    },
    {
      "name": "14 — Send Raw PDF with Anchor Tags",
      "request": {
        "method": "POST",
        "url": "{{base_url}}/api/v1/signpacks",
        "description": "Send a generated PDF with no template. Scope: `signpack.write`. Blocked for sandbox keys.\n\n**This is `multipart/form-data`, not JSON.** Attach a PDF/DOCX/image whose text layer contains anchor tags:\n`{{sig:Role}}`, `{{name:Role}}`, `{{date:Role}}`, `{{text:Role:Label}}`, `{{checkbox:Role:Label}}`, `{{email:Role}}`, `{{number:Role:Label}}`, `{{attachment:Role:Label}}`, `{{location:Role}}`, `{{tag:Value}}`.\n\nERPDocs finds each tag, removes it from the final PDF and places a real field there. The role in the tag must match a key in `recipients`. A recipient with at least one actionable field becomes a Signer; one with none becomes CC.\n\nSelect a file for the `file` key before sending — Postman cannot store the binary in the collection.\n\n**Always check `anchor_unrecognised` in the response.** Tags listed there were not understood, so the field you expected does not exist — and the call still returns 201.\n\n**Signing method per signer:** each recipient may carry `signature_method`: `\"esign\"` (default — drawn, typed or uploaded) or `\"dsc\"` (USB DSC token). See request 14b. The response's `recipients[]` carry `signature_method`, and `dsc_notices` lists any signing-order change ERPDocs made for DSC.\n\nErrors: `400 file_required`, `400 invalid_recipients`, `400 invalid_signature_method`, `400 dsc_signer_without_signature`, `400 dsc_not_enabled`, `400 invalid_expiry`, `400 invalid_brand_id`, `404 brand_not_found`, `403 sandbox_write_blocked`.",
        "body": {
          "mode": "formdata",
          "formdata": [
            {
              "key": "file",
              "type": "file",
              "src": [],
              "description": "PDF/DOCX/image containing anchor tags (required)"
            },
            {
              "key": "sender_email",
              "value": "{{sender_email}}",
              "type": "text"
            },
            {
              "key": "recipients",
              "value": "{\"{{role_name}}\":{\"name\":\"Ravi\",\"email\":\"ravi@example.com\",\"signature_method\":\"esign\"}}",
              "type": "text"
            },
            {
              "key": "title",
              "value": "Raw-PDF Anchor Test",
              "type": "text"
            },
            {
              "key": "signing_order",
              "value": "parallel",
              "type": "text"
            },
            {
              "key": "expires_in_days",
              "value": "30",
              "type": "text"
            },
            {
              "key": "send",
              "value": "false",
              "type": "text",
              "description": "false = create a Draft so you can inspect field placement first"
            },
            {
              "key": "brand_id",
              "value": "{{brand_id}}",
              "type": "text",
              "disabled": true
            }
          ]
        }
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('201 Created', () => pm.response.to.have.status(201));",
              "const b = pm.response.json();",
              "if (b.signpack_id) pm.collectionVariables.set('signpack_id', b.signpack_id);",
              "console.log('Fields detected:', b.field_count);",
              "const un = b.anchor_unrecognised || [];",
              "if (un.length) { console.warn('UNRECOGNISED ANCHORS:', un); }",
              "pm.test('no unrecognised anchors', () => pm.expect(un).to.be.an('array').that.is.empty);"
            ]
          }
        }
      ]
    },
    {
      "name": "14b — Send Raw PDF with a DSC signer (and an e-sign signer)",
      "request": {
        "method": "POST",
        "url": "{{base_url}}/api/v1/signpacks",
        "description": "Same as request 14, with one signer on a USB DSC token and one on e-sign. Scope: `signpack.write`. Blocked for sandbox keys.\n\nThe PDF needs `{{sig:Signer 1}}` and `{{sig:Signer 2}}` anchors. `\"signature_method\": \"dsc\"` turns that signer's signature fields into token fields; their name/date/text fields stay normal.\n\nRules:\n- A DSC signer must have a signature anchor → else `400 dsc_signer_without_signature`.\n- DSC must be on for your organization → else `400 dsc_not_enabled`; and your plan must include DSC → else `402 plan_upgrade_required` on send.\n- A pack that mixes methods is sent in sequence with DSC signers last, even if you ask for `parallel`. `dsc_notices` in the response says what changed.\n- DSC signers sign on a Windows or Mac computer with Chrome, Edge or Brave. Send them to https://www.erpdocs.com/dsc/setup before they sign.\n\nAny other value → `400 invalid_signature_method` (`allowed: [\"esign\", \"dsc\"]`).",
        "body": {
          "mode": "formdata",
          "formdata": [
            {
              "key": "file",
              "type": "file",
              "src": [],
              "description": "PDF with {{sig:Signer 1}} and {{sig:Signer 2}} anchors (required)"
            },
            {
              "key": "sender_email",
              "value": "{{sender_email}}",
              "type": "text"
            },
            {
              "key": "recipients",
              "value": "{\"Signer 1\":{\"name\":\"Ravi\",\"email\":\"ravi@example.com\",\"signature_method\":\"dsc\"},\"Signer 2\":{\"name\":\"Priya\",\"email\":\"priya@example.com\",\"signature_method\":\"esign\"}}",
              "type": "text"
            },
            {
              "key": "title",
              "value": "Raw-PDF DSC Test",
              "type": "text"
            },
            {
              "key": "signing_order",
              "value": "parallel",
              "type": "text",
              "description": "ERPDocs switches a mixed pack to sequential (DSC last) and says so in dsc_notices"
            },
            {
              "key": "send",
              "value": "true",
              "type": "text"
            }
          ]
        }
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('201 Created', () => pm.response.to.have.status(201));",
              "const b = pm.response.json();",
              "if (b.signpack_id) pm.collectionVariables.set('signpack_id', b.signpack_id);",
              "const methods = (b.recipients || []).map(r => r.signature_method);",
              "pm.test('one DSC and one e-sign signer', () => { pm.expect(methods).to.include('dsc'); pm.expect(methods).to.include('esign'); });",
              "pm.test('dsc_notices present', () => pm.expect(b.dsc_notices).to.be.an('array'));",
              "if ((b.dsc_notices || []).length) console.log('DSC notices:', b.dsc_notices);"
            ]
          }
        }
      ]
    },
    {
      "name": "15 — Void Envelope",
      "request": {
        "method": "POST",
        "url": "{{base_url}}/api/v1/signpacks/{{signpack_id}}/void",
        "description": "Permanently cancel an in-flight envelope. Scope: `signpack.write`. Blocked for sandbox keys.\n\nUnlike recall, void does NOT reset signatures or regenerate tokens. The envelope becomes `Cancelled`, signing links stop working immediately, and any unredeemed embedded handoff session expires at once. A best-effort cancellation email goes to non-embedded recipients.\n\nVoidable from `Sent`, `In Progress`, `Correction Requested`, `Recalled`. Anything else returns `409 not_voidable`.\n\nThere is no recall endpoint — recall is UI-only.\n\nErrors: `404 signpack_not_found`, `409 not_voidable`, `403 sandbox_write_blocked`.",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"reason\": \"Counterparty withdrew from the deal.\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('200 or 409', () => pm.expect([200,409]).to.include(pm.response.code));",
              "if (pm.response.code === 409) console.log('Not voidable in current status:', pm.response.json().error.message);"
            ]
          }
        }
      ]
    },
    {
      "name": "16 — List Brand Profiles",
      "request": {
        "method": "GET",
        "url": "{{base_url}}/api/v1/brands",
        "description": "Every brand profile in your organization. Scope: `brand.read`.\n\nExactly one has `is_default: true` and is applied to all sends that omit `brand_id`.\n\nField names: `name`, `primary_color`, `email_sender_name`, `reply_to_email`, `email_header_html`, `email_footer_html`, `logo_path`. `logo_url` is read-only and permanent; it returns `404` once the brand or its logo is removed. Upload a logo as a `logo` file part (PNG, JPEG or WebP, up to 2 MB). There is no `updated_at`."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('200 OK', () => pm.response.to.have.status(200));",
              "const rows = pm.response.json().data || [];",
              "if (rows.length) {",
              "  pm.collectionVariables.set('brand_id', rows[0].id);",
              "  const d = rows.find(b => b.is_default);",
              "  console.log('Default brand:', d ? d.name + ' (id ' + d.id + ')' : 'NONE');",
              "} else { console.warn('No brand profiles yet — run 17 to create one.'); }"
            ]
          }
        }
      ]
    },
    {
      "name": "17 — Create Brand Profile",
      "request": {
        "method": "POST",
        "url": "{{base_url}}/api/v1/brands",
        "description": "Create a brand profile. Scope: `brand.write`. Blocked for sandbox keys.\n\nThe first profile created for an org automatically becomes the default. Names must be unique.\n\nTo upload a logo, switch the body to `form-data` and add a `logo` file part alongside the other fields. That requires the API key to have a recorded creator, or you get `400 invalid_brand`. The logo must be a PNG, JPEG or WebP image up to 2 MB, otherwise `400 invalid_logo`.\n\nErrors: `400 brand_name_required`, `409 brand_name_exists`, `400 invalid_brand`, `400 invalid_logo`, `500 logo_upload_failed`, `500 brand_create_failed`.",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"name\": \"Postman Test Brand\",\n  \"primary_color\": \"#0891b2\",\n  \"email_sender_name\": \"Acme Legal\",\n  \"reply_to_email\": \"legal@acme.example\",\n  \"email_header_html\": \"\",\n  \"email_footer_html\": \"\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('201 Created', () => pm.response.to.have.status(201));",
              "const b = (pm.response.json() || {}).data || {};",
              "if (b.id) pm.collectionVariables.set('brand_id', b.id);",
              "pm.test('response is wrapped in data', () => pm.expect(pm.response.json()).to.have.property('data'));"
            ]
          }
        }
      ]
    },
    {
      "name": "18 — Get Brand Profile",
      "request": {
        "method": "GET",
        "url": "{{base_url}}/api/v1/brands/{{brand_id}}",
        "description": "Read one brand profile. Scope: `brand.read`.\n\nErrors: `404 brand_not_found` (also returned for a brand belonging to another org)."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('200 OK', () => pm.response.to.have.status(200));"
            ]
          }
        }
      ]
    },
    {
      "name": "19 — Update Brand Profile",
      "request": {
        "method": "PATCH",
        "url": "{{base_url}}/api/v1/brands/{{brand_id}}",
        "description": "Update a brand profile. Scope: `brand.write`. Blocked for sandbox keys. Only the fields you send change.\n\n`is_default` cannot be set here — use `POST /brands/{id}/set-default`.\n\nSending a writable string field as `\"\"` clears it to null. `logo_path` accepts only the `logo_path` of one of your own brands, or `null`; to add a new logo, send `form-data` with a `logo` file part (PNG, JPEG or WebP, up to 2 MB).\n\nErrors: `404 brand_not_found`, `400 brand_name_required`, `409 brand_name_exists`, `400 invalid_brand`, `400 invalid_logo`, `500 logo_upload_failed`, `500 brand_update_failed`.",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"primary_color\": \"#059669\",\n  \"email_sender_name\": \"Acme Contracts\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('200 OK', () => pm.response.to.have.status(200));"
            ]
          }
        }
      ]
    },
    {
      "name": "20 — Set Brand As Default",
      "request": {
        "method": "POST",
        "url": "{{base_url}}/api/v1/brands/{{brand_id}}/set-default",
        "description": "Make this profile the org default. Scope: `brand.write`. Blocked for sandbox keys.\n\nClears `is_default` on every other profile in one step. The default applies to every send that omits `brand_id`.\n\nErrors: `404 brand_not_found`, `500 brand_set_default_failed`.",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('200 OK', () => pm.response.to.have.status(200));",
              "pm.test('is now default', () => pm.expect(pm.response.json().data.is_default).to.eql(true));"
            ]
          }
        }
      ]
    },
    {
      "name": "21 — Delete Brand Profile",
      "request": {
        "method": "DELETE",
        "url": "{{base_url}}/api/v1/brands/{{brand_id}}",
        "description": "Delete a brand profile. Scope: `brand.write`. Blocked for sandbox keys.\n\n**The default profile CAN be deleted.** The oldest remaining profile is automatically promoted to default. There is no `cannot_delete_default` error — earlier docs claimed one, but it never existed.\n\nNote the response shape differs from the other brand endpoints: `{\"success\": true, \"deleted_id\": N}`, not wrapped in `data`.\n\nA later send passing this deleted id returns `404 brand_not_found`; it does not silently fall back to the default.\n\nErrors: `404 brand_not_found`, `500 brand_delete_failed`."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('200 OK', () => pm.response.to.have.status(200));",
              "pm.test('returns deleted_id', () => pm.expect(pm.response.json()).to.have.property('deleted_id'));"
            ]
          }
        }
      ]
    },
    {
      "name": "22 — Upload for placement",
      "request": {
        "method": "POST",
        "url": "{{base_url}}/api/v1/signpacks",
        "description": "Upload a document that has no anchor tags and get a one-time link to the placement screen. Scope: `signpack.write`. Blocked for sandbox keys.\n\n**This is `multipart/form-data`.** Select a PDF, DOCX or image for `file` (Postman cannot store the binary). `placement=true` makes the call create a **Draft** and return `placement_url`; nothing is sent and nobody is emailed. `send=true` together with `placement=true` is `400 invalid_send`.\n\nThe origin of the page that will frame the placement screen must be registered on the API key (Admin -> API & Webhooks). With exactly one registered origin `origin` may be left out; with two or more it is required.\n\n`allowed_fields` (comma-separated or a JSON list of `signature`, `name`, `date_signed`, `text`) must include `signature`. `recipients` is optional and only pre-fills signer slots (one per role, label = name); other keys such as `email` are not stored and come back as a `placement_recipient_fields_ignored` warning. `expires_in_days` counts from the send, not the upload.\n\n`placement_url` opens once and for 30 minutes (`placement_expires_at`). It is saved in the `placement_url` collection variable; show it in an iframe with the helper `https://www.erpdocs.com/static/js/erpdocs-embed.js`. Then send with request 24, or get a new link with request 23.\n\nIf `origin`, `allowed_fields` or `redirect_url` are sent without `placement=true` they are ignored and the response carries a `placement_params_ignored` warning.\n\nErrors: `400 invalid_placement`, `400 invalid_send`, `400 file_required`, `400 file_conversion_failed`, `400 file_unreadable`, `400 too_many_pages` (`max_pages`), `400 too_many_slots`, `400 origin_required`, `400 invalid_origin`, `403 origin_not_allowed`, `400 invalid_allowed_fields`, `400 invalid_redirect_url`, `400 invalid_recipients`, `400 invalid_slot_label`, `400 sender_not_found`, `403 sandbox_write_blocked`.",
        "body": {
          "mode": "formdata",
          "formdata": [
            {
              "key": "file",
              "type": "file",
              "src": [],
              "description": "PDF, DOCX or image (required)"
            },
            {
              "key": "sender_email",
              "value": "{{sender_email}}",
              "type": "text"
            },
            {
              "key": "placement",
              "value": "true",
              "type": "text"
            },
            {
              "key": "origin",
              "value": "{{placement_origin}}",
              "type": "text",
              "description": "Required only if the key has two or more registered origins"
            },
            {
              "key": "allowed_fields",
              "value": "signature,name,date_signed,text",
              "type": "text",
              "description": "Must include signature"
            },
            {
              "key": "title",
              "value": "Placement test",
              "type": "text"
            },
            {
              "key": "recipients",
              "value": "{\"Buyer\":{\"name\":\"Buyer\"}}",
              "type": "text",
              "disabled": true,
              "description": "Optional: pre-fills one signer slot per role"
            },
            {
              "key": "redirect_url",
              "value": "{{placement_origin}}/signing/done",
              "type": "text",
              "disabled": true,
              "description": "Optional: same origin as origin. The frame goes here after a send without sign_after"
            },
            {
              "key": "brand_id",
              "value": "{{brand_id}}",
              "type": "text",
              "disabled": true
            }
          ]
        }
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('201 Created', () => pm.response.to.have.status(201));",
              "const b = pm.response.json();",
              "pm.test('a Draft, nothing sent', () => pm.expect(b.status).to.eql('Draft'));",
              "pm.test('has a placement link', () => pm.expect(b.placement_url).to.be.a('string').and.include('/signpack/place/'));",
              "if (b.signpack_id) pm.collectionVariables.set('signpack_id', b.signpack_id);",
              "if (b.placement_url) pm.collectionVariables.set('placement_url', b.placement_url);",
              "const warn = b.warnings || [];",
              "pm.test('no ignored placement parameters', () => pm.expect(warn).to.be.an('array').that.is.empty);"
            ]
          }
        }
      ]
    },
    {
      "name": "23 — New placement link",
      "request": {
        "method": "POST",
        "url": "{{base_url}}/api/v1/signpacks/{{signpack_id}}/placement-url",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"origin\": \"{{placement_origin}}\"\n}"
        },
        "description": "A new one-time placement link for a placement Draft (use it to show the draft again). Scope: `signpack.write`. Blocked for sandbox keys.\n\n**The previous link and any open frame stop working.** The old frame's next save fails with `session_replaced`; everything already saved is kept and reappears in the new frame.\n\nThe body is optional. `origin` defaults to the key's only registered origin. Leave `allowed_fields` and `redirect_url` out to keep the previous link's values; `\"redirect_url\": \"\"` clears it. The new link is saved in the `placement_url` variable and is valid for 30 minutes (`placement_expires_at`).\n\nErrors: `404 signpack_not_found`, `400 invalid_body`, `409 draft_closed` (already sent or no longer a draft), `409 not_placement_draft`, `400 origin_required`, `400 invalid_origin`, `403 origin_not_allowed`, `400 invalid_allowed_fields`, `400 invalid_redirect_url`, `403 sandbox_write_blocked`."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('200 OK', () => pm.response.to.have.status(200));",
              "const b = pm.response.json();",
              "pm.test('has a placement link', () => pm.expect(b.placement_url).to.be.a('string').and.include('/signpack/place/'));",
              "if (b.placement_url) pm.collectionVariables.set('placement_url', b.placement_url);"
            ]
          }
        }
      ]
    },
    {
      "name": "24 — Send with signer mapping",
      "request": {
        "method": "POST",
        "url": "{{base_url}}/api/v1/signpacks/{{signpack_id}}/send",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"signers\": {\n    \"signer_1\": {\"name\": \"Ravi Menon\", \"email\": \"ravi@example.com\", \"signature_method\": \"esign\"},\n    \"signer_2\": {\"name\": \"Priya Raman\", \"email\": \"priya@example.com\"}\n  }\n}"
        },
        "description": "Send a placement Draft, giving every signer slot a person. Scope: `signpack.write`. Blocked for sandbox keys. Use real addresses only with a live key: the signers get the email.\n\n`signers` maps each slot key (`signer_1`, `signer_2`, ... as in `GET /signpacks/{id}` -> `slots[].key`) to `{name, email, signature_method?}` (`esign` default, or `dsc`). **Every slot must appear**, and every slot needs a signature field. Nothing is sent unless every check passes; each error names the slot keys at fault in `slots`.\n\nOptional `sign_after` (a slot key) lets that person sign straight away in your page: it needs `signer_authenticated` with `method`, `identifier` and `at` (ISO 8601; `authenticated_at` is accepted as another name for `at`, `at` preferred, and both with different times is refused). The response then carries a single-use `sign_url` or `sign_after_status` (`not_your_turn` / `session_failed`, with `sign_after_error` as a code). From this server call the key's verification floor applies; a send from the browser frame always makes the `sign_after` signer confirm their email with an ERPDocs code first.\n\nThe envelope expiry starts at the send (`expires_in_days` from the upload).\n\nErrors: `400 invalid_body`, `400 invalid_signers`, `400 no_signers`, `400 signer_without_signature`, `400 unmapped_slots`, `400 unknown_slot`, `400 invalid_signer_name`, `400 invalid_signer_email`, `400 invalid_signature_method`, `400 duplicate_signer_email`, `400 dsc_not_enabled`, `400 sign_after_required`, `400 invalid_signer_authenticated`, `409 not_sendable`, `409 already_sent` (a retry after a send), `500 email_queue_failed` (the envelope WAS sent but its emails could not be queued: do not resend; deliver the links with `POST /signpacks/{id}/remind`),`400 sender_not_found`, `402 plan_upgrade_required`, `402 plan_limit_reached`."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('200 OK', () => pm.response.to.have.status(200));",
              "const b = pm.response.json();",
              "pm.test('sent', () => pm.expect(b.status).to.eql('Sent'));",
              "pm.test('every slot became a recipient', () => pm.expect(b.recipients).to.be.an('array').that.is.not.empty);",
              "if (b.signpack_id) pm.collectionVariables.set('signpack_id', b.signpack_id);",
              "if (b.dsc_notices && b.dsc_notices.length) console.log('DSC notices:', b.dsc_notices);"
            ]
          }
        }
      ]
    },
    {
      "name": "25 — Delete draft",
      "request": {
        "method": "DELETE",
        "url": "{{base_url}}/api/v1/signpacks/{{signpack_id}}",
        "description": "Delete a Draft and every file it stored. Scope: `signpack.write`. Blocked for sandbox keys. Any key of the organization may delete.\n\nOnly drafts **created through the API** (placement drafts, or `POST /signpacks` with `send=false`) can be deleted. A draft made in the ERPDocs app or from a template is `409 not_deletable` (with `source`). Anything already sent is also `409 not_deletable`: use request 15 (void). An open placement frame reports `draft_closed` on its next save.\n\nErrors: `404 signpack_not_found`, `409 not_deletable`, `403 sandbox_write_blocked`."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('200 OK', () => pm.response.to.have.status(200));",
              "pm.test('success', () => pm.expect(pm.response.json().success).to.eql(true));"
            ]
          }
        }
      ]
    },
    {
      "name": "Demo — No signup needed",
      "description": "Uses the public demo key from https://www.erpdocs.com/developers#try-it-now. Read-only sandbox pointing at a synthetic demo org. Rate-limited to 30 req/min. No signup required — just paste the demo key into the `demo_key` collection variable.",
      "item": [
        {
          "name": "Demo — Ping",
          "auth": {
            "type": "bearer",
            "bearer": [
              {
                "key": "token",
                "value": "{{demo_key}}",
                "type": "string"
              }
            ]
          },
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/v1/ping",
            "description": "Confirms the demo key works. Response shows `environment: sandbox`, the demo org name, and all granted scopes (including write scopes — but writes are blocked by the sandbox guard)."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('200 OK', () => pm.response.to.have.status(200));",
                  "pm.test('sandbox environment', () => pm.expect(pm.response.json().environment).to.eql('sandbox'));",
                  "pm.test('demo org', () => pm.expect(pm.response.json().org_name).to.eql('ERPDocs Demo'));"
                ]
              }
            }
          ]
        },
        {
          "name": "Demo — List Templates",
          "auth": {
            "type": "bearer",
            "bearer": [
              {
                "key": "token",
                "value": "{{demo_key}}",
                "type": "string"
              }
            ]
          },
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/v1/templates",
            "description": "Returns the sample Demo NDA template (1 role, 2 fields)."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('200 OK', () => pm.response.to.have.status(200));",
                  "const rows = pm.response.json().data || [];",
                  "pm.test('has Demo NDA', () => pm.expect(rows.some(r => r.name === 'Demo NDA')).to.be.true);"
                ]
              }
            }
          ]
        },
        {
          "name": "Demo — List SignPacks",
          "auth": {
            "type": "bearer",
            "bearer": [
              {
                "key": "token",
                "value": "{{demo_key}}",
                "type": "string"
              }
            ]
          },
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/v1/signpacks",
            "description": "Returns the sample Demo NDA — Acme Co. envelope (status: Sent)."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('200 OK', () => pm.response.to.have.status(200));",
                  "const rows = pm.response.json().data || [];",
                  "pm.test('has sample signpack', () => pm.expect(rows.length).to.be.greaterThan(0));"
                ]
              }
            }
          ]
        },
        {
          "name": "Demo — Send (must be blocked)",
          "auth": {
            "type": "bearer",
            "bearer": [
              {
                "key": "token",
                "value": "{{demo_key}}",
                "type": "string"
              }
            ]
          },
          "request": {
            "method": "POST",
            "url": "{{base_url}}/api/v1/templates/1/send",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "options": {
                "raw": {
                  "language": "json"
                }
              },
              "raw": "{}"
            },
            "description": "Must return `403 sandbox_write_blocked`. The demo key is sandbox — writes are blocked regardless of scope."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('403 Forbidden', () => pm.response.to.have.status(403));",
                  "pm.test('code is sandbox_write_blocked', () => pm.expect(pm.response.json().error.code).to.eql('sandbox_write_blocked'));"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "Sandbox — Ping (reads work)",
      "auth": {
        "type": "bearer",
        "bearer": [
          {
            "key": "token",
            "value": "{{sandbox_key}}",
            "type": "string"
          }
        ]
      },
      "request": {
        "method": "GET",
        "url": "{{base_url}}/api/v1/ping",
        "description": "Confirms a sandbox key authenticates and can read. `environment` in the response should be `sandbox`.\n\nSandbox does **not** simulate signing — there is no way to fake a completed envelope or a `signpack.completed` webhook. It is only useful for exercising auth, scopes and read endpoints."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('200 OK', () => pm.response.to.have.status(200));",
              "pm.test('key is a sandbox key', () => pm.expect(pm.response.json().environment).to.eql('sandbox'));"
            ]
          }
        }
      ]
    },
    {
      "name": "Sandbox — Send (must be blocked)",
      "auth": {
        "type": "bearer",
        "bearer": [
          {
            "key": "token",
            "value": "{{sandbox_key}}",
            "type": "string"
          }
        ]
      },
      "request": {
        "method": "POST",
        "url": "{{base_url}}/api/v1/templates/{{template_id}}/send",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "options": {
            "raw": {
              "language": "json"
            }
          },
          "raw": "{\n  \"sender_email\": \"{{sender_email}}\",\n  \"recipients\": {\n    \"{{role_name}}\": {\n      \"name\": \"Test\",\n      \"email\": \"test@example.com\"\n    }\n  }\n}"
        },
        "description": "Must return `403 sandbox_write_blocked`. The sandbox environment check runs in the auth decorator after the scope check but before the function body, so no payload validation runs first. A sandbox key without `signpack.write` scope returns `403 insufficient_scope` instead."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('403 Forbidden', () => pm.response.to.have.status(403));",
              "pm.test('code is sandbox_write_blocked', () => pm.expect(pm.response.json().error.code).to.eql('sandbox_write_blocked'));"
            ]
          }
        }
      ]
    },
    {
      "name": "Errors — Missing credentials",
      "auth": {
        "type": "noauth"
      },
      "request": {
        "method": "GET",
        "url": "{{base_url}}/api/v1/ping",
        "description": "Must return `401 missing_credentials`.\n\nNote that auth and scope failures are returned **before** the rate limiter runs, so `401` and `403 insufficient_scope` carry **no** `X-RateLimit-*` headers. Do not read `X-RateLimit-Remaining` on those responses.\n\nEvery error uses the same envelope: `{\"error\": {\"code\": \"...\", \"message\": \"...\"}}`. Branch on `code`, never on `message`."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('401 Unauthorized', () => pm.response.to.have.status(401));",
              "pm.test('code is missing_credentials', () => pm.expect(pm.response.json().error.code).to.eql('missing_credentials'));",
              "pm.test('no rate-limit headers on auth failure', () => pm.expect(pm.response.headers.has('X-RateLimit-Limit')).to.be.false);"
            ]
          }
        }
      ]
    },
    {
      "name": "Verify & Onboard (early access)",
      "description": "ERPDocs Verify: consent-based DigiLocker / Entity Locker verification, KYB lookups, Onboard journeys. Register under Admin -> Verify first. Uses {{verify_key}}. Every POST sends an Idempotency-Key ({{$guid}} by default). Limits, sandbox identifiers and error codes: {{base_url}}/developers/verify. Reference: {{base_url}}/developers/api#erpdocs-verify-early-access",
      "auth": {
        "type": "bearer",
        "bearer": [
          {
            "key": "token",
            "value": "{{verify_key}}",
            "type": "string"
          }
        ]
      },
      "item": [
        {
          "name": "V01 — Sources live for this key",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/v1/verify/sources",
            "description": "Which sources this key can use. Sandbox keys: all available (mock). Live keys: only sources approved for ERPDocs.",
            "header": []
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('200', () => pm.response.to.have.status(200));",
                  "pm.test('rate-limit headers', () => pm.response.to.have.header('X-RateLimit-Limit'));"
                ]
              }
            }
          ]
        },
        {
          "name": "V02 — GSTIN lookup",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/api/v1/verify/gstin",
            "description": "Format and checksum are validated before any upstream call. Sandbox: 13th character picks the scenario (see /developers/verify). Live: available once API Setu approves GSTIN.",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{$guid}}",
                "description": "Required on every Verify POST. Same key + same body = same response, not billed again."
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"gstin\": \"27ABCDE1234F1Z0\",\n  \"purpose\": \"kyb_vendor_onboarding\",\n  \"reference_id\": \"vendor-001\",\n  \"name\": \"Sandbox Traders\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('200', () => pm.response.to.have.status(200));",
                  "const b = pm.response.json(); pm.collectionVariables.set('verify_request_id', b.id);",
                  "pm.test('found + match', () => { pm.expect(b.result.found).to.eql(true); pm.expect(b.result.match.name).to.be.above(79); });"
                ]
              }
            }
          ]
        },
        {
          "name": "V03 — GSTIN lookup (idempotent replay)",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/api/v1/verify/gstin",
            "description": "Send twice: the second response is identical and is not billed. Change the body with the same key to see 422 idempotency_key_reused.",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Idempotency-Key",
                "value": "postman-replay-demo-0001",
                "description": "Required on every Verify POST. Same key + same body = same response, not billed again."
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"gstin\": \"27ABCDE1234F1Z0\",\n  \"purpose\": \"kyb_vendor_onboarding\",\n  \"reference_id\": \"vendor-001\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('200', () => pm.response.to.have.status(200));"
                ]
              }
            }
          ]
        },
        {
          "name": "V04 — Udyam lookup",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/api/v1/verify/udyam",
            "description": "Live once API Setu approves Udyam.",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{$guid}}",
                "description": "Required on every Verify POST. Same key + same body = same response, not billed again."
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"udyam_number\": \"UDYAM-MH-00-0000001\",\n  \"purpose\": \"kyb_vendor_onboarding\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "V05 — PAN lookup (name match, name never returned)",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/api/v1/verify/pan",
            "description": "Returns masked PAN, status and a name/DOB match score. The name on PAN is not returned.",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{$guid}}",
                "description": "Required on every Verify POST. Same key + same body = same response, not billed again."
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"pan\": \"ABCPD0001E\",\n  \"name\": \"Sandbox Subject\",\n  \"purpose\": \"employee_onboarding_identity\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "V06 — Create consent session (DigiLocker)",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/api/v1/verify/sessions",
            "description": "Returns hosted_url (15 minutes, single use). Open it in a browser, tick the box, Continue, Allow. Aadhaar is always optional; required:true is rejected. redirect_url must exactly match your allowlist (Admin -> Verify), or omit it.",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{$guid}}",
                "description": "Required on every Verify POST. Same key + same body = same response, not billed again."
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"source\": \"digilocker\",\n  \"documents\": [\n    \"PANCR\",\n    {\n      \"type\": \"ADHAR\",\n      \"required\": false\n    }\n  ],\n  \"purpose\": \"employee_onboarding_identity\",\n  \"subject_hint\": {\n    \"name\": \"Priya Sharma\",\n    \"dob\": \"1994-03-12\"\n  },\n  \"reference_id\": \"hire-4821\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('201', () => pm.response.to.have.status(201));",
                  "const b = pm.response.json();",
                  "pm.collectionVariables.set('verify_session_id', b.id);",
                  "pm.collectionVariables.set('verify_hosted_url', b.hosted_url);",
                  "console.log('Open in a browser:', b.hosted_url);"
                ]
              }
            }
          ]
        },
        {
          "name": "V07 — Create consent session (Entity Locker)",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/api/v1/verify/sessions",
            "description": "A business shares its GST, incorporation or Udyam certificate.",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{$guid}}",
                "description": "Required on every Verify POST. Same key + same body = same response, not billed again."
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"source\": \"entitylocker\",\n  \"documents\": [\n    \"GSTIN_CERT\"\n  ],\n  \"purpose\": \"kyb_vendor_onboarding\",\n  \"subject_hint\": {\n    \"name\": \"Acme Traders Private Limited\"\n  }\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('201', () => pm.response.to.have.status(201));"
                ]
              }
            }
          ]
        },
        {
          "name": "V08 — Get session (results + download path)",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/v1/verify/sessions/{{verify_session_id}}",
            "description": "After approval: status completed, masked fields, match scores. Aadhaar returns masked number + match only, never a document.",
            "header": []
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('200', () => pm.response.to.have.status(200));",
                  "const b = pm.response.json();",
                  "const d = (b.results || []).find(r => r.document);",
                  "if (d) pm.collectionVariables.set('verify_download_path', d.document.download_path);"
                ]
              }
            }
          ]
        },
        {
          "name": "V09 — Download document (single use)",
          "request": {
            "method": "GET",
            "url": "{{base_url}}{{verify_download_path}}",
            "description": "First call returns the PDF. Any later call returns 410 document_purged. Undownloaded files are deleted after 15 minutes. ERPDocs keeps no copy.",
            "header": []
          }
        },
        {
          "name": "V10 — Cancel session",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/api/v1/verify/sessions/{{verify_session_id}}/cancel",
            "description": "Cancels a session that has not finished.",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{$guid}}",
                "description": "Required on every Verify POST. Same key + same body = same response, not billed again."
              }
            ]
          }
        },
        {
          "name": "V11 — Get any verification",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/v1/verify/requests/{{verify_request_id}}",
            "description": "Lookup or session by id.",
            "header": []
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('200', () => pm.response.to.have.status(200));"
                ]
              }
            }
          ]
        },
        {
          "name": "V12 — List verifications",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/v1/verify/requests?limit=25&page=1&reference_id=vendor-001",
            "description": "Paged; filter by reference_id or status.",
            "header": []
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('200', () => pm.response.to.have.status(200));"
                ]
              }
            }
          ]
        },
        {
          "name": "V13 — Usage, quota and wallet",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/v1/verify/usage",
            "description": "Units used today and this month, wallet balance, usage by SKU.",
            "header": []
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('200', () => pm.response.to.have.status(200));"
                ]
              }
            }
          ]
        },
        {
          "name": "V14 — Add GSTIN to re-verification watchlist",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/api/v1/verify/watchlist",
            "description": "Re-checked monthly; status changes fire verify.reverification.changed.",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{$guid}}",
                "description": "Required on every Verify POST. Same key + same body = same response, not billed again."
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"gstin\": \"27ABCDE1234F1Z0\",\n  \"reference_id\": \"vendor-001\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('201', () => pm.response.to.have.status(201));",
                  "pm.collectionVariables.set('watch_id', pm.response.json().id);"
                ]
              }
            }
          ]
        },
        {
          "name": "V15 — List watchlist",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/v1/verify/watchlist",
            "description": "Active GSTINs.",
            "header": []
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('200', () => pm.response.to.have.status(200));"
                ]
              }
            }
          ]
        },
        {
          "name": "V16 — Remove from watchlist",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/api/v1/verify/watchlist/{{watch_id}}/remove",
            "description": "Stops monthly checks.",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{$guid}}",
                "description": "Required on every Verify POST. Same key + same body = same response, not billed again."
              }
            ]
          }
        },
        {
          "name": "O01 — List Onboard journeys",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/v1/verify/onboard/journeys",
            "description": "Flows built in Verify -> Flows.",
            "header": []
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('200', () => pm.response.to.have.status(200));"
                ]
              }
            }
          ]
        },
        {
          "name": "O01b — Create Onboard journey (flow)",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/api/v1/verify/onboard/journeys",
            "description": "Creates a flow from a definition (schema 2 shown). Flows are usually built in the app (Verify › Flows). Invalid definitions return 400 invalid_flow with error.problems. The key needs a creating user.",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{$guid}}",
                "description": "Required on every Verify POST."
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Vendor onboarding (Postman)\",\n  \"kind\": \"kyb\",\n  \"steps\": {\n    \"schema\": 2,\n    \"steps\": [\n      {\n        \"id\": \"about\",\n        \"type\": \"collect\",\n        \"title\": \"About your business\",\n        \"fields\": [\n          {\n            \"key\": \"entity\",\n            \"label\": \"Business type\",\n            \"kind\": \"select\",\n            \"options\": [\n              \"Company\",\n              \"LLP\",\n              \"Proprietorship\"\n            ]\n          },\n          {\n            \"key\": \"cin\",\n            \"label\": \"CIN\",\n            \"kind\": \"text\",\n            \"show_if\": {\n              \"match\": \"all\",\n              \"rules\": [\n                {\n                  \"ref\": \"data.entity\",\n                  \"op\": \"is\",\n                  \"value\": \"Company\"\n                }\n              ]\n            }\n          }\n        ]\n      },\n      {\n        \"id\": \"which\",\n        \"type\": \"branch\",\n        \"title\": \"By business type\",\n        \"routes\": [\n          {\n            \"id\": \"co\",\n            \"name\": \"Companies\",\n            \"when\": {\n              \"match\": \"all\",\n              \"rules\": [\n                {\n                  \"ref\": \"data.entity\",\n                  \"op\": \"is\",\n                  \"value\": \"Company\"\n                }\n              ]\n            },\n            \"steps\": [\n              {\n                \"id\": \"reg\",\n                \"type\": \"upload\",\n                \"key\": \"registration\",\n                \"label\": \"Incorporation certificate\",\n                \"doc_kind\": \"registration\"\n              }\n            ]\n          },\n          {\n            \"id\": \"prop\",\n            \"name\": \"Proprietors\",\n            \"when\": {\n              \"match\": \"all\",\n              \"rules\": [\n                {\n                  \"ref\": \"data.entity\",\n                  \"op\": \"is\",\n                  \"value\": \"Proprietorship\"\n                }\n              ]\n            },\n            \"steps\": [\n              {\n                \"id\": \"nope\",\n                \"type\": \"end\",\n                \"outcome\": \"stop\",\n                \"message\": \"We onboard companies and LLPs only.\"\n              }\n            ]\n          }\n        ],\n        \"otherwise\": {\n          \"steps\": [\n            {\n              \"id\": \"terms\",\n              \"type\": \"notice\",\n              \"key\": \"llp_terms\",\n              \"title\": \"LLP terms\",\n              \"body\": \"Partners sign separately.\"\n            }\n          ]\n        }\n      }\n    ]\n  }\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('201', () => pm.response.to.have.status(201));",
                  "pm.collectionVariables.set('journey_id', pm.response.json().id);"
                ]
              }
            }
          ]
        },
        {
          "name": "O02 — Create Onboard run",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/api/v1/verify/onboard/runs",
            "description": "Returns link (7 days) and resumed. Same reference_id while that person's run is open: 200, resumed=true, same link (no second run). Optional return_url (must be on your return-address allowlist): the person's last page offers a way back to it with ?run_id=&status= (unsigned: confirm with GET or a webhook). The person opens link: consent -> match -> agreement signed in SignPack -> evidence pack. Sandbox simulates the signing step.",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{$guid}}",
                "description": "Required on every Verify POST. Same key + same body = same response, not billed again."
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"journey_id\": \"{{journey_id}}\",\n  \"subject\": {\n    \"name\": \"{{subject_name}}\",\n    \"email\": \"{{subject_email}}\"\n  },\n  \"reference_id\": \"hire-4821\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('201 new or 200 resumed', () => pm.expect([200, 201]).to.include(pm.response.code));",
                  "const b = pm.response.json(); pm.collectionVariables.set('onboard_run_id', b.id); console.log('Open:', b.link);"
                ]
              }
            }
          ]
        },
        {
          "name": "O03 — Get Onboard run",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/v1/verify/onboard/runs/{{onboard_run_id}}",
            "description": "Status, match outcome, SignPack id, evidence fingerprint.",
            "header": []
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('200', () => pm.response.to.have.status(200));"
                ]
              }
            }
          ]
        },
        {
          "name": "O03b — Get what the person gave you (full values)",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/v1/verify/onboard/runs/{{onboard_run_id}}/data",
            "description": "Needs verify.onboard AND verify.onboard.data. Details, files and acknowledgements with full values; every call is logged. Never includes DigiLocker / Entity Locker documents. 410 data_purged once deleted.",
            "header": []
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('200', () => pm.response.to.have.status(200));",
                  "const f = (pm.response.json().files || [])[0]; if (f) pm.collectionVariables.set('file_key', f.key);"
                ]
              }
            }
          ]
        },
        {
          "name": "O03c — Download one uploaded file",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/v1/verify/onboard/runs/{{onboard_run_id}}/files/{{file_key}}",
            "description": "One file the person uploaded (key from O03b). X-Content-SHA256 header. Can be downloaded again until the data is deleted.",
            "header": []
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('200', () => pm.response.to.have.status(200));"
                ]
              }
            }
          ]
        },
        {
          "name": "O04 — Download evidence pack",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/v1/verify/onboard/runs/{{onboard_run_id}}/evidence",
            "description": "PAdES-sealed PDF of results and hashes (no document images). X-Content-SHA256 header carries its fingerprint.",
            "header": []
          }
        },
        {
          "name": "O05 — Download face image (live selfie, single use)",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/v1/verify/onboard/runs/{{onboard_run_id}}/face/selfie",
            "description": "Single-use hand-over of the live selfie (journey face step with `deliver_images: true`). 200 = JPEG; 410 once handed over or deleted (ERPDocs deletes its copy after download or 72 h); 409 while the run waits for your review; 403 if the journey does not hand over images. Plan §22.14.",
            "header": []
          }
        },
        {
          "name": "O06 — Download face image (uploaded ID, single use)",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/v1/verify/onboard/runs/{{onboard_run_id}}/face/id",
            "description": "Single-use hand-over of the uploaded ID (journey face step with `deliver_images: true`). 200 = JPEG; 410 once handed over or deleted (ERPDocs deletes its copy after download or 72 h); 409 while the run waits for your review; 403 if the journey does not hand over images. Plan §22.14.",
            "header": []
          }
        },
        {
          "name": "VE1 — Error: Aadhaar marked required",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/api/v1/verify/sessions",
            "description": "Expect 400 aadhaar_cannot_be_required.",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{$guid}}",
                "description": "Required on every Verify POST. Same key + same body = same response, not billed again."
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"source\": \"digilocker\",\n  \"documents\": [\n    {\n      \"type\": \"ADHAR\",\n      \"required\": true\n    }\n  ],\n  \"purpose\": \"employee_onboarding_identity\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('400', () => pm.response.to.have.status(400));",
                  "pm.test('code', () => pm.expect(pm.response.json().error.code).to.eql('aadhaar_cannot_be_required'));"
                ]
              }
            }
          ]
        },
        {
          "name": "VE2 — Error: missing Idempotency-Key",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/api/v1/verify/gstin",
            "description": "Expect 400 idempotency_key_required.",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"gstin\": \"27ABCDE1234F1Z0\",\n  \"purpose\": \"kyb_vendor_onboarding\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('400', () => pm.response.to.have.status(400));",
                  "pm.test('code', () => pm.expect(pm.response.json().error.code).to.eql('idempotency_key_required'));"
                ]
              }
            }
          ]
        },
        {
          "name": "VE3 — Error: invalid GSTIN checksum",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/api/v1/verify/gstin",
            "description": "Rejected locally; never reaches the government source.",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{$guid}}",
                "description": "Required on every Verify POST. Same key + same body = same response, not billed again."
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"gstin\": \"27ABCDE1234F1Z9\",\n  \"purpose\": \"kyb_vendor_onboarding\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('400', () => pm.response.to.have.status(400));",
                  "pm.test('code', () => pm.expect(pm.response.json().error.code).to.eql('invalid_identifier'));"
                ]
              }
            }
          ]
        }
      ]
    }
  ]
}
