# Referentie

Alle endpoints in één tabel, gegenereerd uit de OpenAPI-beschrijving. Dezelfde beschrijving draait live.

## OpenAPI

De machineleesbare beschrijving staat op `https://docs.cijfr.com/openapi.json` (CORS open) en op `https://api.cijfr.com/api/v1/openapi`. Importeer hem in Postman, Insomnia of je eigen codegen.

```bash
curl https://docs.cijfr.com/openapi.json
```

## Endpoints

### `GET /api/v1/me`

Current organisation and profile
Scope: `none`.

### `GET /api/v1/customers`

List customers
Scope: `customers:read`.

### `POST /api/v1/customers`

Create a customer
Scope: `customers:write`.

- `name` (string, required)
- `email` (string, optional)
- `companyName` (string, optional)
- `addressLine1` (string, optional)
- `postalCode` (string, optional)
- `city` (string, optional)
- `countryCode` (string, optional)
- `btwId` (string, optional)
- `kvkNumber` (string, optional)
- `externalId` (string, optional)

### `GET /api/v1/products`

List products
Scope: `products:read`.

### `POST /api/v1/products`

Create a product
Scope: `products:write`.

- `name` (string, required)
- `unitPriceCents` (integer, required)
- `vatRateBps` (integer, optional)
- `unit` (string, optional)
- `sku` (string, optional)

### `GET /api/v1/invoices`

List invoices
Scope: `invoices:read`.

### `POST /api/v1/invoices`

Create an invoice (draft or sent)
Scope: `invoices:write`.

- `customerId` (string uuid, required)
- `issueDate` (string date, optional)
- `dueDate` (string date, optional)
- `send` (boolean, optional) When true, lock the invoice and dispatch email. The response includes emailed and emailError. A missing Resend config still issues the invoice.
- `profileId` (string uuid, optional)
- `lines` (array, required)

### `GET /api/v1/subscriptions`

List recurring schedules
Scope: `subscriptions:read`.

### `POST /api/v1/subscriptions`

Create a subscription from invoice-like lines
Scope: `subscriptions:write`.

- `customerId` (string uuid, required)
- `freq` (string, required) `weekly`, `monthly`, `quarterly`, `yearly`
- `interval` (integer, optional)
- `autoSendEmail` (boolean, optional)
- `autoSendPost` (boolean, optional)
- `lines` (array, required)

### `GET /api/v1/checkouts`

List hosted checkout sessions
Scope: `checkouts:read`.

### `POST /api/v1/checkouts`

Create a hosted checkout session. The response `url` is a Cijfr-hosted checkout page where the payer picks a payment method and enters invoice details; the invoice is issued and emailed after payment.
Scope: `checkouts:write`.

- `title` (string, required)
- `lines` (array, required)
- `customer` (object, optional) Optional prefill for the checkout details form.
- `redirectUrl` (string uri, optional) Where the payer lands after a successful payment.
- `methods` (array, optional) Mollie method ids; defaults to all enabled.
- `expiresInHours` (integer, optional)

### `GET /api/v1/openapi`

This OpenAPI document as JSON (unauthenticated, CORS open)
Scope: `none`.

### `POST /api/v1/credits`

Grant mail credits after a paid top-up (platform billing / Edge Functions)
Scope: `credits:write (platform)`.

- `orgId` (string uuid, required)
- `credits` (integer, required)
- `reason` (string, optional)


