---
title: "Integrate with your SaaS · EenFactuurMaken.nl"
description: "Step-by-step guide for an integration from your web shop, CRM or SaaS. An Invoices key, your own ids, create and issue in one request, fetching the PDF and webhooks."
url: "https://eenfactuurmaken.nl/en/docs/api/integrate"
markdown_url: "https://eenfactuurmaken.nl/en/docs/api/integrate.md"
language: "en-GB"
---

# Integrate with your SaaS

Step-by-step guide for an integration from your web shop, CRM or SaaS. An Invoices key, your own ids, create and issue in one request, fetching the PDF and webhooks.

Building an integration from your own software, such as a web shop, CRM, booking system or SaaS? Then one request gives you an issued invoice, you fetch the PDF, and a webhook tells you when it has been paid. This guide walks through the steps with curl and Node.js. Want an overview first? See the [invoice API](https://eenfactuurmaken.nl/en/invoice-api) page.

## Overview

An integration usually looks like this:

1. You create an **API key with Invoices access**.
2. You create the **customer** with your own id (`externalId`), or look it up.
3. You create the **invoice** and **issue** it in the same request (`"issue": true`), with an `Idempotency-Key` so retrying is safe.
4. You fetch the **PDF** or let EenFactuurMaken.nl **email** the invoice.
5. With Pro, a **webhook** tells you when the invoice is sent, paid or cancelled.

> **From your server only**
>
> Call the API from your own server, never from a browser or an app on your customer's device. The API doesn't allow browser requests from other websites (no CORS), and your key would be visible to everyone there.

## A key with Invoices access

Create a key under **Settings → API & AI** and choose **Invoices** under **Access**. With that key your software can:

- read everything (invoices, customers, products, PDFs, UBL and exports);
- create and update customers, products and invoices;
- issue, send, credit and mark invoices paid.

It can't delete or cancel anything, create quotes or touch your settings, so a leaked key does limited damage. You choose the access when you create the key and can't change it later. All levels are listed under [Authentication](https://eenfactuurmaken.nl/en/docs/api/authentication#permissions).

Put the key in an environment variable, for example `EENFACTUURMAKEN_API_KEY`, and send it as `Authorization: Bearer efm_…`.

## The customer

Give every customer the id from your own system as `externalId`. That's 1 to 100 characters (letters, digits and punctuation, no spaces), unique within your account.

```bash
curl -X POST https://eenfactuurmaken.nl/api/v1/customers \
  -H "Authorization: Bearer $EENFACTUURMAKEN_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "externalId": "cus_9",
    "type": "business",
    "name": "Bakkerij De Gouden Korst B.V.",
    "email": "administratie@goudenkorst.nl",
    "addressLine1": "Marktstraat 12",
    "postalCode": "3511 AB",
    "city": "Utrecht",
    "country": "NL",
    "kvkNumber": "12345678"
  }'
```

If a customer with that `externalId` already exists, archived ones included, you get `409 external_id_taken` with the id of that customer:

```json
{
  "statusCode": 409,
  "data": {
    "code": "external_id_taken",
    "details": { "resource": "customer", "id": "9d2c1b0a-…", "archived": false }
  }
}
```

Nothing to worry about: the customer exists, and you simply use `details.id`. This check runs before the 25-customer limit of the Free plan, so a repeat always gets 409, never 402.

On the invoice you then refer to the customer with **`customerExternalId`**, so you don't even need our id. If no customer has that id, you get `422 unknown_customer`. You can also use `customerId`, or send the customer inline in `customer` (we create it right away). Don't combine `customerExternalId` with either of those.

> **Sending the customer inline**
>
> If you send the customer inline in `customer` with an `externalId` that already exists, you get `409 external_id_taken` with `details.resource: "customer"`. So for an existing customer, use `customerExternalId`.

## Create and issue

With `"issue": true` you create the invoice and issue it in **one transaction**. You get the issued invoice back, with its number, or an error. A half-made draft is never left behind.

```bash
curl -X POST https://eenfactuurmaken.nl/api/v1/invoices \
  -H "Authorization: Bearer $EENFACTUURMAKEN_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 4f3c9a7e-2b1d-4c6e-8a90-5d7f1e2b3c4a" \
  -d '{
    "externalId": "order-1042",
    "customerExternalId": "cus_9",
    "issue": true,
    "reference": "Order 1042",
    "lines": [
      { "description": "Annual subscription Basic", "quantity": "1", "unitPriceCents": 12000, "vatRate": "21" }
    ]
  }'
```

The same in Node.js (18 or newer):

```js
import { randomUUID } from 'node:crypto'

const res = await fetch('https://eenfactuurmaken.nl/api/v1/invoices', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.EENFACTUURMAKEN_API_KEY}`,
    'Content-Type': 'application/json',
    'Idempotency-Key': randomUUID(), // store it with the order and reuse it on a retry
  },
  body: JSON.stringify({
    externalId: 'order-1042',
    customerExternalId: 'cus_9',
    issue: true,
    reference: 'Order 1042',
    lines: [{ description: 'Annual subscription Basic', quantity: '1', unitPriceCents: 12000, vatRate: '21' }],
  }),
})
const invoice = await res.json()
if (!res.ok) throw new Error(invoice.data.code)
console.log(invoice.number, invoice.status, invoice.totalCents) // "2026-0042" "issued" 14520
```

- Whatever you leave out, we fill in like the app does: today's dates, the payment term, and the language and VAT treatment of the customer or your business. See [Formats and pagination](https://eenfactuurmaken.nl/en/docs/api/conventions#defaults).
- With `"issue": true`, `number` and `issueDate` act as the choices you make when issuing: your own number or a different invoice date.
- The invoice's `externalId` (`order-1042`) makes sure a repeat never creates a second invoice: the second time you get `409 external_id_taken` with the id, status and kind of the existing invoice.
- The `Idempotency-Key` makes a retry after a timeout or network error simply return the first response. See [Idempotent requests](https://eenfactuurmaken.nl/en/docs/api/idempotency).
- Create a credit note the same way with `"kind": "credit_note"`. Credit notes don't count towards your monthly limit.

Want to see or check the invoice as a draft first? Leave out `issue` and issue it later with `POST /invoices/{id}/issue`.

## When it goes wrong

When a request with `"issue": true` fails, **nothing** has been created: no draft, no new customer from `customer` and no invoice used from your monthly limit. So you can just try again once you've fixed the problem.

| Status and code | What it means | What to do |
| --- | --- | --- |
| `422 invoice_not_compliant` | The invoice doesn't meet the Dutch requirements. `data.details` lists each point with `level`, `field` and `code`. | Fix the points with `level: "error"`. Often it's your own business details (KvK number, VAT ID, IBAN) or the customer's VAT number. All codes are under [Invoice checks](https://eenfactuurmaken.nl/en/docs/invoices/checks). |
| `422 invoice_not_compliant` (VIES) | For `intra_eu` and `reverse_charge` we check the customer's VAT number in VIES. Invalid blocks. | Check the VAT number. If VIES is briefly unavailable, you only get a warning and it goes ahead. See [VIES check](https://eenfactuurmaken.nl/en/docs/vat/vies). |
| `422 invoice_not_compliant` (KvK) | As a Dutch business you need a KvK number, unless you're not in the Handelsregister. | Add your KvK number to your [business details](https://eenfactuurmaken.nl/en/docs/getting-started/business-details). |
| `402 plan_limit_reached` | Your 5 free invoices for this month are used up. | Wait until next month or upgrade to [Pro](https://eenfactuurmaken.nl/en/docs/billing/plans). |
| `403 session_required` | You sent your own `paymentLink` that differs from your default payment link. That's only possible in the web app. | Leave out `paymentLink`, and we use the default payment link from your business details. |
| `409 number_taken` | The `number` you sent already exists. | Leave out `number` to get the next number. |
| `409 external_id_taken` | An invoice with this `externalId` already exists. | Fetch it with `details.id`. If it's still a `draft`, issue it with `POST /invoices/{id}/issue`. |
| `422 unknown_customer` | No customer with this `customerExternalId`. | Create the customer first. |

All codes are listed under [Errors and limits](https://eenfactuurmaken.nl/en/docs/api/errors).

## Fetching the PDF and the e-invoice

```bash
curl "https://eenfactuurmaken.nl/api/v1/invoices/$INVOICE_ID/pdf?download=1" \
  -H "Authorization: Bearer $EENFACTUURMAKEN_API_KEY" -o invoice.pdf
