# Issue an invoice from charges

Canonical page: https://docs.ovok.com/api/patient-billing/issue-an-invoice-from-charges

`POST /v1/patient-billing/patients/{patientId}/invoices/issue`

Issues an invoice of the patient's billable charges at one clinic, for example a private GOÄ bill. The invoice is a FHIR `Invoice` from the clinic to the patient, a line per charge with its price; the charges turn `billed` in the same commit.

**Scope:** the caller's project, with `PATIENT_BILLING_ENABLED` on.

## Behaviour

- Your access policy must grant `patient_billing_invoices` `create` and let you read the patient, else **403** `PATIENT_BILLING_NOT_ALLOWED` or **404** `PATIENT_BILLING_PATIENT_NOT_FOUND`. The invoice shows the charges it bills, so this row reads them too.
- `clinicId` must be a clinic the patient is enrolled with, else **422** `BILLING_CLINIC_INVALID`.
- `chargeIds` names the charges to bill; left out, every billable charge at the clinic is billed, 49 at most (**422** `CHARGES_TOO_MANY`). A charge named that is not billable there answers **409** `CHARGE_NOT_BILLABLE`; nothing billable at all, **409** `NO_BILLABLE_CHARGES`.
- The charges must share one currency, else **422** `CHARGE_CURRENCY_MIXED`.
- `identifier`, such as your invoice number, is optional. With it, the same identifier for the same patient again answers the invoice already issued, with **200**. A new invoice answers **201** with `Location: /v1/patient-billing/invoices/<id>`.
- Changes to one patient's charges run one at a time: another still running, or a charge changed while billing, answers **409**; send yours again.

## Example

```bash
curl -X POST 'https://api.sandbox.ovok.com/v1/patient-billing/patients/<patientId>/invoices/issue' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjcyNjg4MDAsImV4cCI6MTc2NzI3MjQwMH0.Ql3B_ztDvctlyZ2z0vp4sl3ExXRQGkzmxdmTAqxNzZk' \
  -H 'Content-Type: application/json' \
  -d '{ "identifier": { "system": "https://example.com/invoice-numbers", "value": "2026-000123" }, "clinicId": "<clinicId>", "chargeIds": null, "issuedAt": null }'
```
