{
  "info": {
    "name": "Easy Invoices Documents API",
    "description": "Read-only API for the documents Easy Invoices issued for a shop: invoices, credit notes and cancellation invoices with their PDFs.\n\nPaste your API token into the collection's Authorization tab (Auth Type: Bearer Token), then send “First run”.\n\nReference: https://easy-invoices.de/en/documentation/api",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "",
        "type": "string"
      }
    ]
  },
  "variable": [
    {
      "key": "baseUrl",
      "value": "https://api.easy-invoices.de/api/v1",
      "type": "string"
    },
    {
      "key": "type",
      "value": "INVOICE",
      "type": "string",
      "description": "INVOICE, CREDIT_NOTE or CANCELLATION"
    },
    {
      "key": "updatedSince",
      "value": "2026-01-01T00:00:00Z",
      "type": "string",
      "description": "Starting point of the first run (ISO 8601)"
    },
    {
      "key": "cursor",
      "value": "",
      "type": "string",
      "description": "Set by the list requests"
    },
    {
      "key": "documentId",
      "value": "",
      "type": "string",
      "description": "Set by the list requests"
    }
  ],
  "item": [
    {
      "name": "First run",
      "request": {
        "method": "GET",
        "header": [],
        "description": "Lists the documents changed since `updatedSince`. Stores `nextCursor` (and the first document’s id) in the collection variables.\n\nList issued documents (change feed)",
        "url": {
          "raw": "{{baseUrl}}/public/documents?type={{type}}&updatedSince={{updatedSince}}",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "public",
            "documents"
          ],
          "query": [
            {
              "key": "type",
              "value": "{{type}}"
            },
            {
              "key": "updatedSince",
              "value": "{{updatedSince}}"
            }
          ],
          "variable": []
        }
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('responds 200', () => pm.response.to.have.status(200));",
              "if (pm.response.code === 200) {",
              "  const body = pm.response.json();",
              "  pm.collectionVariables.set('cursor', body.nextCursor);",
              "  if (body.data.length > 0) pm.collectionVariables.set('documentId', body.data[0].id);",
              "}"
            ]
          }
        }
      ]
    },
    {
      "name": "Following runs",
      "request": {
        "method": "GET",
        "header": [],
        "description": "Lists only what changed since the stored `cursor`, and stores the new one. Send again while `hasMore` is true.\n\nList issued documents (change feed)",
        "url": {
          "raw": "{{baseUrl}}/public/documents?type={{type}}&cursor={{cursor}}",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "public",
            "documents"
          ],
          "query": [
            {
              "key": "type",
              "value": "{{type}}"
            },
            {
              "key": "cursor",
              "value": "{{cursor}}"
            }
          ],
          "variable": []
        }
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('responds 200', () => pm.response.to.have.status(200));",
              "if (pm.response.code === 200) {",
              "  const body = pm.response.json();",
              "  pm.collectionVariables.set('cursor', body.nextCursor);",
              "  if (body.data.length > 0) pm.collectionVariables.set('documentId', body.data[0].id);",
              "}"
            ]
          }
        }
      ]
    },
    {
      "name": "Fetch the PDF",
      "request": {
        "method": "GET",
        "header": [],
        "description": "Downloads the PDF of `documentId` (set by the list requests). Use “Send and Download” to save it.\n\nDownload the PDF of an issued document",
        "url": {
          "raw": "{{baseUrl}}/public/documents/:id/pdf?type={{type}}",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "public",
            "documents",
            ":id",
            "pdf"
          ],
          "query": [
            {
              "key": "type",
              "value": "{{type}}"
            }
          ],
          "variable": [
            {
              "key": "id",
              "value": "{{documentId}}",
              "description": "Document id, as listed"
            }
          ]
        }
      }
    }
  ]
}
