# Invoice routes: update

URL: /code/api/invoice/records-update · Id: `page:code/api/invoice/records-update`

> The Invoice Verbs update as api.sb routes, with inputs, result, refusals and an example.

Reference for [Invoice](/business/nouns/invoice), one group of [Invoice routes](/code/api/invoice).

### Invoice.update
Changes the given properties of an Invoice. [Verb page](/business/nouns/invoice/update?interface=api).

```text
PATCH /{namespace}/invoices/{id}
```

Path: `id`. Body, as JSON: the other inputs. Emits `Invoice.updated`.

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | The id of the Invoice. |
| `total` | `money` | No | The amount due. |
| `due` | `date` | No | When payment is due. |
| `paidAt` | `datetime` | No | When it was paid. |
| `collection` | `string` | No | `charge` charges the saved payment method; `send` sends the Invoice and waits for a transfer. `charge` by default. |
| `terms` | `integer` | No | Days from issue until a `send` Invoice is due, such as 30; sets `due`. |
| `purchaseOrder` | `string` | No | The Customer’s purchase order number, printed on the Invoice. |
| `refunded` | `money` | No | The total returned to the Customer, from zero up to the amount paid. |
| `number` | `string` | No | The Invoice number, sequential per Startup and never reused, voided Invoices included. |
| `lines` | `json` | No | Each Offer billed: its quantity, Period and amount, with any Coupon or Credit Grant applied. |
| `pdf` | `url` | No | The Invoice, or its receipt once paid, as a PDF on the Startup’s Domain that names the seller of record. |
| `payUrl` | `url` | No | The page on the Startup’s Domain where the Customer pays it by card or bank transfer. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `invoice` | [Invoice](/business/nouns/invoice) | Yes | The Invoice. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |

**Example**

```bash
curl -X PATCH https://api.sb/leaseline.app/invoices/inv_9sfvgeRT7L \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"total":{"amount":29,"currency":"USD"}}'
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "invoice": {
    "$id": "https://api.sb/leaseline.app/invoices/inv_9sfvgeRT7L",
    "$type": "Invoice",
    "total": {
      "amount": 29,
      "currency": "USD"
    },
    "due": "2026-10-01"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Invoice.update",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```