> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wave.sa/llms.txt
> Use this file to discover all available pages before exploring further.

# Billing

> How the wallet, top-up, project budgets and invoices work in the Wave portal.

Wave has one **wallet** for each organization. Charges come out of the wallet.
You manage the wallet on the **Billing** page of the portal. All amounts are in
Saudi riyals (SAR).

## Who can do what

| Role | What the role can do on the Billing page |
| - | - |
| `owner` | Everything: read, top up, split the wallet across projects, turn project budgets on or off, generate an invoice. |
| `billing` | Read, top up, and split the wallet across projects. |
| `admin` | Read, and generate an invoice. An `admin` cannot top up or split the wallet. |
| `developer`, `supervisor`, `agent` | No access to the Billing page. |

The Billing page is open from the first day. You do not need a Go-Live to use it.

## Wallet

The top of the Billing page shows your **balance**. Below it you see these
parts:

* **Rate plan.** The unit price of each usage type.
* **Usage.** The charges of the last 30 days, with the price in SAR. The list
  shows at most 500 charges.
* **Invoices.** The invoices of your organization.

When the balance is 0 or less, an action that costs money returns `402
INSUFFICIENT_CREDITS`. For example, buying a number is such an action. Top up to
continue.

### Call charges

A call charge counts each started minute of an answered production call. The
minimum is one minute. A sandbox call is not billed. See
[Sandbox mode](https://docs.wave.sa/sandbox-mode.md). Each charge shows on the **Usage** list, and the
amount comes out of the wallet.

## Top up

1. Open **Billing**.
2. Select an amount (50, 100 or 500 SAR), or type your own amount. The amount
   must be more than 0 and not more than 100,000 SAR.
3. Select **Top up**.
4. The portal sends you to the payment page of the payment provider. Pay there
   with a card or Apple Pay.

After you pay, the portal shows **Payment received** and the new balance. The
payment provider tells Wave that the payment is complete, and then Wave adds the
money to the wallet. If the page shows **Payment not confirmed yet**, wait a
moment and select **Check again**. Wave adds the money once only, also if you
select **Check again** many times.

Only the `owner` and the `billing` role can top up. If the payment provider
cannot start the payment, the portal shows an error (`502 PAYMENT_FAILED`). Try
again later.

## Project budgets

By default, all projects spend from the main balance. With **project budgets**,
you give each project its own part of the wallet. A project can spend only from
its own budget.

**Project budgets** is a switch for the whole organization. Only the `owner` can
turn it on or off.

* **Off (default).** Each charge comes out of the main balance.
* **On.** Each project spends from its own budget. When the budget of a project
  reaches 0, the project stops with `402 INSUFFICIENT_PROJECT_BALANCE`.

> [!WARNING]
>
> When you turn the switch on, no money moves. A project that has no budget stops
> working until you add money to it.

To move money:

1. In **Project budgets**, find the project. The **Unallocated** amount is the
   part of the wallet that no project has.
2. Type an amount in SAR (at most 2 decimal places).
3. Select **Add to project** to move the money from the unallocated amount to the
   project. Select **Take back** to move money from the project to the unallocated
   amount.

If the unallocated amount is less than the amount that you ask for, Wave returns
`402 INSUFFICIENT_POOL_BALANCE`. If the project has less than the amount that you
take back, Wave returns `402 INSUFFICIENT_PROJECT_BALANCE`.

Select **Ledger** on a project to see all its entries: money added, money taken
back, usage, refunds and adjustments. Each entry shows the balance after it.

## Invoices

An invoice groups the usage charges of one period that no invoice has yet. It
shows three amounts:

| Amount | Meaning |
| - | - |
| Net | The sum of the charges. |
| VAT | 15% of the net amount. |
| Gross | The net amount plus VAT. |

The **Invoices** list shows the period and the three amounts of each invoice. An
invoice detail shows one line for each usage type, with the quantity and the net
amount.

An `owner` or an `admin` can select **Generate invoice**. This groups the charges
of the current month so far that no invoice has yet. If there are no such charges,
Wave makes no invoice. A charge is on one invoice only.

## Billing API

The portal uses these routes. They need a portal session, not an API key.

| Route | What it does |
| - | - |
| `GET /v1/billing/balance` | The balance of the wallet. |
| `GET /v1/billing/usage` | The usage charges, with `from` and `to` (default: the last 30 days). |
| `GET /v1/billing/invoices` | The list of invoices. |
| `GET /v1/billing/invoices/{id}` | One invoice, with its line items. |
| `POST /v1/billing/topup` | Start a top-up (`amount_sar`). |
| `GET /v1/billing/projects` | The unallocated amount and the balance of each project. |
| `POST /v1/billing/projects/{projectId}/allocate` and `/deallocate` | Move money to or from a project (`amount_sar`). |

## Errors

| Status | Code | When |
| - | - | - |
| `402` | `INSUFFICIENT_CREDITS` | The balance is 0 or less. Top up. |
| `402` | `INSUFFICIENT_PROJECT_BALANCE` | Project budgets are on and the budget of the project is used up. |
| `402` | `INSUFFICIENT_POOL_BALANCE` | The unallocated amount is less than the amount that you ask for. |
| `404` | `INVOICE_NOT_FOUND` | No such invoice in your organization. |
| `502` | `PAYMENT_FAILED` | The payment provider could not start the top-up. |

## Next steps

> [card] [Sandbox mode](https://docs.wave.sa/sandbox-mode.md)
>
> What sandbox keys can do, and what is not billed.

> [card] [Errors](https://docs.wave.sa/errors.md)
>
> All error codes of the Wave API.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.