# Billing

Ada subscribes on 3 April and pays $20. Until 3 May she runs one `default` machine for 8 hours on 22 days, and keeps one `small` machine on for all 30 days.

| Machine | Running time | Rate | Cost |
|---|---|---|---|
| `default`, 4 vCPU / 8 GB | 176 hours | $0.018 an hour | $3.17 |
| `small`, 2 vCPU / 4 GB | 720 hours | $0.009 an hour | $6.48 |
| Total | | | $9.65 |

She has used $9.65 of her $20.00. The other $10.35 expires on 3 May, when the next $20.00 arrives. If she had reached zero, her machines would have been shut down with their disks kept, and nothing more would have been charged.

## Subscription tiers

100% of your monthly minimum commitment is usable per-second compute credit. Higher monthly commitments unlock 5x higher parallel VM concurrency (10, 50 and 250 parallel `default` VMs) so we can plan bare-metal capacity and keep pricing affordable. `GET /v1/plans` returns the live plan catalog with no key required:

```console
$ curl -s "https://api.arvm.dev/v1/plans"
```

| Tier | Plan ID | Monthly minimum | Included compute | Parallel `default` VMs | Max machines | Running vCPUs / RAM | Total disk | Network & features |
|---|---|---|---|---:|---:|---:|---:|---|
| **Free** | `trial` | $0 (no card) | $5 starter credit (14 days) | 2 | 3 | 8 / 16 GB | 222 GB | 25 Mbit/s, private URLs, closed inbound, 30 min idle cap, 0 snapshots |
| **Pro** | `standard` | $20/mo | $20/mo (1,111 hrs `default`) | 10 | 30 | 40 / 80 GB | 1,530 GB | 500 Mbit/s, public URLs, 20 snapshots, $10+ top-ups |
| **Max** | `max` | $100/mo | $100/mo (5,555 hrs `default`) | 50 | 150 | 200 / 400 GB | 7,650 GB | 500 Mbit/s, public URLs, 50 snapshots, $10+ top-ups |
| **Ultra** | `ultra` | $500/mo | $500/mo (27,777 hrs `default`) | 250 | 500 | 1,000 / 2,000 GB | 25,500 GB | 500 Mbit/s, public URLs, 100 snapshots, $10+ top-ups |

## What each size costs

Every tier uses the same per-second VM rates. The balance is in dollars, and each size draws from it only while running. A full month is 730 hours.

| Size | vCPUs | Memory | Disk | Rate | A full month |
|---|---|---|---|---|---|
| `small` | 2 | 4 GB | 51 GB | $0.009 an hour | $6.57 |
| `default` | 4 | 8 GB | 51 GB | $0.018 an hour | $13.14 |
| `large` | 8 | 16 GB | 111 GB | $0.036 an hour | $26.28 |

A full month of `default` uses $13.14 of the $20. A full month of `large` uses $26.28, so it takes a $6.28 top-up after the $20.

On these pages 1 GB is 1,073,741,824 bytes, which the API reports exactly. Rates are stored in millionths of a dollar (`9000`, `18000`, `36000`). `GET /v1/sizes` returns the rates in force, and needs no key:

```console
$ curl -s "https://api.arvm.dev/v1/sizes"
```

Paid subscriptions (Pro $20/month, Max $100/month, Ultra $500/month) are charged to your card at the start of each month plus any tax that applies.


## What an hour is

An hour is 3,600 seconds of one machine in the phase `running`. Time is counted in seconds.

- The count starts when the machine's server reports it running. Time spent creating or starting a machine is not counted.
- The count ends when you ask for the stop. Time spent shutting down is not counted.
- If a server stops reporting, the count ends at its last report. You do not pay for time arvm cannot show the machine was running.

Two machines that run for one hour are two hours at their sizes' rates. A `small` machine costs half the `default` rate, and a `large` machine twice.

## What a stopped machine costs

Nothing. A stopped machine keeps its disk, its name and its SSH address, and uses no balance.

