{
  "info": {
    "name": "PageAnchor API",
    "description": "Public API of PageAnchor: create an archive, read it, get text/markdown, compare versions, download the evidence package, subscribe to webhooks.\n\nSet the collection variables first: `baseUrl` (https://pageanchor.app) and `apiKey` (pk_live_...). Every request uses the same Bearer key.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "_postman_id": "0f5c9d1e-6b5a-4d2f-9d1a-7c3e5b8a4f21"
  },
  "variable": [
    { "key": "baseUrl", "value": "https://pageanchor.app" },
    { "key": "apiKey", "value": "pk_live_your_key_here" },
    { "key": "archiveId", "value": "" }
  ],
  "auth": {
    "type": "bearer",
    "bearer": [{ "key": "token", "value": "{{apiKey}}", "type": "string" }]
  },
  "item": [
    {
      "name": "Create archive",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Content-Type", "value": "application/json" },
          { "key": "Idempotency-Key", "value": "{{$guid}}", "description": "8–128 chars; a retry with the same key returns the same archive without spending quota." }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"url\": \"https://example.com/article\"\n}"
        },
        "url": { "raw": "{{baseUrl}}/api/v1/archive", "host": ["{{baseUrl}}"], "path": ["api", "v1", "archive"] },
        "description": "Returns `{ id, status, cached, archive_url }`. Status is `queued` first: the capture runs in a worker."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "const data = pm.response.json();",
              "if (data.id) pm.collectionVariables.set('archiveId', data.id);"
            ]
          }
        }
      ]
    },
    {
      "name": "Get archive (status, files, hashes)",
      "request": {
        "method": "GET",
        "url": { "raw": "{{baseUrl}}/api/v1/archive/{{archiveId}}", "host": ["{{baseUrl}}"], "path": ["api", "v1", "archive", "{{archiveId}}"] }
      }
    },
    {
      "name": "Text of the capture",
      "request": {
        "method": "GET",
        "url": { "raw": "{{baseUrl}}/api/v1/archive/{{archiveId}}/text", "host": ["{{baseUrl}}"], "path": ["api", "v1", "archive", "{{archiveId}}", "text"] },
        "description": "text/plain. Available after the capture is done."
      }
    },
    {
      "name": "Markdown of the capture",
      "request": {
        "method": "GET",
        "url": { "raw": "{{baseUrl}}/api/v1/archive/{{archiveId}}/markdown", "host": ["{{baseUrl}}"], "path": ["api", "v1", "archive", "{{archiveId}}", "markdown"] }
      }
    },
    {
      "name": "Diff two versions",
      "request": {
        "method": "GET",
        "url": {
          "raw": "{{baseUrl}}/api/v1/archive/{{archiveId}}/diff?from=1&to=2",
          "host": ["{{baseUrl}}"],
          "path": ["api", "v1", "archive", "{{archiveId}}", "diff"],
          "query": [
            { "key": "from", "value": "1" },
            { "key": "to", "value": "2" }
          ]
        },
        "description": "Text diff between two captures of the same archive. Needs at least two versions."
      }
    },
    {
      "name": "Evidence package (ZIP)",
      "request": {
        "method": "GET",
        "url": { "raw": "{{baseUrl}}/api/v1/archive/{{archiveId}}/package", "host": ["{{baseUrl}}"], "path": ["api", "v1", "archive", "{{archiveId}}", "package"] },
        "description": "ZIP with files, manifest, timestamp, authority certificate and a README that explains how to verify it without us."
      }
    },
    {
      "name": "List archives",
      "request": {
        "method": "GET",
        "url": {
          "raw": "{{baseUrl}}/api/v1/archives?limit=20",
          "host": ["{{baseUrl}}"],
          "path": ["api", "v1", "archives"],
          "query": [{ "key": "limit", "value": "20" }]
        }
      }
    },
    {
      "name": "Delete archive",
      "request": {
        "method": "DELETE",
        "url": { "raw": "{{baseUrl}}/api/v1/archive/{{archiveId}}", "host": ["{{baseUrl}}"], "path": ["api", "v1", "archive", "{{archiveId}}"] }
      }
    },
    {
      "name": "Webhooks",
      "item": [
        {
          "name": "Create webhook",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"url\": \"https://your-service.example/hooks/pageanchor\"\n}"
            },
            "url": { "raw": "{{baseUrl}}/api/v1/webhooks", "host": ["{{baseUrl}}"], "path": ["api", "v1", "webhooks"] },
            "description": "The response contains `secret` once. Verify deliveries with HMAC-SHA256 over `<t>.<body>` from X-PageAnchor-Signature."
          }
        },
        {
          "name": "List webhooks",
          "request": {
            "method": "GET",
            "url": { "raw": "{{baseUrl}}/api/v1/webhooks", "host": ["{{baseUrl}}"], "path": ["api", "v1", "webhooks"] }
          }
        }
      ]
    }
  ]
}
