REST API

# Invoices API

Create, manage, and track invoices and customers programmatically.

## Required scopes

| Endpoint | Scope |
| --- | --- |
| List / Get customers | `customers:read` |
| Create / Update / Delete customers | `customers:write` |
| List / Get invoices | `invoices:read` |
| Create / Update / Delete invoices | `invoices:write` |
| Send / Mark as paid / Cancel invoices | `invoices:send` |
| Set or clear a payment link (generate_payment_link) | `payment_links:write` |
| Create credit note | `invoices:write` |
| Auto-approve created invoices (behavior, not an endpoint) | `invoices:auto_approve` |

## Approval before send

> **Default flow: dashboard approval:** By default the API creates invoices in `pending_approval` status and does not expose an approve endpoint. The invoice number is given at approval, so the create response carries `"number": null`; read it back with `GET /api/invoices/:id` once the invoice is approved. Before `POST /api/invoices/:id/send` works, the invoice must be approved. Dashboard Approve & Send also sends it once approval requirements are met; do not call send again. For unattended issuance, use the auto-approval scope below.

> **Auto-approval with the invoices:auto_approve scope:** A key granted the `invoices:auto_approve` scope skips the approval step entirely: `POST /api/invoices` (and `POST /api/invoices/:id/credit_note`) return the invoice approved, with its number. With a `send_to_email` the invoice email is queued too and the status is `sent`; with none the status is `approved` and `sent_at` is null. The approval happens in the same call, and its date rules are checked before anything is saved: an invoice dated after today is refused with a 422 and nothing is created (every key's create already refuses an issue date in a month before the newest number's month). Should the approval itself fail after the save, the invoice stays in review without a number; read it back before retrying. This bypasses any approval rules configured for the entity — including multi-approval requirements — so grant the scope only to integrations trusted to issue invoices on their own, such as recurring-invoicing automations.

## Recurring invoices and branding

For fixed monthly subscriptions, create the customer once and schedule one `POST /api/invoices` per billing period from your application. Reuse the customer and agreed line items, updating the dates and billing-period `reference`. The API creates individual invoices; it does not manage subscription schedules. Stop future creation jobs when a subscription ends. Cancelling an existing invoice does not cancel a schedule in your application.

For example, Ruby can build the period reference as `"club-#{club_id}-#{billing_month}"`.

