# Pay from your balance

Top up once, then rent energy from your server without a transfer per order: one call, idempotent, debited from the balance.

With a balance there's no deposit address and no payment window per order: the price is debited from your FeeBolt balance in one ledger entry and delivery starts at once. Top up in the app (Balance › Deposit) in TRX or USDT.

1. Create a key with the `order` scope (and `read`, to check the balance).
2. For each payout, make an Idempotency-Key you can repeat (your payout id).
3. `POST /api/me/orders` with the address and plan. `201`: paid and being delivered.
4. Poll `GET /api/orders/{id}` until `stage` is `ready`, then send the USDT.

Order from the balance:

```bash
KEY="payout-$PAYOUT_ID"
curl -X POST https://feebolt.com/api/me/orders \
  -H "Authorization: Bearer $FEEBOLT_API_KEY" \
  -H "Idempotency-Key: $KEY" \
  -H "content-type: application/json" \
  -d '{"address":"TKHuVq1oKVruCGLvqVexFs6dawKv6fQgFs","packageId":"1tx"}'
```

JavaScript:

```js
const order = await fetch("https://feebolt.com/api/me/orders", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.FEEBOLT_API_KEY}`,
    "Idempotency-Key": `payout-${payout.id}`,
    "content-type": "application/json",
  },
  body: JSON.stringify({ address: payout.from, packageId: "1tx" }),
}).then((r) => r.json());

let o = order;
while (o.stage === "waiting" || o.stage === "seen") {
  await new Promise((r) => setTimeout(r, 3000));
  o = await fetch(`https://feebolt.com/api/orders/${order.id}`).then((r) => r.json());
}
if (o.stage !== "ready") throw new Error(o.failReason ?? o.stage);
```

## Idempotency

Network calls fail in the middle. Retry with the **same** Idempotency-Key and you get the same order back (`200`, header `Idempotent-Replayed: true`): it is never charged twice, even when two retries race. Use a **new** key for a new order. The same key with a different address, plan or currency is refused (`409 idempotency_conflict`) rather than guessed at. Keys are per account.

## Money

- The debit and the order are one ledger entry, `spend:<order id>`, unique for ever. The balance can't go below zero: a short balance answers `402 insufficient_balance` and charges nothing.
- If no provider delivers, the full amount goes back to the balance as a `refund` entry; a partly filled order refunds the unfilled share.
- Your [loyalty tier](https://feebolt.com/developers/get-balance/) discount applies, as in the app.
- Every order a key pays is in your account's security log with the key that paid it.

---

HTML: https://feebolt.com/developers/balance-orders/ · OpenAPI: https://feebolt.com/developers/openapi.json · All docs as one Markdown file: https://feebolt.com/developers/full.md
