---
title: Billing API (invoices & credit)
description: GET /v1/invoices and GET /v1/billing/credit — invoices, amounts, payment status and credit balance
sidebar:
  order: 5
  badge:
    text: Alpha
    variant: success
---

Returns the token owner's invoices and account credit, **read-only**. These endpoints never pay, charge or move credit.

:::note[Amounts]
Amounts are in the account currency, **Iranian Rial (IRR)**, and every amount has a **Toman** equivalent with a `_toman` suffix (1 Toman = 10 Rial).
:::

## List invoices

```http
GET https://api.hostino.ai/v1/invoices
Authorization: Bearer ACCESS_TOKEN
```

| Item | Value |
|---|---|
| Required scope | `invoices:read` |
| `status` (optional) | `Unpaid`, `Paid`, `Overdue` (unpaid and past due), `Cancelled`, `Refunded`, `Draft`, `Collections`, `Payment Pending` (case-insensitive) |
| `invoice_id` (optional) | Only this invoice, **including its line items** |

```bash
curl -s "https://api.hostino.ai/v1/invoices?status=Unpaid" -H "Authorization: Bearer $TOKEN"
```

```json
{
  "count": 1,
  "invoices": [
    {
      "id": 1683,
      "number": "1683",
      "status": "Unpaid",
      "issued_on": "2026-10-06",
      "due_date": "2026-10-06",
      "paid_on": null,
      "days_until_due": -15,
      "overdue": true,
      "currency": "IRR",
      "subtotal": 950000,
      "tax": 95000,
      "credit_applied": 0,
      "total": 1045000,
      "balance_due": 1045000,
      "total_toman": 104500,
      "balance_due_toman": 104500
    }
  ]
}
```

| Field | Description |
|---|---|
| `number` | Invoice number (the `id` when no custom number is set) |
| `issued_on` / `due_date` / `paid_on` | Issue, due and paid dates (`YYYY-MM-DD`) |
| `days_until_due` | Unpaid invoices only; **negative means overdue** |
| `overdue` | Unpaid and past due |
| `subtotal` / `tax` | Amount before tax and the VAT |
| `credit_applied` | Credit applied to the invoice |
| `total` | Invoice total (before credit) |
| `balance_due` | Amount still to pay; `0` for paid/cancelled invoices |
| `items` | (with `invoice_id` only) description and amount of each line |

:::note
Responses do **not** include the payment gateway/method, transactions, notes or customer name/company. An invoice that belongs to another account returns `404 invoice_not_found`, exactly like a missing one.
:::

## Credit balance

```http
GET https://api.hostino.ai/v1/billing/credit
Authorization: Bearer ACCESS_TOKEN
```

| Item | Value |
|---|---|
| Required scope | `billing:read` |

```json
{ "balance": 1960672, "currency": "IRR", "balance_toman": 196067 }
```

## Pay an invoice from credit

Pays an unpaid invoice (for example a hosting or domain renewal) from the account credit, in two steps and **only with a phrase the account owner types themselves**. Both steps need the `orders:confirm` and `billing:pay` scopes.

**Step 1: prepare** (no money moves)

```bash
curl -s -X POST https://api.hostino.ai/v1/invoices/1234/credit-payment -H "Authorization: Bearer $TOKEN"
```

```json
{
  "request_id": "q7Yd…",
  "invoice_id": 1234,
  "amount_toman": 1250000,
  "credit_balance_toman": 3000000,
  "payable": true,
  "phrase": { "fa": "تایید پرداخت 1,250,000 تومان از اعتبار کد 4821", "en": "confirm paying 1,250,000 toman from credit code 4821" }
}
```

If the credit is not enough, you get `payable: false` with `reason: "insufficient_credit"` and a `payment_url`; if the invoice is not unpaid, `reason: "not_unpaid"`.

**Step 2: confirm**

```bash
curl -s -X POST https://api.hostino.ai/v1/invoice-payments/q7Yd…/confirm -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" -d '{"confirmation":"confirm paying 1,250,000 toman from credit code 4821"}'
```

A successful response is `{"status":"paid", "invoice_id":1234, "amount_toman":1250000}`. Errors on this path: `409 amount_changed` (the invoice amount changed; the new phrase is in the response), `400 confirmation_mismatch` (at most 5 attempts), `402 insufficient_credit` and `410 request_expired` (the request expires after about 15 minutes).

## Errors

| Code | Body | Cause |
|---|---|---|
| `400` | `invalid_status` / `invalid_invoice_id` | Invalid filter value |
| `401` | `missing_token` / `inactive_token` / `invalid_audience` | Token problem |
| `403` | `insufficient_scope` | Token lacks `invoices:read` or `billing:read` |
| `404` | `invoice_not_found` | Invoice doesn't exist or isn't yours |
| `502` | `backend_error` | Temporary internal error |

## In MCP

The [`list_invoices`](/en/ai-mcp/remote-mcp/#list_invoices) and [`get_credit_balance`](/en/ai-mcp/remote-mcp/#get_credit_balance) tools, and `prepare_invoice_payment` / `pay_invoice_with_credit` for paying from credit ([guide](/en/ai-mcp/dns-ssl-support/)).
