{
  "info": {
    "_postman_id": "e3b8d5a9-2a1a-4f2a-9b66-ledgerize-api",
    "name": "Ledgerize Public API",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "description": "Postman collection for the Ledgerize Public API (upload, convert, poll, result)."
  },
  "variable": [
    { "key": "BASE_URL", "value": "https://ledgerize.ai" },
    { "key": "API_KEY", "value": "YOUR_LEDGERIZE_API_KEY" },
    { "key": "UUID", "value": "<set-after-upload>" },
    { "key": "JOB_ID", "value": "<set-after-convert>" },
    { "key": "FORMAT", "value": "JSON" }
  ],
  "item": [
    {
      "name": "Upload PDF",
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "try {",
              "  const json = pm.response.json();",
              "  if (json && json.uuid) {",
              "    pm.collectionVariables.set('UUID', json.uuid);",
              "  }",
              "} catch (e) {}"
            ]
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [
          { "key": "X-Api-Key", "value": "{{API_KEY}}" }
        ],
        "body": {
          "mode": "formdata",
          "formdata": [
            { "key": "file", "type": "file", "src": [] }
          ]
        },
        "url": { "raw": "{{BASE_URL}}/api/v1/files", "host": ["{{BASE_URL}}"], "path": ["api","v1","files"] }
      },
      "response": []
    },
    {
      "name": "Set Password (optional)",
      "request": {
        "method": "POST",
        "header": [
          { "key": "X-Api-Key", "value": "{{API_KEY}}" },
          { "key": "Content-Type", "value": "application/json" }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"password\": \"your_pdf_password\"\n}"
        },
        "url": { "raw": "{{BASE_URL}}/api/v1/files/{{UUID}}/password", "host": ["{{BASE_URL}}"], "path": ["api","v1","files","{{UUID}}","password"] }
      },
      "response": []
    },
    {
      "name": "Convert",
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "try {",
              "  const json = pm.response.json();",
              "  if (json && json.jobId) {",
              "    pm.collectionVariables.set('JOB_ID', json.jobId);",
              "  }",
              "} catch (e) {}"
            ]
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [
          { "key": "X-Api-Key", "value": "{{API_KEY}}" },
          { "key": "Content-Type", "value": "application/json" }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"ids\": [\"{{UUID}}\"],\n  \"format\": \"{{FORMAT}}\"\n}"
        },
        "url": { "raw": "{{BASE_URL}}/api/v1/convert", "host": ["{{BASE_URL}}"], "path": ["api","v1","convert"] }
      },
      "response": []
    },
    {
      "name": "Job Status",
      "request": {
        "method": "GET",
        "header": [ { "key": "X-Api-Key", "value": "{{API_KEY}}" } ],
        "url": { "raw": "{{BASE_URL}}/api/v1/jobs/{{JOB_ID}}", "host": ["{{BASE_URL}}"], "path": ["api","v1","jobs","{{JOB_ID}}"] }
      },
      "response": []
    },
    {
      "name": "Job Result",
      "request": {
        "method": "GET",
        "header": [ { "key": "X-Api-Key", "value": "{{API_KEY}}" } ],
        "url": { "raw": "{{BASE_URL}}/api/v1/jobs/{{JOB_ID}}/result", "host": ["{{BASE_URL}}"], "path": ["api","v1","jobs","{{JOB_ID}}","result"] }
      },
      "response": []
    }
  ]
}