curl "https://eenfactuurmaken.nl/api/v1/invoices/$INVOICE_ID/ubl" \
  -H "Authorization: Bearer $EENFACTUURMAKEN_API_KEY" -o invoice.xml
```

In Node.js:

```js
import { writeFile } from 'node:fs/promises'

const res = await fetch(`https://eenfactuurmaken.nl/api/v1/invoices/${invoice.id}/pdf?download=1`, {
  headers: { Authorization: `Bearer ${process.env.EENFACTUURMAKEN_API_KEY}` },
})
if (!res.ok) throw new Error(`PDF: ${res.status}`)
await writeFile(`${invoice.number}.pdf`, Buffer.from(await res.arrayBuffer()))
```

- The UBL is the e-invoice (Peppol BIS Billing 3.0 / NLCIUS) for your customer's accounting software. Without a KvK number you get `409 peppol_kvk_required`. See [PDF and e-invoice](https://eenfactuurmaken.nl/en/docs/invoices/pdf-and-ubl).
- A download with `?download=1`, or of the UBL, counts as [a download by you](https://eenfactuurmaken.nl/en/docs/retention#downloaded), also with a Read only key. On the Free plan we delete a downloaded invoice after 60 days even if a warning email didn't arrive: you already have it. So keep the files yourself, because the [7-year retention duty](https://eenfactuurmaken.nl/en/docs/retention) stays with you.

## Sending

Let EenFactuurMaken.nl email the invoice, with the PDF and the UBL attached:

```bash
curl -X POST "https://eenfactuurmaken.nl/api/v1/invoices/$INVOICE_ID/send" \
  -H "Authorization: Bearer $EENFACTUURMAKEN_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{}'
