# Invoices

> Read the invoice B7R made for an order, and download its PDF, with the same figures as the order's page in the app.

Source: https://docs.b7r.app/invoices

B7R makes one invoice for an order when the order moves to In Production: what B7R charged your wallet for it, the lines and the shipping. The two reads below need the `invoices:read` area, which goes with `orders:read`. They answer the invoice your order's page in the app shows, for any order of your account, whatever its channel. Another account's order answers `404 not_found`, exactly like an order that does not exist.

- An order still Created has no invoice: `404 not_found`. Read it again once the order is In Production.
- An Admin edit of an order makes a new invoice beside the first: both reads answer the newest, as the app does.
- `credited` is `true` when a credit note reverses the invoice: the order was cancelled after it was made. A credit note is a document of its own and is not answered here.
- `kind` is `tax_invoice` for a VAT invoice and `invoice` for one made before B7R charged VAT. `vat_rate` is the rate locked on the order.

## Read an invoice

`GET /v1/orders/{order_id}/invoice`

The invoice as its PDF states it: each line net of VAT, then the totals as money (`net`, `vat`, `gross`). The buyer and seller details stay in the PDF. `pdf_ready` is `false` when B7R has no PDF of the invoice.

Key: A key with the `invoices:read` area.

Path:

- `order_id` (string, required): B7R's order id: opaque, `B` and digits.

Answer:

- `number` (string, required): The invoice number, as on the PDF.
- `order_id` (string, required)
- `kind` (string, required): tax_invoice: a VAT invoice. invoice: an invoice issued before B7R charged VAT. One of `tax_invoice`, `invoice`.
- `issued_at` (string, required)
- `lines` (array of object, required)
  - `description` (string, required): As the invoice prints it. The shipping line is the last: `Shipping`, then the carrier's name after a long dash when the order has one.
  - `quantity` (integer, required)
  - `unit_price` (string, required): One unit, net of VAT.
  - `total` (string, required): The line, net of VAT.
- `vat_rate` (number, required): The rate locked on the order, a decimal: 0.15 is 15 %. 0 to 1.
- `total` (object, required): net: the lines with shipping, net of VAT; vat; gross: what the invoice totals.
  - `net` (string, required)
  - `vat` (string, required)
  - `gross` (string, required)
  - `currency` (constant, required): Always `"SAR"`.
- `credited` (boolean, required): True when a credit note reverses this invoice: the order was cancelled after it was made.
- `pdf_ready` (boolean, required): False when B7R has no PDF of this invoice: the PDF read answers 409 invoice_not_ready, and retrying will not change that.

Errors: `unauthorized` (401), `area_forbidden` (403), `account_inactive` (403), `connection_disabled` (403), `https_required` (403), `not_found` (404), `invalid_request` (400), `rate_limited` (429), `internal_error` (500), `upstream_unavailable` (502), `api_unavailable` (503), `request_expired` (503), `service_unavailable` (503), `upstream_timeout` (504). See [Errors](https://docs.b7r.app/errors).

Request:

```bash
curl https://api.b7r.app/v1/orders/B26112200042/invoice \
  -H "Authorization: Bearer $B7R_API_KEY"
```

```javascript
const res = await fetch("https://api.b7r.app/v1/orders/B26112200042/invoice", {
  headers: {
    Authorization: `Bearer ${process.env.B7R_API_KEY}`,
  },
});
const data = await res.json();
```

```python
import os, requests

res = requests.get(
    "https://api.b7r.app/v1/orders/B26112200042/invoice",
    headers={
        "Authorization": f"Bearer {os.environ['B7R_API_KEY']}",
    },
    timeout=30,
)
data = res.json()
```

Answer (200 OK):

```json
{
  "number": "WC26112400017",
  "order_id": "B26112200042",
  "kind": "invoice",
  "issued_at": "2026-11-24T09:12:44.512Z",
  "lines": [
    {
      "description": "T-shirt Classic (B7R-TS-001-BLK-M)",
      "quantity": 2,
      "unit_price": "40.00",
      "total": "80.00"
    },
    {
      "description": "Shipping",
      "quantity": 1,
      "unit_price": "25.00",
      "total": "25.00"
    }
  ],
  "vat_rate": 0,
  "total": {
    "net": "105.00",
    "vat": "0.00",
    "gross": "105.00",
    "currency": "SAR"
  },
  "credited": false,
  "pdf_ready": true
}
```

## Download the invoice PDF

`GET /v1/orders/{order_id}/invoice/pdf`

The PDF itself, as `application/pdf`, the same file the app downloads. Save the bytes as they come; the answer is never cached and names no file: the app saves the same file as `B7R-<order_id>.pdf`. When B7R has no PDF of the invoice, the answer is `409 invoice_not_ready`, and retrying will not change that: open a ticket from the Help Center in the B7R app. Every download is written to your activity log with the key that made it.

Key: A key with the `invoices:read` area.

Path:

- `order_id` (string, required): B7R's order id: opaque, `B` and digits.

Answer:



Errors: `unauthorized` (401), `area_forbidden` (403), `account_inactive` (403), `connection_disabled` (403), `https_required` (403), `not_found` (404), `invalid_request` (400), `rate_limited` (429), `internal_error` (500), `upstream_unavailable` (502), `api_unavailable` (503), `request_expired` (503), `service_unavailable` (503), `upstream_timeout` (504), `invoice_not_ready` (409). See [Errors](https://docs.b7r.app/errors).

Request:

```bash
curl https://api.b7r.app/v1/orders/B26112200042/invoice/pdf \
  -H "Authorization: Bearer $B7R_API_KEY"
```

```javascript
const res = await fetch("https://api.b7r.app/v1/orders/B26112200042/invoice/pdf", {
  headers: {
    Authorization: `Bearer ${process.env.B7R_API_KEY}`,
  },
});
const data = await res.json();
```

```python
import os, requests

res = requests.get(
    "https://api.b7r.app/v1/orders/B26112200042/invoice/pdf",
    headers={
        "Authorization": f"Bearer {os.environ['B7R_API_KEY']}",
    },
    timeout=30,
)
data = res.json()
```

Answer (200 OK): the file, byte for byte, as `application/pdf`.
