# Agreements

> Countersignature, payment confirmation, activation checks, cancellation and disputes.

Source: https://cairva.xyz/docs/agreements

An agreement is created the moment a buyer accepts a quote version. It holds the accepted terms, the price and a contract hash, and it decides when the allocation behind it can run.

## States

| State | What's happening | Who acts next |
| --- | --- | --- |
| `awaiting_approval` | The buyer accepted. Capacity is reserved on the lot | Supplier countersigns |
| `awaiting_payment` | Countersigned. An invoice is issued | Buyer pays and records the reference, then Cairva operations confirm |
| `provisioning` | Settled. Activation checks are running | Cairva |
| `active` | The allocation can serve requests | Nobody |
| `completed` | The allowance was used up, or the window ended after activation | Nobody |
| `expired` | The window ended before activation | Nobody |
| `cancelled` | Cancelled before activation | Nobody |
| `disputed` | A dispute is open | Cairva operations |

Sandbox agreements go straight from countersignature to `provisioning` with a zero-amount record marked paid. No money moves.

## Countersignature

An admin of the supplier organization countersigns. That issues the invoice for a live agreement, or the no-charge record for a sandbox one, and notifies the buyer.

## Payment

For a live agreement, the buyer pays the invoice outside Cairva and records the payment reference in the workspace. Cairva operations then confirm receipt or reject it with a note, which puts the invoice back to issued. See [Settlement](https://cairva.xyz/docs/settlement).

## Activation checks

Activation only succeeds when every check is true at that moment:

- the supplier countersigned
- payment is confirmed, or the sandbox settlement is recorded
- the supplier is still verified
- the inventory lot is still active
- the route is enabled
- the route passed a live health check, run as part of activation
- the delivery window hasn't ended

If any check fails, the agreement stays in `provisioning` and shows which checks it's waiting on. When they pass, the allocation becomes `active`, or `ready` if its window hasn't started, and the buyer is told to create an API key.

## Cancelling

Either party's admin, or Cairva operations, can cancel an agreement before it's active, with a reason. Cancelling releases the reserved tokens back to the lot, terminates the allocation and voids any unpaid invoice.

An active agreement can't be cancelled from the workspace. It follows the cancellation terms written into the quote. Open a dispute or contact operations.

## Disputes

The buyer or the supplier can open a dispute on an agreement that's active, completed or expired. Pick a category and describe the problem in at least 20 characters:

| Category | Use it for |
| --- | --- |
| `under_delivery` | Capacity or limits not delivered as agreed |
| `metering` | Usage counts you think are wrong |
| `availability` | The route wasn't reachable when it should have been |
| `billing` | Invoices and payments |
| `other` | Anything else |

The agreement moves to `disputed` and both sides and operations are notified. Operations move the dispute to `investigating`, then `resolved` or `rejected` with a written resolution. When it closes, the agreement returns to `active` if the allocation is still live, or to `completed`.