```

Without `to`, the email goes to the customer's email address (and cc). The status becomes `sent` and `sentAt` is set. If, after an error, you're not sure whether the email went out, check `sentAt` on the invoice or `GET /emails` before you send again. On the Free plan you can only email the customer's address or your own. See [Sending by email](https://eenfactuurmaken.nl/en/docs/invoices/sending#limits) for the limits.

Rather email it yourself? Then fetch the PDF and send it from your own system.

## Looking up with your own id

```bash
curl "https://eenfactuurmaken.nl/api/v1/invoices?externalId=order-1042" \
  -H "Authorization: Bearer $EENFACTUURMAKEN_API_KEY"
curl "https://eenfactuurmaken.nl/api/v1/customers?externalId=cus_9" \
  -H "Authorization: Bearer $EENFACTUURMAKEN_API_KEY"
```

You get a list with zero or one result. For customers this also finds archived ones.

An `externalId` becomes free again when you delete a draft, or when an invoice on the Free plan is deleted after 60 days. If you sync again after that, a new invoice with the same id can be created. So also keep track in your own system of which orders have been invoiced.

## Webhooks

With Pro, EenFactuurMaken.nl sends a signed message to your own URL as soon as an invoice is issued, sent, paid or cancelled, a credit note is issued or a quote is accepted, so you don't have to keep polling the API. The message carries the `externalId` of the invoice and of the customer, so you can match it to your own order right away. Setting up and verifying is explained under [Webhooks](https://eenfactuurmaken.nl/en/docs/api/webhooks).

Without Pro, poll the list now and then, for example `GET /invoices?status=paid&sort=-createdAt`. See [Keeping in sync](https://eenfactuurmaken.nl/en/docs/api/guides#polling).

## Free or Pro

|  | Free | Pro |
| --- | --- | --- |
| REST API, API keys, access levels | Yes | Yes |
| `Idempotency-Key`, `externalId`, create and issue in one request | Yes | Yes |
| Invoices | 5 per month (credit notes don't count) | Unlimited |
| Customers and products | 25 active of each | Unlimited |
| Storage | 60 days | 7 years |
| Webhooks | No | Yes |

So an integration that creates many invoices needs Pro. See [Free and Pro](https://eenfactuurmaken.nl/en/docs/billing/plans).

## Versions and changes

- The API is `v1`. Within `v1` we only add things: new endpoints, new fields in responses, new error codes and new values. Build your integration so unknown fields don't break anything, and branch on `data.code`.
- Anything that breaks existing integrations comes in a new version. We announce it well in advance, and the old version keeps working for a transition period.
- Webhooks have their own payload version per endpoint (`version` in every message). New fields don't change that version; you choose a new version yourself. See [Webhooks](https://eenfactuurmaken.nl/en/docs/api/webhooks#payload).

## Checklist

- A separate key with **Invoices** access per integration, in an environment variable on your server.
- An `Idempotency-Key` on every POST, and the same key on a retry.
- An `externalId` on customers and invoices. Catch `409 external_id_taken` and use `details.id`.
- `"issue": true` when you want an issued invoice straight away.
- Handle `422` errors on `data.code` and show `data.details` to whoever can fix it.
- Retry on `429`, `502` and `503`, waiting the number of seconds in `Retry-After`.
- Download the PDF (and the UBL if you need it) and keep it yourself.
- With webhooks: verify the signature, process each `webhook-id` only once and compare with `GET /invoices` now and then.

## Full example

A small Node.js script (18 or newer, no extra packages) that invoices an order: create or reuse the customer, create and issue the invoice, save the PDF and email it. Every POST gets one `Idempotency-Key` that stays the same on every retry.

```js
import { randomUUID } from 'node:crypto'
import { writeFile } from 'node:fs/promises'

