# Device states, earnings and payouts

Calls go to https://supply.coronium.ai, signed in as in [enrolment](/guides/device-enrol.md).

## Steps

1. Read the devices, about once a minute until the new one is measured.

```sh
umask 077
SUPPLY=${SUPPLY:-https://supply.coronium.ai}
curl -sS -b coronium.cookies "$SUPPLY/app/api/devices" | jq -c '.devices[] | {deviceId, status, state, reason}'
```

Expect: `online` once the agent connects. Then act on `state` and `reason`:

| Reads | Means | Do |
|---|---|---|
| `status` `offline` | the agent is not connected | read the agent's log: each line names its cause and fix |
| `new`, `not_measured` | connected, not measured yet | read again a minute later |
| `withheld`, `unclassified_asn` | Coronium has not classified this network yet | nothing: leave it running, tell your person, do not enrol again |
| `withheld`, `class_not_sold` | a network Coronium does not sell, such as a data centre | stop: this device will not carry buyer traffic |
| `withheld`, `same_exit` | an earlier residential device, of any account, exits from this address | move it to a connection of its own, or stop it |
| `withheld`, `exit_unverified` or `exit_changed` | three measurements in a row failed, or the country changed | keep it running: it is measured again |
| `withheld`, `supplier_blocked` | the operator blocked the account | tell your person |
| `admitted` | carries buyer traffic as fallback supply | done |
| `established` | carries traffic first, after the operator promoted it on a clean history | done |
| `paused`, `private` | the account's own choice | nothing, unless your person asks |
| `withdrawn` | permanent | a new enrolment, if your person wants one |

`requests`, `bytesUp` and `bytesDown` include Coronium's own measurements of the exit, one request each, which earn nothing. Safe to repeat: yes.

2. Read the earnings.

```sh
umask 077
SUPPLY=${SUPPLY:-https://supply.coronium.ai}
curl -sS -b coronium.cookies "$SUPPLY/app/api/earnings" | jq '{earned, held, available, requested, paid, payoutMinimumUsdMicros, terms}'
```

Expect: the totals; the full answer lists each day and device with the bytes carried, what buyers paid, the share and the release day. `terms` is what the ledger applies to this account: `holdDays`, `deviceLimit` (null without a limit), `shareBp` (null while Coronium does not charge buyers) and `charging`. Read them here, never from memory. Traffic from a free grant, traffic a buyer could not pay for and an account's own traffic earn nothing. Safe to repeat: yes.

3. Ask for a payout, only with your person's word: `POST /app/api/payouts` with the exact amount in whole cents, `asset` (`USDC` or `USDT`), `network`, `address` and the access code as proof. One request waits at a time, paid by hand once a month; an account that owes for its own buyer traffic is refused `buyer_in_debt`. Safe to repeat: no.

## Stop and withdraw

Stopping the agent stops sharing. Withdrawing a device, or more devices on one account, is a request to Coronium at the contact in section 10 of the partner agreement; there is no API call, and a withdrawal does not stop a running agent.
