# Top up the organization's balance

> POST /v1/billing/top-ups. Starts a top-up of the prepaid balance through Stripe Checkout and returns the Checkout page to send the person to.

Source: https://legion.ambient.xyz/docs/api/billing/create-top-up

`POST https://api.legion.ambient.xyz/v1/billing/top-ups`

Authenticate with an API key: `Authorization: Bearer $LEGION_API_KEY`.

Starts a top-up of the prepaid balance through Stripe Checkout and
returns the Checkout page to send the person to. They pay by card,
US bank debit (ACH) or USDC, from $25 to $10,000, in USD (: less
than $25 is 400 `invalid_request`). `payment_method` offers only card
or only US bank debit. The balance
is credited the full amount once the payment succeeds: when Checkout
completes for card and USDC, and when the debit settles for ACH (up to
4 business days). Until then `getBillingAccount` does not show it. Stripe sends the person back to the web app's balance page.

Requires an `Idempotency-Key`: a repeat with the same key and amount
within 24 hours returns the same Checkout page, and the same key with
another amount or `payment_method` is 422 `idempotency_key_reused`. Requires
`billing.topup` (owners). At most 20 top-ups an hour per organization
(429 `rate_limited`). Payments failing or not answering within 3
seconds is 503 `payments_unavailable`; retry with the same key.

: `promo_code` names a top-up bonus code (any other kind is 409 `promo_code_wrong_kind`; the
refusals are `redeemPromoCode`'s, and a top-up under the code's minimum is 403
`promo_code_not_eligible` with `reason` `top_up_too_small`). The answer's `promo` says the bonus; it is
granted after the payment is credited and checked, and taken back in proportion if the top-up is
refunded. The same key with another promo code is 422 `idempotency_key_reused`.