const API = 'https://eenfactuurmaken.nl/api/v1'
const KEY = process.env.EENFACTUURMAKEN_API_KEY

class ApiError extends Error {
  constructor(status, data) {
    super(data?.message ?? `HTTP ${status}`)
    this.status = status
    this.code = data?.code
    this.details = data?.details
  }
}

const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))

async function api(method, path, body) {
  const key = method === 'POST' ? randomUUID() : undefined // one key per action, also on retries
  for (let attempt = 1; ; attempt++) {
    let res
    try {
      res = await fetch(`${API}${path}`, {
        method,
        headers: {
          'Authorization': `Bearer ${KEY}`,
          ...(key ? { 'Idempotency-Key': key } : {}),
          ...(body ? { 'Content-Type': 'application/json' } : {}),
        },
        body: body ? JSON.stringify(body) : undefined,
      })
    }
    catch (err) {
      if (attempt >= 5) throw err
      await sleep(2 ** attempt * 500) // network error: retry with the same key
      continue
    }
    if (res.ok) return res.headers.get('content-type')?.includes('json') ? res.json() : res
    const data = (await res.json().catch(() => null))?.data
    const busy = res.status === 409 && data?.code === 'idempotency_key_in_progress'
    if ((res.status === 429 || res.status === 502 || res.status === 503 || busy) && attempt < 5) {
      await sleep((Number(res.headers.get('retry-after')) || 2 ** attempt) * 1000)
      continue
    }
    throw new ApiError(res.status, data)
  }
}

async function ensureCustomer(customer) {
  try {
    return await api('POST', '/customers', customer)
  }
  catch (e) {
    if (e.code === 'external_id_taken') return api('GET', `/customers/${e.details.id}`)
    throw e
  }
}

export async function invoiceOrder(order) {
  await ensureCustomer({
    externalId: `cus_${order.customer.id}`,
    type: 'business',
    name: order.customer.company,
    email: order.customer.email,
    addressLine1: order.customer.street,
    postalCode: order.customer.postalCode,
    city: order.customer.city,
    country: 'NL',
    kvkNumber: order.customer.kvk,
  })

  let invoice
  try {
    invoice = await api('POST', '/invoices', {
      externalId: `order-${order.id}`,
      customerExternalId: `cus_${order.customer.id}`,
      issue: true,
      reference: `Order ${order.id}`,
      lines: order.lines.map(l => ({ description: l.name, quantity: String(l.qty), unitPriceCents: l.priceCents, vatRate: '21' })),
    })
  }
  catch (e) {
    if (e.code !== 'external_id_taken') throw e
    invoice = await api('GET', `/invoices/${e.details.id}`) // made earlier: use that one
    if (invoice.status === 'draft') invoice = await api('POST', `/invoices/${invoice.id}/issue`, {})
  }

  const pdf = await api('GET', `/invoices/${invoice.id}/pdf?download=1`)
  await writeFile(`${invoice.number}.pdf`, Buffer.from(await pdf.arrayBuffer()))

  if (!invoice.sentAt) invoice = await api('POST', `/invoices/${invoice.id}/send`, {})
  return invoice
}
```

More recipes are under [Recipes](https://eenfactuurmaken.nl/en/docs/api/guides), and every endpoint with all its fields is in the [endpoint reference](https://eenfactuurmaken.nl/en/docs/api/reference).

Last updated on 29 October 2026
