# Invoice programs: create, get, list

URL: /code/mcp/invoice/records · Id: `page:code/mcp/invoice/records`

> The Invoice Verbs create, get, list as MCP do programs, with inputs, result, refusals and an example.

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

### Invoice.create
Creates an Invoice. [Verb page](/business/nouns/invoice/create?interface=mcp).

```text
do: return await $.Invoice.create(input)
```

Emits `Invoice.created`.

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `total` | `money` | Yes | The amount due. |
| `due` | `date` | Yes | 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. |
| `subscription` | [Subscription](/business/nouns/subscription) | No | The Invoices the Subscription issues, one for each period it renews. |
| `customer` | [Customer](/business/nouns/customer) | No | Each Invoice is owed by one Customer. |

**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**

```json
{
  "name": "do",
  "arguments": {
    "code": "return await $.Invoice.create({ total: { amount: 29, currency: 'USD' }, due: '2026-10-22' })"
  }
}
```

### Invoice.get
Returns one Invoice by id. [Verb page](/business/nouns/invoice/get?interface=mcp).

```text
do: return await $.Invoice.get(input)
```

Reads only: it emits no Event.

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | The id of the Invoice. |
| `at` | `string` | No | A time or Version name: the record as it stood then. Unset: as it stands now. |

**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**

```json
{
  "name": "do",
  "arguments": {
    "code": "return await $.Invoice.get({ id: 'inv_9sfvgeRT7L' })"
  }
}
```

### Invoice.list
Returns Invoices, newest first, one page at a time. [Verb page](/business/nouns/invoice/list?interface=mcp).

```text
do: return await $.Invoice.list(input)
```

Reads only: it emits no Event.

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `limit` | `integer` | No | At most this many records, up to 100. The default is 20. |
| `after` | `string` | No | The cursor from the previous page. |
| `where` | `string` | No | A filter over the properties, such as `paidAt = null and total.amount > 500`. |
| `sort` | `string` | No | Properties to sort by, comma-separated; a leading minus sorts descending. |
| `total` | `boolean` | No | True adds the match count as `meta.total`, exact up to 10,000 matches and estimated above. |
| `facets` | `string` | No | Properties to count by value, comma-separated, returned as `meta.facets`. |
| `fields` | `string` | No | Properties to return on each record, comma-separated; `$id` and `$type` always return. |
| `include` | `string` | No | Related records to embed in place of their URLs, comma-separated. |
| `depth` | `integer` | No | How many levels of related records to embed. The default is 1. |
| `q` | `string` | No | Words to match across the text properties, ranked by relevance. |
| `match` | `string` | No | Ranks the search by `words`, or `meaning`; words is the default. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `invoices` | list of [Invoice](/business/nouns/invoice) | Yes | One page of Invoices. |

**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**

```json
{
  "name": "do",
  "arguments": {
    "code": "return await $.Invoice.list({ limit: 20 })"
  }
}
```