Its disk still counts toward the disk your account may hold. A create or a resize that would pass that [limit](machines.md#limits) is refused with `limit_exceeded`.

## The balance

Your balance is the sum of your grants that have not expired. A grant is an amount of money. A grant of the plan has an expiry date, and a top-up has none.

| Grant | Comes from | Expires |
|---|---|---|
| `trial` | Free starter credit claim | 14 days after claim |
| `plan` | Each paid month of Pro, Max or Ultra | When that month ends |
| `topup` | A top-up | Never. Its `expires_at` is `null`. |
| `courtesy` | Support | On the date support sets |

Usage draws from the grant that expires first, and from a grant that does not expire last. So a top-up is not touched until the month's $20 is used up.

See the balance, the grants and how long the balance runs one machine of each size:

```console
$ arvm billing
```

The same through the API:

```console
$ curl -s "https://api.arvm.dev/v1/billing" \
    -H "Authorization: Bearer $ARVM_API_KEY"
```

In the response, amounts are integers in millionths of a dollar: `"balance_micros": 20000000` is $20.00. `runtime_remaining` gives, for each size, the seconds the balance would run one machine of that size.

## Unused balance

Each monthly subscription grant expires when the month ends, and the Free $5 starter credit expires after 14 days. Nothing carries over.

## What happens at zero

1. arvm emails you when 80% of the month's $20 is used.
2. When the balance reaches zero, arvm emails you again.
3. One hour later, if the balance is still zero, arvm shuts your running machines down. The shutdown is a normal operating system shutdown. Every disk is kept.
4. While the balance is zero, starting or creating a machine fails with the error code `insufficient_balance` and status 402.

Nothing is charged to your card at zero, unless you turned [auto top-up](#auto-top-up) on. To keep working, [top up](#top-ups) or wait for the next month.


## Top-ups

A top-up adds prepaid dollars to your balance. Machines draw from it at the same hourly rates as the plan.

- You need an active paid subscription (Pro, Max or Ultra) to top up. Unpaid and Free starter orgs cannot purchase top-ups; the request fails with `subscription_required` (402).
- The smallest top-up is $10.
- A top-up does not expire. What is left of it stays in your balance until you use it.
- A `default` machine that never stops uses $13.14 for a full month, inside the $20 plan with $6.86 left. Two `default` machines running all month use $26.28: the $20 plan plus $6.28 from a top-up.


Start a top-up. The response holds a `url` on Stripe. Open it in a browser to pay.

```console
$ curl -s -X POST "https://api.arvm.dev/v1/billing/top-ups" \
    -H "Authorization: Bearer $ARVM_API_KEY" \
    -H "Idempotency-Key: $(uuidgen)" \
    -H "Content-Type: application/json" \
    -d '{"amount_micros": 10000000}'
```

The balance grows when Stripe confirms the payment. The plan's limits on a top-up are the fields `topup_min_micros` and `topup_max_micros` of `GET /v1/billing`.

## Auto top-up

Auto top-up charges your card when the balance runs low, so that your machines are not stopped while you are away. It is off until you turn it on in the dashboard's billing page, where you set the threshold, charge amount, and the most it may charge in a calendar month.

Turning auto top-up on or changing its amounts requires a browser session (`PUT /v1/billing/auto-top-up` does not accept an API key), so an API key cannot spend money on a saved card.

See where it stands, and what it has charged this month:

```console
$ arvm billing auto-top-up
```

Turn it off (from the dashboard, the CLI, or a full API key):

```console
$ arvm billing auto-top-up off
```

How it behaves:

- **It charges the card your subscription is paid with.** You need an active subscription. If no card is saved, the request fails with the error code `payment_method_required`: add a card in the billing portal, which the dashboard's billing page opens, and set auto top-up again.
- **Each charge is a top-up.** It is added to the balance when your bank has paid it, it appears in the ledger as a `grant` entry, and its receipt is emailed. Like any top-up it does not expire, and the amount must be within the plan's top-up limits.
- **One charge at a time.** A second charge is not started while the first has no answer.
- **The monthly maximum is yours.** It counts what auto top-up has charged since the calendar month began, in UTC. When one more charge would pass it, nothing is charged, arvm emails you once, and the `state` is `at_monthly_max` until the month ends or you raise the maximum. A top-up you pay by hand does not count toward it.
- **A charge that fails stops it.** Nothing was added to the balance, arvm emails you, and the `state` is `stopped` until you set auto top-up again. `stopped_reason` says why: what the card's bank said when it declined the card, or `the charge could not be made` when the charge failed for another reason. Check the card in the billing portal before you turn it on again.
- **With auto top-up off or stopped, or at its maximum, the rules at zero apply.** See [What happens at zero](#what-happens-at-zero).

## Add-ons

| Add-on | Price |
|---|---|
| Snapshot storage | $0.10 per GB a month, for what the snapshot stores |

Snapshot storage draws from the same balance as machine time. [Snapshots](snapshots.md) explains what is stored. [What a snapshot costs](snapshots.md#what-a-snapshot-costs) says when snapshot storage is charged, and what happens to the charge of a snapshot that is lost.

Not sold: a larger disk than the size includes, a dedicated IPv4 address, and outbound email on port 25.

## See what was used

Usage by day, one row for each machine or snapshot that used anything:

```console
$ curl -s "https://api.arvm.dev/v1/billing/usage" \
    -H "Authorization: Bearer $ARVM_API_KEY"
```

Every movement of the balance, newest first:

```console
$ curl -s "https://api.arvm.dev/v1/billing/ledger" \
    -H "Authorization: Bearer $ARVM_API_KEY"
```

What one machine used this calendar month:

```console
$ curl -s "https://api.arvm.dev/v1/machines/calm-river-otter/usage" \
    -H "Authorization: Bearer $ARVM_API_KEY"
```

The ledger only grows: an entry is never changed or removed. [The billing reference](api/billing.md) describes every field.

## Pay, cancel and refunds

Card details, invoices and cancellation are on a page that Stripe hosts. Get a link to it:

```console
$ curl -s -X POST "https://api.arvm.dev/v1/billing/portal" \
    -H "Authorization: Bearer $ARVM_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{}'
```

- **Cancel.** The subscription runs to the end of the month you paid for. The month's balance stays usable until then.
- **Refunds.** arvm does not refund unused time.
- **A payment that fails.** The new month's $20 grant stays in place for a 48-hour grace period from the first failed charge so a card retry does not interrupt running machines. If the charge has still not succeeded after 48 hours, what is left of that unpaid month's grant is removed; if you have no top-up balance remaining, the balance reaches zero and [the rules at zero](#what-happens-at-zero) apply. If Stripe collects the payment later, the removed amount is restored for that month. Stripe tries the payment again for a while; when it stops trying, the subscription ends.
- **After the subscription ends.** Your running machines stop, and no machine can be started or created until you subscribe again: the request fails with the error code `subscription_required` and status 402. You can still sign in, read everything, delete machines and snapshots, and take a snapshot of a stopped machine. Your balance is not changed: a top-up stays for when you come back, this period's plan balance still expires when the period ends, and snapshot storage is still charged to it. `GET /v1/billing` says when the subscription ended, as `subscription_ended_at`, until you subscribe again.
- **Your machines and snapshots after the subscription ends.** Each machine's disk stays on its server for at least 14 days. arvm then archives the disk: it moves the disk to object storage and deletes it from the server. Before arvm deletes an archived machine, it sends you three warnings by email. Every warning sent after arvm sets the date of the deletion states that date, and the third always does. The date is at least 90 days after the subscription ended and at least 7 days after the first warning that states it. arvm deletes the machine and its archived disk on that date or later, and at least a day after the last warning was delivered. A deleted machine cannot be recovered. Snapshots are not archived: they stay on their server. While the subscription stays ended, arvm deletes them with the account's machines on the deletion date, after the same three warnings. A subscription that starts again before that date keeps them. The [terms of service](../legal/terms.md#6-your-data) state the same rules.
- **Coming back.** Subscribe again, then start your machines. None starts by itself. A machine whose disk was archived first comes back to a server, with its ID and name. Start it once its phase is `stopped`.