A test organization (`getMe`'s `org.test_org`) cannot pay
with real money: while Stripe runs with live keys its top-up is 409
`test_org_live_payment` (ask a Legion Legion for test credit); with
Stripe's test keys it works as for any organization.

## Headers

- `Idempotency-Key`, string, required: Client-chosen key, unique per request intent, at most 255 characters.

## Request body

- `amount_minor`, integer (int64), required: USD cents, from $25 to $10,000 (it was $10 before).
- `currency`, MoneyCurrency, required: ISO 4217 currency code. Only USD is supported.
- `payment_method`, string: . Offer only this way to pay on the Checkout page: `card` or `us_bank_account` (a US bank debit, ACH). Absent offers every way: card, US bank debit and USDC. Part of the request for `Idempotency-Key`: the same key with another `payment_method` is 422 `idempotency_key_reused`.
- `promo_code`, string: : a top-up bonus code this top-up is to earn. The bonus is granted once the top-up is credited and Legion has checked the redemption; see `TopUpCheckout.promo`.

Example:

```json
{
  "amount_minor": 5000,
  "currency": "USD",
  "payment_method": "card",
  "promo_code": "string"
}
```

## Responses

### 201

The Checkout page.

- `checkout_url`, string (uri), required: Stripe Checkout's page for this top-up.
- `amount`, Money, required
  - `amount_minor`, integer (int64), required: Amount in minor units (cents for USD).
  - `currency`, MoneyCurrency, required: ISO 4217 currency code. Only USD is supported.
- `expires_at`, string (date-time), required: When the Checkout page stops accepting payment.
- `promo`, TopUpPromo: The promo code bonus a top-up is to earn.
  - `redemption_id`, string (uuid), required
  - `code`, string, required
  - `bonus`, Money, required: The bonus this top-up earns once it is credited and checked.
  - `status`, PromoRedemptionStatus, required: `pending` (Legion is checking it), `awaiting_payment` (a top-up bonus waiting for its top-up), `granted`, `held` (a person at Ambient looks at it), `refused`, `cancelled` (the top-up of a bonus did not complete), `revoked` (taken back after it was granted).

Example:

```json
{
  "checkout_url": "https://example.com",
  "amount": {
    "amount_minor": 250,
    "currency": "USD"
  },
  "expires_at": "2026-10-15T12:00:00Z",
  "promo": {
    "redemption_id": "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b",
    "code": "string",
    "bonus": {
      "amount_minor": 250,
      "currency": "USD"
    },
    "status": "pending"
  }
}
```

### 400

The request is malformed or fails validation. An image reference that
is not a container image reference answers `invalid_image_reference`.

### 401

Missing, unknown, expired or revoked credentials.

### 403

The caller lacks the permission this operation requires (`forbidden`),
or signed in without having joined an organization yet
(`no_organization`; `getOnboarding` and the invitation and
organization operations under it work), or could not sign in
(`email_unverified`, `account_conflict`, and `domain_not_allowed`). `not_invited` is no longer returned to
session tokens.

`access_not_approved`: a signed-in person who is not approved
for the beta yet. Every operation that takes a credential answers it to
them, except `getMe` and `joinMyWaitlist`; the problem carries
`access` (`waitlisted` or `not_requested`, and the email). Approved
means a member of an organization, holding a pending invitation, or Legion; an API key always belongs to a member.

`oauth_token_mcp_only`: the caller sent an OAuth access token (`lgo_`), which is accepted
only by `mcpMessage` and the tool calls it dispatches. Every other operation answers it, whatever
the token's scope. Use an API key or the Legion web app.

`org_suspended`: the caller's organization is suspended. Every operation that takes a
credential answers it, by session or API key, except `getMe` (which shows `org.suspended_at` and
`org.suspension_reason`) and the support operations under `/v1/support/`.

`terms_not_accepted`: an approved caller who has not accepted
the current version of the Terms of Use and the Acceptable Use Policy. Every operation that takes a credential answers it, except `getMe`,
`acceptLegalDocuments`, `joinMyWaitlist` and the wind-down operations
(`listRentals`, `stopRental`, `deleteRental`, `listHosts`,
`updateListing` with `listed` false, `removeHost`); the problem
carries `legal`. An API key acts for the person who created it, so it
is refused until that person accepts. Terminal
operations also return
`session_required` (called with an API key) and `step_up_required`
(neither a sign-in nor a step-up challenge within the step-up window).

### 404

The resource does not exist or belongs to another organization.

### 409

The resource's current state does not allow the operation. `legal_versions_stale`: a legal document version sent is not the current one; the
problem's `legal` holds the current documents.

### 422

The Idempotency-Key was already used with a different request body.

### 429

Rate limited (`code` is `rate_limited`), or the organization asked the
pull-through mirror to copy in too many different tags or digests of one
repository today (`mirror_quota_exceeded`). Retry after the `Retry-After`
seconds.

### 500

An unexpected server error. Safe to retry.

### 503

The payments service failed or did not answer within 3 seconds
(`payments_unavailable`). Nothing changed; retry with backoff.

## Errors

- 403 [`no_organization`](https://legion.ambient.xyz/docs/errors#no_organization)
- 403 [`promo_code_not_eligible`](https://legion.ambient.xyz/docs/errors#promo_code_not_eligible)
- 404 [`promo_code_not_found`](https://legion.ambient.xyz/docs/errors#promo_code_not_found)
- 409 [`test_org_live_payment`](https://legion.ambient.xyz/docs/errors#test_org_live_payment)
- 409 [`promo_code_expired`](https://legion.ambient.xyz/docs/errors#promo_code_expired)
- 409 [`promo_code_not_started`](https://legion.ambient.xyz/docs/errors#promo_code_not_started)
- 409 [`promo_code_used_up`](https://legion.ambient.xyz/docs/errors#promo_code_used_up)
- 409 [`promo_code_already_redeemed`](https://legion.ambient.xyz/docs/errors#promo_code_already_redeemed)
- 409 [`promo_code_wrong_kind`](https://legion.ambient.xyz/docs/errors#promo_code_wrong_kind)
- 409 [`promotions_paused`](https://legion.ambient.xyz/docs/errors#promotions_paused)
- 409 [`promo_budget_reached`](https://legion.ambient.xyz/docs/errors#promo_budget_reached)
- 422 [`idempotency_key_reused`](https://legion.ambient.xyz/docs/errors#idempotency_key_reused)
- 429 [`rate_limited`](https://legion.ambient.xyz/docs/errors#rate_limited)
- 503 [`payments_unavailable`](https://legion.ambient.xyz/docs/errors#payments_unavailable)
- 503 [`billing_unavailable`](https://legion.ambient.xyz/docs/errors#billing_unavailable)

## Example request

```sh
curl -s -X POST "https://api.legion.ambient.xyz/v1/billing/top-ups" \
  -H "Authorization: Bearer $LEGION_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
  "amount_minor": 5000,
  "currency": "USD",
  "payment_method": "card",
  "promo_code": "string"
}'
```
