# Check what a promo code gives the organization

> POST /v1/billing/promo-codes/preview. .

Source: https://legion.ambient.xyz/docs/api/billing/preview-promo-code

`POST https://api.legion.ambient.xyz/v1/billing/promo-codes/preview`

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

. Says what `code` would give the caller's organization, in plain words (`summary`), without
redeeming it. Codes are case-insensitive. `eligible` is false, with `ineligible_reason`, when the
organization does not qualify (for example a code for new organizations only, or a top-up bonus whose
top-up is too small: pass `top_up_amount_minor` to check the bonus of a top-up of that amount). Nothing
about the code's budget, its redemptions or other codes is ever shown.

A code that does not exist is 404 `promo_code_not_found`; one that has ended, has not started, is used
up, or that the organization already redeemed as often as it may is 409 with the code that says so;
`promotions_paused` while promotions are switched off, `promo_budget_reached` once this UTC month's promotion
cost has reached the monthly promotion budget. Unknown, ended and used up codes count as failed
attempts: 10 failed attempts an hour per organization and per person is 429 `rate_limited` with
`Retry-After`. Requires `billing.read`.

## Request body

- `code`, string, required
- `top_up_amount_minor`, integer (int64)

Example:

```json
{
  "code": "string",
  "top_up_amount_minor": 1000
}
```

## Responses

### 200

What the code gives.

- `code`, string, required: The code as Legion stores it (upper-case).
- `kind`, PromoKind, required: . `free_credit`: an amount of promo credit. `top_up_bonus`: extra promo credit on one top-up (a percentage or a fixed amount, capped). `usage_discount`: a percentage off compute usage for some days, capped.
- `summary`, string, required: What the code gives, in one plain sentence.
- `value`, Money, required: The most the code gives (the credit, the bonus cap or the bonus for the amount, the discount cap).
- `credit_expires_at`, string (date-time): When the credit would expire if redeemed now.
- `discount`, PromoDiscountTerms
  - `bps`, integer, required
  - `days`, integer, required
  - `cap`, 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.
  - `until`, string (date-time): When the discount ends; once granted.
- `bonus`, PromoBonusTerms
  - `bps`, integer
  - `fixed`, Money
    - `amount_minor`, integer (int64), required: Amount in minor units (cents for USD).
    - `currency`, MoneyCurrency, required: ISO 4217 currency code. Only USD is supported.
  - `cap`, 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.
  - `min_top_up`, 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.
  - `bonus_for_amount`, Money: The bonus a top-up of `top_up_amount_minor` gets.
- `eligible`, boolean, required
- `ineligible_reason`, PromoIneligibleReason

Example:

```json
{
  "code": "string",
  "kind": "free_credit",
  "summary": "string",
  "value": {
    "amount_minor": 250,
    "currency": "USD"
  },
  "credit_expires_at": "2026-10-15T12:00:00Z",
  "discount": {
    "bps": 1,
    "days": 0,
    "cap": {
      "amount_minor": 250,
      "currency": "USD"
    },
    "until": "2026-10-15T12:00:00Z"
  },
  "bonus": {
    "bps": 1,
    "fixed": {
      "amount_minor": 250,
      "currency": "USD"
    },
    "cap": {
      "amount_minor": 250,
      "currency": "USD"
    },
    "min_top_up": {
      "amount_minor": 250,
      "currency": "USD"
    },
    "bonus_for_amount": {
      "amount_minor": 250,
      "currency": "USD"
    }
  },
  "eligible": false,
  "ineligible_reason": "new_orgs_only"
}
```

### 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.

### 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 billing service failed or did not answer within 3 seconds
(`billing_unavailable`). Nothing changed; retry with backoff.

## Errors

- 403 [`no_organization`](https://legion.ambient.xyz/docs/errors#no_organization)
- 404 [`promo_code_not_found`](https://legion.ambient.xyz/docs/errors#promo_code_not_found)
- 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 [`promotions_paused`](https://legion.ambient.xyz/docs/errors#promotions_paused)
- 409 [`promo_budget_reached`](https://legion.ambient.xyz/docs/errors#promo_budget_reached)
- 429 [`rate_limited`](https://legion.ambient.xyz/docs/errors#rate_limited)
- 503 [`billing_unavailable`](https://legion.ambient.xyz/docs/errors#billing_unavailable)
- 503 [`payments_unavailable`](https://legion.ambient.xyz/docs/errors#payments_unavailable)

## Example request

```sh
curl -s -X POST "https://api.legion.ambient.xyz/v1/billing/promo-codes/preview" \
  -H "Authorization: Bearer $LEGION_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "code": "string",
  "top_up_amount_minor": 1000
}'
```