Grant the integration `invoices:write` and `invoices:auto_approve` to create invoices without monthly manual approval. No `approved=true` parameter is needed. This permission bypasses all approval rules and is not limited to an agreed amount. Include `send_to_email` so the invoice is emailed: without it the invoice stops at `approved` and is never sent. `sent` alone is not proof of email delivery or payment. For a card-payment link in that email, see the [Recurring billing guide](https://za.manza.finance/docs/recurring-billing).

Keep a unique billing record per subscription and period in your application. Invoice creation does not provide an `Idempotency-Key` guarantee, and `reference` is not a uniqueness constraint. A 422 for the request body, the issue date rules or the payment link check is answered before anything is saved. A failure after the save (the approval step of an `invoices:auto_approve` key, or a lost response) can leave the invoice saved in `pending_approval` without a number, so store returned invoice IDs and reconcile an ambiguous failure before retrying creation. Use `invoices:read` to retrieve invoices during reconciliation.

Upload your issuing company's logo once in the dashboard's business profile settings. Invoice previews and PDFs use the issuing entity's logo, including for API-created invoices. The customer object represents the recipient, not the invoice issuer. The public API does not currently expose logo upload or invoice-branding settings; there is no per-invoice logo parameter. Complete this dashboard setup before enabling automatic sending.

## Customer object

Customers must exist before they can be referenced in invoices.

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | Unique identifier (UUIDv7) |
| `customer_type` | string | individual or business (auto-detected from company_name, and from registration_number where the market collects one) |
| `person_name` | string | Individual's name |
| `company_name` | string | Company name (typically for business customers) |
| `name` | string | Computed: company_name if present, else person_name |
| `email` | string | Email address (unique per entity) |
| `phone` | string | Phone number |
| `registration_number` | string | CIPC registration number (optional; slashed form, e.g. 2020/038425/07). Implies customer_type business — sending it alongside an explicit individual is rejected. |
| `vat_number` | string | VAT number (optional; any country's format, must include at least one digit, at most 50 characters). Allowed for individuals as well as businesses. |
| `billing_address` | object | Billing address |
| `invoices_count` | integer | Number of invoices (list only) |
| `created_at` | string | ISO 8601 timestamp |
| `updated_at` | string | ISO 8601 timestamp |

The `billing_address` object carries `street`, `street2`, `city`, `postal_code`, and `country_code` (ISO 3166-1 alpha-2). When an address is provided, all fields except street2 are required. The `country` field is refused with a 400, whatever it holds; send `country_code` instead.

## List customers

`GET` `/api/customers`

Supports `q` (search by name, company, email) plus cursor pagination (`cursor`, `limit` 1–100, default 25).

cURL

CLI

JavaScript

Ruby

Python

Go

Rust

Elixir

Crystal

PHP

```console
curl "https://za.manza.finance/api/customers?q=acme" \
  -H "Authorization: Bearer sk_live_..."
```

```console
manza customers list
```

```javascript
import { Manza } from "@getmanza/sdk";
const manza = new Manza({ apiKey: process.env.MANZA_API_KEY });

await manza.customers.list({ q: "acme" });
```

```ruby
require "manza"
manza = Manza.new(api_key: ENV["MANZA_API_KEY"])

manza.customers.list(q: "acme")
```

```python
from manza import Manza
client = Manza()  # reads MANZA_API_KEY

client.customers.list(q="acme")
```

```go
import manza "github.com/getmanza/manza-go/v2"

client, _ := manza.New(manza.WithAPIKey(os.Getenv("MANZA_API_KEY")))

page, err := client.Customers.List(ctx, manza.CustomerListParams{Query: "acme"})
```

```rust
let client = manza::Client::builder()
    .api_key(std::env::var("MANZA_API_KEY")?)
    .build()?;

let params = manza::CustomerListParams { q: Some("acme".into()), ..Default::default() };
let page = client.customers().list(params)?;
```

```elixir
{:ok, client} = Manza.new(api_key: System.fetch_env!("MANZA_API_KEY"))

{:ok, page} = Manza.Customers.list(client, q: "acme")
```

```crystal
require "manza"

client = Manza::Client.new # reads MANZA_API_KEY

page = client.customers.list(q: "acme")
```

```php
use Manza\Client;

$client = new Client(apiKey: getenv('MANZA_API_KEY'));

$page = $client->customers->list(q: 'acme');
```

## Create customer

`POST` `/api/customers`

Requires at least one of `person_name` or `company_name`. When `customer_type` is omitted it is auto-detected: `business` when a company name is present or a `registration_number` is sent, `individual` otherwise.

cURL

CLI

JavaScript

Ruby

Python

Go

Rust

Elixir

Crystal

PHP

```console
curl -X POST "https://za.manza.finance/api/customers" \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
  "customer_type": "business",
  "person_name": "Thandi Nkosi",
  "company_name": "Acme Corp",
  "email": "billing@acme.com",
  "phone": "+27821234567",
  "registration_number": "2020/038425/07",
  "vat_number": "4123456789",
  "billing_address": {
    "street": "12 Long Street",
    "city": "Cape Town",
    "postal_code": "8001",
    "country_code": "ZA"
  }
}'
```

```console
manza customers create --file customer.json
```

```javascript
import { Manza } from "@getmanza/sdk";
const manza = new Manza({ apiKey: process.env.MANZA_API_KEY });

await manza.customers.create({
  customer_type: "business",
  company_name: "Acme Corp",
  email: "billing@acme.com",
});
```

```ruby
require "manza"
manza = Manza.new(api_key: ENV["MANZA_API_KEY"])

manza.customers.create(
  customer_type: "business",
  company_name: "Acme Corp",
  email: "billing@acme.com",
)
```

```python
from manza import Manza
client = Manza()  # reads MANZA_API_KEY

client.customers.create(
    customer_type="business",
    company_name="Acme Corp",
    email="billing@acme.com",
)
```

```go
import manza "github.com/getmanza/manza-go/v2"

client, _ := manza.New(manza.WithAPIKey(os.Getenv("MANZA_API_KEY")))

customer, err := client.Customers.Create(ctx, manza.Attributes{
    "customer_type": "business",
    "company_name":  "Acme Corp",
    "email":         "billing@acme.com",
})
```

```rust
let client = manza::Client::builder()
    .api_key(std::env::var("MANZA_API_KEY")?)
    .build()?;

let customer = client.customers().create(&serde_json::json!({
    "customer_type": "business",
    "company_name": "Acme Corp",
    "email": "billing@acme.com",
}))?;
```

```elixir
{:ok, client} = Manza.new(api_key: System.fetch_env!("MANZA_API_KEY"))

{:ok, customer} =
  Manza.Customers.create(client, %{
    "customer_type" => "business",
    "company_name" => "Acme Corp",
    "email" => "billing@acme.com"
  })
```

```crystal
require "manza"

client = Manza::Client.new # reads MANZA_API_KEY

customer = client.customers.create(
  customer_type: "business",
  company_name: "Acme Corp",
  email: "billing@acme.com"
)
```

```php
use Manza\Client;

$client = new Client(apiKey: getenv('MANZA_API_KEY'));

$customer = $client->customers->create([
    'customer_type' => 'business',
    'company_name' => 'Acme Corp',
    'email' => 'billing@acme.com',
]);
```

Responds 201 Created with the full customer object.

## Get customer

`GET` `/api/customers/:id`

cURL

CLI

JavaScript

Ruby

Python

Go

Rust

Elixir

Crystal

PHP

```console
curl "https://za.manza.finance/api/customers/01964a3b-0000-7000-8000-customer0001" \
  -H "Authorization: Bearer sk_live_..."
```

```console
manza customers get 01964a3b-0000-7000-8000-customer0001
```

```javascript
import { Manza } from "@getmanza/sdk";
const manza = new Manza({ apiKey: process.env.MANZA_API_KEY });

await manza.customers.get("01964a3b-0000-7000-8000-customer0001");
```

```ruby
require "manza"
manza = Manza.new(api_key: ENV["MANZA_API_KEY"])

manza.customers.get("01964a3b-0000-7000-8000-customer0001")
```

```python
from manza import Manza
client = Manza()  # reads MANZA_API_KEY

client.customers.get("01964a3b-0000-7000-8000-customer0001")
```

```go
import manza "github.com/getmanza/manza-go/v2"

client, _ := manza.New(manza.WithAPIKey(os.Getenv("MANZA_API_KEY")))

customer, err := client.Customers.Get(ctx, "01964a3b-0000-7000-8000-customer0001")
```

```rust
let client = manza::Client::builder()
    .api_key(std::env::var("MANZA_API_KEY")?)
    .build()?;

let customer = client.customers().get("01964a3b-0000-7000-8000-customer0001")?;
```

```elixir
{:ok, client} = Manza.new(api_key: System.fetch_env!("MANZA_API_KEY"))

{:ok, customer} = Manza.Customers.get(client, "01964a3b-0000-7000-8000-customer0001")
```

```crystal
require "manza"

client = Manza::Client.new # reads MANZA_API_KEY

customer = client.customers.get("01964a3b-0000-7000-8000-customer0001")
```

```php
use Manza\Client;

$client = new Client(apiKey: getenv('MANZA_API_KEY'));

$customer = $client->customers->get('01964a3b-0000-7000-8000-customer0001');
```

## Update customer

`PATCH` `/api/customers/:id`

Partial update — only provided fields change. A supplied `billing_address` replaces the existing one entirely; setting it to `null` deletes the address.

cURL

CLI

JavaScript

Ruby

Python

Go

Rust

Elixir

Crystal

PHP

```console
curl -X PATCH "https://za.manza.finance/api/customers/01964a3b-0000-7000-8000-customer0001" \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
  "email": "newemail@acme.com",
  "billing_address": {
    "street": "45 Jan Smuts Avenue",
    "city": "Johannesburg",
    "postal_code": "2196",
    "country_code": "ZA"
  }
}'
```

```console
manza customers update 01964a3b-0000-7000-8000-customer0001 --file customer.json
```

```javascript
import { Manza } from "@getmanza/sdk";
const manza = new Manza({ apiKey: process.env.MANZA_API_KEY });

await manza.customers.update("01964a3b-0000-7000-8000-customer0001", { email: "newemail@acme.com" });
```

```ruby
require "manza"
manza = Manza.new(api_key: ENV["MANZA_API_KEY"])

manza.customers.update("01964a3b-0000-7000-8000-customer0001", email: "newemail@acme.com")
```

```python
from manza import Manza
client = Manza()  # reads MANZA_API_KEY

client.customers.update("01964a3b-0000-7000-8000-customer0001", email="newemail@acme.com")
```

```go
import manza "github.com/getmanza/manza-go/v2"

client, _ := manza.New(manza.WithAPIKey(os.Getenv("MANZA_API_KEY")))

customer, err := client.Customers.Update(ctx, "01964a3b-0000-7000-8000-customer0001",
    manza.Attributes{"email": "newemail@acme.com"})
```

```rust
let client = manza::Client::builder()
    .api_key(std::env::var("MANZA_API_KEY")?)
    .build()?;

let customer = client.customers()
    .update("01964a3b-0000-7000-8000-customer0001", &serde_json::json!({ "email": "newemail@acme.com" }))?;
```

```elixir
{:ok, client} = Manza.new(api_key: System.fetch_env!("MANZA_API_KEY"))

{:ok, customer} =
  Manza.Customers.update(client, "01964a3b-0000-7000-8000-customer0001", %{"email" => "newemail@acme.com"})
```

```crystal
require "manza"

client = Manza::Client.new # reads MANZA_API_KEY

customer = client.customers.update("01964a3b-0000-7000-8000-customer0001", email: "newemail@acme.com")
```

```php
use Manza\Client;

$client = new Client(apiKey: getenv('MANZA_API_KEY'));

$customer = $client->customers->update('01964a3b-0000-7000-8000-customer0001', ['email' => 'newemail@acme.com']);
```

## Delete customer

`DELETE` `/api/customers/:id`

Responds `204 No Content`. A customer that still has invoices cannot be deleted — that returns `422 unprocessable_entity`.

cURL

CLI

JavaScript

Ruby

Python

Go

Rust

Elixir

Crystal

PHP

```console
curl -X DELETE "https://za.manza.finance/api/customers/01964a3b-0000-7000-8000-customer0001" \
  -H "Authorization: Bearer sk_live_..."
```

```console
manza customers delete 01964a3b-0000-7000-8000-customer0001
```

```javascript
import { Manza } from "@getmanza/sdk";
const manza = new Manza({ apiKey: process.env.MANZA_API_KEY });

await manza.customers.delete("01964a3b-0000-7000-8000-customer0001");
```

```ruby
require "manza"
manza = Manza.new(api_key: ENV["MANZA_API_KEY"])

manza.customers.delete("01964a3b-0000-7000-8000-customer0001")
```

```python
from manza import Manza
client = Manza()  # reads MANZA_API_KEY

client.customers.delete("01964a3b-0000-7000-8000-customer0001")
```

```go
import manza "github.com/getmanza/manza-go/v2"

client, _ := manza.New(manza.WithAPIKey(os.Getenv("MANZA_API_KEY")))

_, err := client.Customers.Delete(ctx, "01964a3b-0000-7000-8000-customer0001")
```

```rust
let client = manza::Client::builder()
    .api_key(std::env::var("MANZA_API_KEY")?)
    .build()?;

client.customers().delete("01964a3b-0000-7000-8000-customer0001")?;
```

```elixir
{:ok, client} = Manza.new(api_key: System.fetch_env!("MANZA_API_KEY"))

{:ok, _} = Manza.Customers.delete(client, "01964a3b-0000-7000-8000-customer0001")
```

```crystal
require "manza"

client = Manza::Client.new # reads MANZA_API_KEY

client.customers.delete("01964a3b-0000-7000-8000-customer0001")
```

```php
use Manza\Client;

$client = new Client(apiKey: getenv('MANZA_API_KEY'));

$client->customers->delete('01964a3b-0000-7000-8000-customer0001');
```

## Invoice object

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | Unique identifier (UUIDv7) |
| `number` | string/null | Given at approval (default <prefix><date>-<sequence>, configurable per entity); null while the invoice is in pending_approval or declined (a few invoices created before this change may already carry a number in either status) |
| `status` | string | draft, pending_approval, declined, approved, sent, paid, overdue, cancelled. A credit note holds only draft, pending_approval, declined, approved, sent or cancelled |
| `currency_code` | string | ISO 4217 currency code |
| `subtotal` | string | Sum of item amounts |
| `discount_total` | string | Total discount amount |
| `tax_total` | string | Total tax amount |
| `total` | string | Final amount due |
| `issue_date` | string | Date (YYYY-MM-DD) |
| `due_date` | string/null | Date (YYYY-MM-DD). Null on a credit note, which asks nobody to pay |
| `reference` | string | PO number or external reference. A new or changed one is kept on one line, at most 64 characters |
| `notes` | string | Free-text notes |
| `payment_terms` | string | Payment terms text |
| `send_to_email` | string/null | Where the invoice is emailed. It cannot change once the invoice is approved. With none the invoice cannot be sent |
| `generate_payment_link` | boolean | Whether approval makes a card payment link for the invoice |
| `credited_invoice_id` | string/null | ID of the credited invoice |
| `credit_note` | boolean | Whether this invoice is a credit note |
| `sent_at` | string/null | ISO 8601 timestamp of the invoice email. Null on an invoice that was never sent, which can still be paid or overdue |
| `paid_at` | string | ISO 8601 timestamp |
| `account` | object/null | Bank account the invoice is paid into: id, name, currency_code and the market's number (see Accounts). Null on a credit note of an invoice that predates the account rule |
| `customer` | object | Snapshotted customer data |
| `billing_address` | object | Snapshotted billing address |
| `items` | array | Line items (show only) |
| `discounts` | array | Discounts (show only) |
| `payment_link` | object | Attached payment link (show only) |
| `created_at` | string | ISO 8601 timestamp |
| `updated_at` | string | ISO 8601 timestamp |

> **Amounts are strings:** Financial amounts are serialized as strings to preserve decimal precision.

## Items and discounts

Each item carries `description`, `quantity`, `unit_price`, `tax_rate` (a fraction, e.g. `"0.2000"` = 20%; one of the entity's allowed VAT rates: its standard rate, in Morocco also the reduced `"0.1000"` (10%), or `"0"` for an export or other zero-rated supply — a business that is not VAT-registered can only issue at 0%), a calculated `amount` (`quantity × unit_price`), and a `position` sort order.

Each discount carries `description`, `discount_type` (`percentage` or `fixed`), `value` (percentage 0–100 or fixed amount), a calculated `amount`, and a `position` sort order.

## List invoices

`GET` `/api/invoices`

Filter by `status` and `customer_id`, plus cursor pagination. The list response returns `items_count` and `discounts_count` instead of the full arrays, and `payment_link_url` instead of the full payment-link object.

cURL

CLI

JavaScript

Ruby

Python

Go

Rust

Elixir

Crystal

PHP

```console
curl "https://za.manza.finance/api/invoices?status=sent" \
  -H "Authorization: Bearer sk_live_..."
```

```console
manza invoices list
```

```javascript
import { Manza } from "@getmanza/sdk";
const manza = new Manza({ apiKey: process.env.MANZA_API_KEY });

await manza.invoices.list({ status: "sent" });
```

```ruby
require "manza"
manza = Manza.new(api_key: ENV["MANZA_API_KEY"])

manza.invoices.list(status: "sent")
```

```python
from manza import Manza
client = Manza()  # reads MANZA_API_KEY

client.invoices.list(status="sent")
```

```go
import manza "github.com/getmanza/manza-go/v2"

client, _ := manza.New(manza.WithAPIKey(os.Getenv("MANZA_API_KEY")))

page, err := client.Invoices.List(ctx, manza.InvoiceListParams{Status: "sent"})
```

```rust
let client = manza::Client::builder()
    .api_key(std::env::var("MANZA_API_KEY")?)
    .build()?;

let params = manza::InvoiceListParams { status: Some("sent".into()), ..Default::default() };
let page = client.invoices().list(params)?;
```

```elixir
{:ok, client} = Manza.new(api_key: System.fetch_env!("MANZA_API_KEY"))

{:ok, page} = Manza.Invoices.list(client, status: "sent")
```

```crystal
require "manza"

client = Manza::Client.new # reads MANZA_API_KEY

page = client.invoices.list(status: "sent")
```

```php
use Manza\Client;

$client = new Client(apiKey: getenv('MANZA_API_KEY'));

$page = $client->invoices->list(status: 'sent');
```

## Create invoice

`POST` `/api/invoices`

By default, creates an invoice directly in `pending_approval` status (no draft workflow) with no number yet. With `invoices:auto_approve`, it is approved and numbered automatically, and emailed when it has a send_to_email. Required: `customer_id`, `account_id` (the bank account the invoice is paid into; discover valid account IDs via [GET /api/accounts](https://za.manza.finance/docs/api/accounts)), `issue_date`, `due_date`, and at least one item. Totals are calculated automatically, `currency_code` defaults to entity currency, and per-item `tax_rate` defaults to the entity's standard VAT rate if omitted (0% for a business that is not VAT-registered). Any other value is rejected with a 422 whose `param` is `invoice_items.tax_rate`.

Set `generate_payment_link` to `true` (needs the `payment_links:write` scope, and payment links enabled for your account) to give the invoice a card payment link. Approval makes the link, for the invoice's total and into the invoice's bank account, so the invoice email includes it. An invoice without a bank account cannot have one: the create answers 422 `state_error`.

cURL

CLI

JavaScript

Ruby

Python

Go

Rust

Elixir

Crystal

PHP

```console
curl -X POST "https://za.manza.finance/api/invoices" \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
  "customer_id": "01964a3b-0000-7000-8000-customer0001",
  "account_id": "01964a3b-0000-7000-8000-ac6000000a01",
  "currency_code": "ZAR",
  "issue_date": "2026-03-15",
  "due_date": "2026-04-15",
  "reference": "PO-2026-001",
  "notes": "Net 30 payment terms",
  "payment_terms": "Net 30",
  "send_to_email": "billing@acme.com",
  "items": [
    {
      "description": "Consulting services - March 2026",
      "quantity": 10,
      "unit_price": "150.00"
    },
    {
      "description": "Travel expenses",
      "quantity": 1,
      "unit_price": "500.00",
      "tax_rate": "0.00"
    }
  ],
  "discounts": [
    {
      "description": "Loyalty discount",
      "discount_type": "percentage",
      "value": "10.00"
    }
  ]
}'
```

```console
manza invoices create --file invoice.json
```

```javascript
import { Manza } from "@getmanza/sdk";
const manza = new Manza({ apiKey: process.env.MANZA_API_KEY });

await manza.invoices.create({
  customer_id: "01964a3b-0000-7000-8000-customer0001",
  account_id: "01964a3b-0000-7000-8000-ac6000000a01",
  currency_code: "ZAR",
  issue_date: "2026-03-15",
  due_date: "2026-04-15",
  items: [
    { description: "Consulting services", quantity: 10, unit_price: "150.00" },
  ],
});
```

```ruby
require "manza"
manza = Manza.new(api_key: ENV["MANZA_API_KEY"])

manza.invoices.create(
  customer_id: "01964a3b-0000-7000-8000-customer0001",
  account_id: "01964a3b-0000-7000-8000-ac6000000a01",
  currency_code: "ZAR",
  issue_date: "2026-03-15",
  due_date: "2026-04-15",
  items: [
    { description: "Consulting services", quantity: 10, unit_price: "150.00" },
  ],
)
```

```python
from manza import Manza
client = Manza()  # reads MANZA_API_KEY

client.invoices.create(
    customer_id="01964a3b-0000-7000-8000-customer0001",
    account_id="01964a3b-0000-7000-8000-ac6000000a01",
    currency_code="ZAR",
    issue_date="2026-03-15",
    due_date="2026-04-15",
    items=[
        {"description": "Consulting services", "quantity": 10, "unit_price": "150.00"},
    ],
)
```

```go
import manza "github.com/getmanza/manza-go/v2"

client, _ := manza.New(manza.WithAPIKey(os.Getenv("MANZA_API_KEY")))

invoice, err := client.Invoices.Create(ctx, manza.Attributes{
    "customer_id":   "01964a3b-0000-7000-8000-customer0001",
    "account_id":    "01964a3b-0000-7000-8000-ac6000000a01",
    "currency_code": "ZAR",
    "issue_date":    "2026-03-15",
    "due_date":      "2026-04-15",
    "items": []manza.Attributes{
        {"description": "Consulting services", "quantity": 10, "unit_price": "150.00"},
    },
})
```

```rust
let client = manza::Client::builder()
    .api_key(std::env::var("MANZA_API_KEY")?)
    .build()?;

let invoice = client.invoices().create(&serde_json::json!({
    "customer_id": "01964a3b-0000-7000-8000-customer0001",
    "account_id": "01964a3b-0000-7000-8000-ac6000000a01",
    "currency_code": "ZAR",
    "issue_date": "2026-03-15",
    "due_date": "2026-04-15",
    "items": [
        { "description": "Consulting services", "quantity": 10, "unit_price": "150.00" },
    ],
}))?;
```

```elixir
{:ok, client} = Manza.new(api_key: System.fetch_env!("MANZA_API_KEY"))

{:ok, invoice} =
  Manza.Invoices.create(client, %{
    "customer_id" => "01964a3b-0000-7000-8000-customer0001",
    "account_id" => "01964a3b-0000-7000-8000-ac6000000a01",
    "currency_code" => "ZAR",
    "issue_date" => "2026-03-15",
    "due_date" => "2026-04-15",
    "items" => [
      %{"description" => "Consulting services", "quantity" => 10, "unit_price" => "150.00"}
    ]
  })
```

```crystal
require "manza"

client = Manza::Client.new # reads MANZA_API_KEY

invoice = client.invoices.create(
  customer_id: "01964a3b-0000-7000-8000-customer0001",
  account_id: "01964a3b-0000-7000-8000-ac6000000a01",
  currency_code: "ZAR",
  issue_date: "2026-03-15",
  due_date: "2026-04-15",
  items: [
    {description: "Consulting services", quantity: 10, unit_price: "150.00"},
  ]
)
```

```php
use Manza\Client;

$client = new Client(apiKey: getenv('MANZA_API_KEY'));

$invoice = $client->invoices->create([
    'customer_id' => '01964a3b-0000-7000-8000-customer0001',
    'account_id' => '01964a3b-0000-7000-8000-ac6000000a01',
    'currency_code' => 'ZAR',
    'issue_date' => '2026-03-15',
    'due_date' => '2026-04-15',
    'items' => [
        ['description' => 'Consulting services', 'quantity' => 10, 'unit_price' => '150.00'],
    ],
]);
```

Responds 201 Created with the full invoice object. The `issue_date` may be in this month or next month, and may be backdated unless a newer number has closed that month; any other date is refused with a 422 on `issue_date`. Without `invoices:auto_approve` the object has `"number": null` and `"status": "pending_approval"`:

```json
{
  "id": "01964a3b-7c8d-7000-8000-deadbeef1234",
  "number": null,
  "status": "pending_approval",
  "issue_date": "2026-03-15",
  "due_date": "2026-04-15"
}
```

Each create takes one of the invoices a month your plan allows. Past that cap the API answers `422 plan_limit_reached` with `kind`, `current` and `max`, and creates nothing.

## Get invoice

`GET` `/api/invoices/:id`

Returns the full invoice with items, discounts, customer snapshot, billing address, payment link, and any `credit_notes` issued against it.

cURL

CLI

JavaScript

Ruby

Python

Go

Rust

Elixir

Crystal

PHP

```console
curl "https://za.manza.finance/api/invoices/01964a3b-7c8d-7000-8000-deadbeef1234" \
  -H "Authorization: Bearer sk_live_..."
```

```console
manza invoices get 01964a3b-7c8d-7000-8000-deadbeef1234
```

```javascript
import { Manza } from "@getmanza/sdk";
const manza = new Manza({ apiKey: process.env.MANZA_API_KEY });

await manza.invoices.get("01964a3b-7c8d-7000-8000-deadbeef1234");
```

```ruby
require "manza"
manza = Manza.new(api_key: ENV["MANZA_API_KEY"])

manza.invoices.get("01964a3b-7c8d-7000-8000-deadbeef1234")
```

```python
from manza import Manza
client = Manza()  # reads MANZA_API_KEY

client.invoices.get("01964a3b-7c8d-7000-8000-deadbeef1234")
```

```go
import manza "github.com/getmanza/manza-go/v2"

client, _ := manza.New(manza.WithAPIKey(os.Getenv("MANZA_API_KEY")))

invoice, err := client.Invoices.Get(ctx, "01964a3b-7c8d-7000-8000-deadbeef1234")
```

```rust
let client = manza::Client::builder()
    .api_key(std::env::var("MANZA_API_KEY")?)
    .build()?;

let invoice = client.invoices().get("01964a3b-7c8d-7000-8000-deadbeef1234")?;
```

```elixir
{:ok, client} = Manza.new(api_key: System.fetch_env!("MANZA_API_KEY"))

{:ok, invoice} = Manza.Invoices.get(client, "01964a3b-7c8d-7000-8000-deadbeef1234")
```

```crystal
require "manza"

client = Manza::Client.new # reads MANZA_API_KEY

invoice = client.invoices.get("01964a3b-7c8d-7000-8000-deadbeef1234")
```

```php
use Manza\Client;

$client = new Client(apiKey: getenv('MANZA_API_KEY'));

$invoice = $client->invoices->get('01964a3b-7c8d-7000-8000-deadbeef1234');
```

```json
{
  "id": "01964a3b-7c8d-7000-8000-deadbeef1234",
  "number": "INV-202603-001",
  "status": "sent",
  "currency_code": "ZAR",
  "subtotal": "1500.00",
  "discount_total": "150.00",
  "tax_total": "202.50",
  "total": "1552.50",
  "issue_date": "2026-03-15",
  "due_date": "2026-04-15",
  "generate_payment_link": true,
  "customer": {
    "id": "01964a3b-0000-7000-8000-customer0001",
    "name": "Acme Corp",
    "email": "billing@acme.com"
  },
  "account": {
    "id": "01964a3b-0000-7000-8000-ac6000000a01",
    "name": "Operations",
    "currency_code": "ZAR",
    "account_number": "1234567890"
  },
  "items": [
    {
      "id": "01964a3b-1111-7000-8000-item00000001",
      "description": "Consulting services - March 2026",
      "quantity": "10.00",
      "unit_price": "150.00",
      "tax_rate": "0.1500",
      "amount": "1500.00",
      "position": 0
    }
  ],
  "discounts": [
    {
      "id": "01964a3b-2222-7000-8000-disc00000001",
      "description": "Loyalty discount",
      "discount_type": "percentage",
      "value": "10.00",
      "amount": "150.00",
      "position": 0
    }
  ],
  "payment_link": {
    "id": "01964a3b-3333-7000-8000-link00000001",
    "url": "https://pay.zazu.example/payment-link/abc123def456",
    "status": "active"
  },
  "created_at": "2026-03-15T09:00:00Z",
  "updated_at": "2026-03-16T10:00:00Z"
}
```

## Update invoice

`PATCH` `/api/invoices/:id`

Only invoices in `pending_approval` or `draft` status can be updated — an approved invoice is frozen, so from `approved` on the API returns `422 state_error`. `currency_code`, `number`, and `status` are not updatable; `account_id` can change to another of your accounts but cannot be cleared. Setting `generate_payment_link` to `false` also removes a payment link the invoice already has. Items and discounts use full replacement: entries with a matching id are updated, entries without an id are created, and existing entries absent from the array are deleted. Totals are recalculated automatically.

cURL

CLI

JavaScript

Ruby

Python

Go

Rust

Elixir

Crystal

PHP

```console
curl -X PATCH "https://za.manza.finance/api/invoices/01964a3b-7c8d-7000-8000-deadbeef1234" \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{"notes": "Updated terms"}'
```

```console
manza invoices update 01964a3b-7c8d-7000-8000-deadbeef1234 --file invoice.json
```

```javascript
import { Manza } from "@getmanza/sdk";
const manza = new Manza({ apiKey: process.env.MANZA_API_KEY });

await manza.invoices.update("01964a3b-7c8d-7000-8000-deadbeef1234", { notes: "Updated terms" });
```

```ruby
require "manza"
manza = Manza.new(api_key: ENV["MANZA_API_KEY"])

manza.invoices.update("01964a3b-7c8d-7000-8000-deadbeef1234", notes: "Updated terms")
```

```python
from manza import Manza
client = Manza()  # reads MANZA_API_KEY

client.invoices.update("01964a3b-7c8d-7000-8000-deadbeef1234", notes="Updated terms")
```

```go
import manza "github.com/getmanza/manza-go/v2"

client, _ := manza.New(manza.WithAPIKey(os.Getenv("MANZA_API_KEY")))

invoice, err := client.Invoices.Update(ctx, "01964a3b-7c8d-7000-8000-deadbeef1234", manza.Attributes{"notes": "Updated terms"})
```

```rust
let client = manza::Client::builder()
    .api_key(std::env::var("MANZA_API_KEY")?)
    .build()?;

let invoice = client.invoices()
    .update("01964a3b-7c8d-7000-8000-deadbeef1234", &serde_json::json!({ "notes": "Updated terms" }))?;
```

```elixir
{:ok, client} = Manza.new(api_key: System.fetch_env!("MANZA_API_KEY"))

{:ok, invoice} = Manza.Invoices.update(client, "01964a3b-7c8d-7000-8000-deadbeef1234", %{"notes" => "Updated terms"})
```

```crystal
require "manza"

client = Manza::Client.new # reads MANZA_API_KEY

invoice = client.invoices.update("01964a3b-7c8d-7000-8000-deadbeef1234", notes: "Updated terms")
```

```php
use Manza\Client;

$client = new Client(apiKey: getenv('MANZA_API_KEY'));

$invoice = $client->invoices->update('01964a3b-7c8d-7000-8000-deadbeef1234', ['notes' => 'Updated terms']);
```

## Send invoice

`POST` `/api/invoices/:id/send`

Emails the invoice to its `send_to_email`, transitions it to `sent` and sets `sent_at`. Available from `approved`, and from `overdue` while `sent_at` is null (the status then stays `overdue`). Without auto-approval, API-created invoices start in `pending_approval`. Dashboard Approve & Send also sends the invoice. Invoices created with invoices:auto_approve and a send_to_email are already sent; do not call this endpoint again for them.

Sending is optional, and it is an email: an invoice with no usable `send_to_email` is refused with a 422 whose `param` is `send_to_email`, and stays as it was. The address cannot change after approval, so mark such an invoice as paid when the customer pays, or cancel it.

cURL

CLI

JavaScript

Ruby

Python

Go

Rust

Elixir

Crystal

PHP

```console
curl -X POST "https://za.manza.finance/api/invoices/01964a3b-7c8d-7000-8000-deadbeef1234/send" \
  -H "Authorization: Bearer sk_live_..."
```

```console
manza invoices send 01964a3b-7c8d-7000-8000-deadbeef1234
```

```javascript
import { Manza } from "@getmanza/sdk";
const manza = new Manza({ apiKey: process.env.MANZA_API_KEY });

await manza.invoices.send("01964a3b-7c8d-7000-8000-deadbeef1234");
```

```ruby
require "manza"
manza = Manza.new(api_key: ENV["MANZA_API_KEY"])

manza.invoices.send_invoice("01964a3b-7c8d-7000-8000-deadbeef1234")
```

```python
from manza import Manza
client = Manza()  # reads MANZA_API_KEY

client.invoices.send_invoice("01964a3b-7c8d-7000-8000-deadbeef1234")
```

```go
import manza "github.com/getmanza/manza-go/v2"

client, _ := manza.New(manza.WithAPIKey(os.Getenv("MANZA_API_KEY")))

invoice, err := client.Invoices.Send(ctx, "01964a3b-7c8d-7000-8000-deadbeef1234")
```

```rust
let client = manza::Client::builder()
    .api_key(std::env::var("MANZA_API_KEY")?)
    .build()?;

let invoice = client.invoices().send("01964a3b-7c8d-7000-8000-deadbeef1234")?;
```

```elixir
{:ok, client} = Manza.new(api_key: System.fetch_env!("MANZA_API_KEY"))

{:ok, invoice} = Manza.Invoices.send(client, "01964a3b-7c8d-7000-8000-deadbeef1234")
```

```crystal
require "manza"

client = Manza::Client.new # reads MANZA_API_KEY

invoice = client.invoices.send("01964a3b-7c8d-7000-8000-deadbeef1234")
```

```php
use Manza\Client;

$client = new Client(apiKey: getenv('MANZA_API_KEY'));

$invoice = $client->invoices->send('01964a3b-7c8d-7000-8000-deadbeef1234');
```

## Mark as paid

`POST` `/api/invoices/:id/mark_as_paid`

Transitions the invoice to `paid` and sets `paid_at`. Available from `approved`, `sent` or `overdue`: an invoice does not have to be sent before it is paid, so `sent_at` can be null on a paid invoice. A credit note is never paid: the call answers 422 with a `state_error`.

cURL

CLI

JavaScript

Ruby

Python

Go

Rust

Elixir

Crystal

PHP

```console
curl -X POST "https://za.manza.finance/api/invoices/01964a3b-7c8d-7000-8000-deadbeef1234/mark_as_paid" \
  -H "Authorization: Bearer sk_live_..."
```

```console
manza invoices mark-as-paid 01964a3b-7c8d-7000-8000-deadbeef1234
```

```javascript
import { Manza } from "@getmanza/sdk";
const manza = new Manza({ apiKey: process.env.MANZA_API_KEY });

await manza.invoices.markAsPaid("01964a3b-7c8d-7000-8000-deadbeef1234");
```

```ruby
require "manza"
manza = Manza.new(api_key: ENV["MANZA_API_KEY"])

manza.invoices.mark_as_paid("01964a3b-7c8d-7000-8000-deadbeef1234")
```

```python
from manza import Manza
client = Manza()  # reads MANZA_API_KEY

client.invoices.mark_as_paid("01964a3b-7c8d-7000-8000-deadbeef1234")
```

```go
import manza "github.com/getmanza/manza-go/v2"

client, _ := manza.New(manza.WithAPIKey(os.Getenv("MANZA_API_KEY")))

invoice, err := client.Invoices.MarkAsPaid(ctx, "01964a3b-7c8d-7000-8000-deadbeef1234")
```

```rust
let client = manza::Client::builder()
    .api_key(std::env::var("MANZA_API_KEY")?)
    .build()?;

let invoice = client.invoices().mark_as_paid("01964a3b-7c8d-7000-8000-deadbeef1234")?;
```

```elixir
{:ok, client} = Manza.new(api_key: System.fetch_env!("MANZA_API_KEY"))

{:ok, invoice} = Manza.Invoices.mark_as_paid(client, "01964a3b-7c8d-7000-8000-deadbeef1234")
```

```crystal
require "manza"

client = Manza::Client.new # reads MANZA_API_KEY

invoice = client.invoices.mark_as_paid("01964a3b-7c8d-7000-8000-deadbeef1234")
```

```php
use Manza\Client;

$client = new Client(apiKey: getenv('MANZA_API_KEY'));

$invoice = $client->invoices->markAsPaid('01964a3b-7c8d-7000-8000-deadbeef1234');
```

## Cancel invoice

`POST` `/api/invoices/:id/cancel`

Cancels the invoice and its associated payment link (if any). Only available from `approved`, `sent` or `overdue`; the invoice keeps its number. A credit note is cancelled the same way, from `approved` or `sent`. Its invoice cannot take a second credit note afterwards.

cURL

CLI

JavaScript

Ruby

Python

Go

Rust

Elixir

Crystal

PHP

```console
curl -X POST "https://za.manza.finance/api/invoices/01964a3b-7c8d-7000-8000-deadbeef1234/cancel" \
  -H "Authorization: Bearer sk_live_..."
```

```console
manza invoices cancel 01964a3b-7c8d-7000-8000-deadbeef1234
```

```javascript
import { Manza } from "@getmanza/sdk";
const manza = new Manza({ apiKey: process.env.MANZA_API_KEY });

await manza.invoices.cancel("01964a3b-7c8d-7000-8000-deadbeef1234");
```

```ruby
require "manza"
manza = Manza.new(api_key: ENV["MANZA_API_KEY"])

manza.invoices.cancel("01964a3b-7c8d-7000-8000-deadbeef1234")
```

```python
from manza import Manza
client = Manza()  # reads MANZA_API_KEY

client.invoices.cancel("01964a3b-7c8d-7000-8000-deadbeef1234")
```

```go
import manza "github.com/getmanza/manza-go/v2"

client, _ := manza.New(manza.WithAPIKey(os.Getenv("MANZA_API_KEY")))

invoice, err := client.Invoices.Cancel(ctx, "01964a3b-7c8d-7000-8000-deadbeef1234")
```

```rust
let client = manza::Client::builder()
    .api_key(std::env::var("MANZA_API_KEY")?)
    .build()?;

let invoice = client.invoices().cancel("01964a3b-7c8d-7000-8000-deadbeef1234")?;
```

```elixir
{:ok, client} = Manza.new(api_key: System.fetch_env!("MANZA_API_KEY"))

{:ok, invoice} = Manza.Invoices.cancel(client, "01964a3b-7c8d-7000-8000-deadbeef1234")
```

```crystal
require "manza"

client = Manza::Client.new # reads MANZA_API_KEY

invoice = client.invoices.cancel("01964a3b-7c8d-7000-8000-deadbeef1234")
```

```php
use Manza\Client;

$client = new Client(apiKey: getenv('MANZA_API_KEY'));

$invoice = $client->invoices->cancel('01964a3b-7c8d-7000-8000-deadbeef1234');
```

## Create credit note

`POST` `/api/invoices/:id/credit_note`

Creates a full credit note against a `paid` invoice: a new invoice with negated line items, starting in `pending_approval`. Requires the `invoices:write` scope and responds 201 Created with the credit note.

A credit note asks nobody to pay. Its `due_date` is null, and its status is one of `draft`, `pending_approval`, `declined`, `approved`, `sent` and `cancelled`: it never becomes overdue or paid.

cURL

CLI

JavaScript

Ruby

Python

Go

Rust

Elixir

Crystal

PHP

```console
curl -X POST "https://za.manza.finance/api/invoices/01964a3b-7c8d-7000-8000-deadbeef1234/credit_note" \
  -H "Authorization: Bearer sk_live_..."
```

```console
manza invoices credit-note 01964a3b-7c8d-7000-8000-deadbeef1234
```

```javascript
import { Manza } from "@getmanza/sdk";
const manza = new Manza({ apiKey: process.env.MANZA_API_KEY });

await manza.invoices.creditNote("01964a3b-7c8d-7000-8000-deadbeef1234");
```

```ruby
require "manza"
manza = Manza.new(api_key: ENV["MANZA_API_KEY"])

manza.invoices.credit_note("01964a3b-7c8d-7000-8000-deadbeef1234")
```

```python
from manza import Manza
client = Manza()  # reads MANZA_API_KEY

client.invoices.credit_note("01964a3b-7c8d-7000-8000-deadbeef1234")
```

```go
import manza "github.com/getmanza/manza-go/v2"

client, _ := manza.New(manza.WithAPIKey(os.Getenv("MANZA_API_KEY")))

creditNote, err := client.Invoices.CreditNote(ctx, "01964a3b-7c8d-7000-8000-deadbeef1234")
```

```rust
let client = manza::Client::builder()
    .api_key(std::env::var("MANZA_API_KEY")?)
    .build()?;

let credit_note = client.invoices().credit_note("01964a3b-7c8d-7000-8000-deadbeef1234")?;
```

```elixir
{:ok, client} = Manza.new(api_key: System.fetch_env!("MANZA_API_KEY"))

{:ok, credit_note} = Manza.Invoices.credit_note(client, "01964a3b-7c8d-7000-8000-deadbeef1234")
```

```crystal
require "manza"

client = Manza::Client.new # reads MANZA_API_KEY

credit_note = client.invoices.credit_note("01964a3b-7c8d-7000-8000-deadbeef1234")
```

```php
use Manza\Client;

$client = new Client(apiKey: getenv('MANZA_API_KEY'));

$creditNote = $client->invoices->creditNote('01964a3b-7c8d-7000-8000-deadbeef1234');
```

| Scenario | Status | Type |
| --- | --- | --- |
| Invoice is not in paid status | 422 | `state_error` |
| A credit note already exists for this invoice | 409 | `conflict` |

## Delete invoice

`DELETE` `/api/invoices/:id`

Only invoices in `draft`, `pending_approval` or `declined` status, before they have a number, can be deleted. Responds `204 No Content`.

cURL

CLI

JavaScript

Ruby

Python

Go

Rust

Elixir

Crystal

PHP

```console
curl -X DELETE "https://za.manza.finance/api/invoices/01964a3b-7c8d-7000-8000-deadbeef1234" \
  -H "Authorization: Bearer sk_live_..."
```

```console
manza invoices delete 01964a3b-7c8d-7000-8000-deadbeef1234
```

```javascript
import { Manza } from "@getmanza/sdk";
const manza = new Manza({ apiKey: process.env.MANZA_API_KEY });

await manza.invoices.delete("01964a3b-7c8d-7000-8000-deadbeef1234");
```

```ruby
require "manza"
manza = Manza.new(api_key: ENV["MANZA_API_KEY"])

manza.invoices.delete("01964a3b-7c8d-7000-8000-deadbeef1234")
```

```python
from manza import Manza
client = Manza()  # reads MANZA_API_KEY

client.invoices.delete("01964a3b-7c8d-7000-8000-deadbeef1234")
```

```go
import manza "github.com/getmanza/manza-go/v2"

client, _ := manza.New(manza.WithAPIKey(os.Getenv("MANZA_API_KEY")))

_, err := client.Invoices.Delete(ctx, "01964a3b-7c8d-7000-8000-deadbeef1234")
```

```rust
let client = manza::Client::builder()
    .api_key(std::env::var("MANZA_API_KEY")?)
    .build()?;

client.invoices().delete("01964a3b-7c8d-7000-8000-deadbeef1234")?;
```

```elixir
{:ok, client} = Manza.new(api_key: System.fetch_env!("MANZA_API_KEY"))

{:ok, _} = Manza.Invoices.delete(client, "01964a3b-7c8d-7000-8000-deadbeef1234")
```

```crystal
require "manza"

client = Manza::Client.new # reads MANZA_API_KEY

client.invoices.delete("01964a3b-7c8d-7000-8000-deadbeef1234")
```

```php
use Manza\Client;

$client = new Client(apiKey: getenv('MANZA_API_KEY'));

$client->invoices->delete('01964a3b-7c8d-7000-8000-deadbeef1234');
```

## Status transitions

API-created invoices land in `pending_approval` and require a member to approve via the dashboard before they can be sent; the approval gives the invoice its number. The `request_approval` and `approve` transitions are not exposed in the API by design. An approver who declines an invoice moves it to `declined`; a member then edits it and requests approval again in the dashboard, or it is deleted. With the `invoices:auto_approve` scope, creates skip both and land directly on `sent`, or on `approved` when the invoice has no send_to_email.

```
Web UI only (no API endpoint):
  draft            → request_approval → pending_approval
  pending_approval → approve          → approved (number given here)
  pending_approval → decline          → declined
  declined         → request_approval → pending_approval

API + Web UI:
  approved → cancel       → cancelled
  approved → send         → sent (needs a send_to_email)
  approved → mark_as_paid → paid
  approved → (automatic, past due_date) → overdue
  sent     → mark_as_paid → paid
  sent     → cancel       → cancelled
  sent     → (automatic, past due_date) → overdue
  overdue  → send         → overdue (only while sent_at is null)
  overdue  → mark_as_paid → paid
  overdue  → cancel       → cancelled
  draft, pending_approval, declined → (delete)
  paid     → credit_note  → (new invoice: starts in pending_approval)

A credit note is never marked as paid and never becomes overdue.

With invoices:auto_approve on the key:
  create / credit_note → (automatic) → sent, or approved with no send_to_email
```

Invalid transitions return a state_error:

```json
{
  "error": {
    "type": "state_error",
    "message": "Invoice cannot be sent from 'paid' status"
  }
}
```