Ask for an invitation
Menu

Endpoint

Update a draft invoice

PATCH/v1/invoices/{id}

Any create parameter, while draft. On an open invoice only due_date, memo, footer, reminders and metadata can change.

Scope a restricted key needs
invoices:write
Publishable key
Not allowed: secret or restricted key only
Idempotency-Key
Not used. A PATCH is already safe to repeat.

Parameters

Parameters of Update a draft invoice
ParameterType and placeMeaning
idrequiredstringpathThe id of the invoice.
Orrerie-VersionstringheaderAPI version date. Default: the version the key was created with. Example 2026-10-11.

Request body

A JSON object. The body is required. A field the call does not list is refused with parameter_unknown.

Request body of Update a draft invoice
FieldTypeMeaning
currencystringAn ISO 4217 code; a draft only.
line_itemsarray of values1 to 100 items: {price, quantity} or {name, unit_amount, quantity}.
discount_amountstringSubtracted from the subtotal. Pattern ^\d+(\.\d+)?$.
tax_amountstringAdded to the total. Typed by you. Pattern ^\d+(\.\d+)?$.
due_datestring (date)YYYY-MM-DD, today or later, in the merchant's time zone.
memostringUp to 2,000 characters, shown on the invoice.
footerstringUp to 500 characters.
remindersobject{days_before_due: [..], days_after_due: [..]}, each up to 3 values of 0 to 30. Default [3] and [1, 7].
metadataobjectYour own key-value data (rules in Metadata).

Example request

curl

curl -X PATCH https://api.orrerie.com/v1/invoices/inv_sxr44t9zk7krg104gmhsqx2p \
  -H "Authorization: Bearer $ORRERIE_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "due_date": "2026-10-29"
}'

JavaScript

const response = await fetch("https://api.orrerie.com/v1/invoices/inv_sxr44t9zk7krg104gmhsqx2p", {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.ORRERIE_SECRET_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "due_date": "2026-10-29"
  }),
});
const result = await response.json();
if (!response.ok) throw new Error(`${result.error.code}: ${result.error.message}`);
console.log(result);

Python

import os
import requests

response = requests.patch(
    "https://api.orrerie.com/v1/invoices/inv_sxr44t9zk7krg104gmhsqx2p",
    headers={"Authorization": f"Bearer {os.environ['ORRERIE_SECRET_KEY']}"},
    json={
        "due_date": "2026-10-29",
    },
    timeout=30,
)
result = response.json()
if not response.ok:
    raise RuntimeError(f"{result['error']['code']}: {result['error']['message']}")
print(result)

PHP

<?php
$request = curl_init('https://api.orrerie.com/v1/invoices/inv_sxr44t9zk7krg104gmhsqx2p');
curl_setopt_array($request, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'PATCH',
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('ORRERIE_SECRET_KEY'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'due_date' => '2026-10-29',
    ]),
]);
$body = curl_exec($request);
if ($body === false) {
    throw new RuntimeException(curl_error($request));
}
$result = json_decode($body, true);
if (curl_getinfo($request, CURLINFO_HTTP_CODE) >= 400) {
    throw new RuntimeException($result['error']['code'] . ': ' . $result['error']['message']);
}
print_r($result);

Responses

200 OK

The answer is the invoice object. Headers: Orrerie-Request-Id.

Example response, 200

{
  "id": "inv_sxr44t9zk7krg104gmhsqx2p",
  "object": "invoice",
  "livemode": true,
  "created": "2026-10-08T09:00:00.000Z",
  "updated": "2026-10-08T09:02:00.000Z",
  "number": "INV-0042",
  "status": "open",
  "overdue": false,
  "customer": "cus_8ea07c40qsvv19f7rgmeb8ha",
  "order": "ord_18ayqdcy8s50t2dp5r257ep3",
  "currency": "USD",
  "line_items": [
    {
      "name": "Wholesale beans, 20 kg",
      "quantity": 20,
      "unit_amount": "17.50",
      "amount": "350.00",
      "price": null
    }
  ],
  "subtotal": "350.00",
  "discount_amount": "0.00",
  "tax_amount": "0.00",
  "total": "350.00",
  "amount_paid": "0.00",
  "amount_due": "350.00",
  "due_date": "2026-10-29",
  "memo": "Thank you for your order.",
  "footer": "Acme Coffee Roasters LLC",
  "url": "https://pay.orrerie.com/i/inv_sxr44t9zk7krg104gmhsqx2p",
  "pdf": "file_jgxe7twfcheqtdha9pafpnc3",
  "reminders": {
    "days_before_due": [
      3
    ],
    "days_after_due": [
      1,
      7
    ]
  },
  "finalized_at": "2026-10-08T09:02:00.000Z",
  "sent_at": "2026-10-08T09:02:05.000Z",
  "paid_at": null,
  "voided_at": null,
  "metadata": {}
}

Any other status: an error

A status of 400 or above answers with the error object. Branch on its code, never on its message.

Errors

Beside the errors every call can answer with (a bad key, a missing scope, the rate limit), this call answers with:

Errors of Update a draft invoice
CodeHTTPMeaning
invoice_not_editable409The field cannot change in the invoice's present state.