# Get credit refund quote

> GET /v1/billing/credit-refund-quote. .

Source: https://legion.ambient.xyz/docs/api/billing/get-credit-refund-quote

`GET https://api.legion.ambient.xyz/v1/billing/credit-refund-quote`

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

. What a refund of the organization's unused credit would return now. `refundable` is the most
you can get back: the paid part of the balance (promo credit is never refunded), at most what your
top-ups of the last 180 days can still return, newest top-ups first. Stripe keeps its processing fee
when it refunds a payment, so each top-up's share of that fee is kept from the refund (`fee`, rounded up
to the cent); `payout` is what goes back to your cards and bank accounts. Without `amount_minor` the quote
is for everything refundable; more than `refundable` is 409 `exceeds_refundable`. `rentals_running` is
true while the organization has a rental that is starting or running (or waiting to come back): a
refund is refused until they are stopped, so the balance does not move under it.

Show the quote, then confirm it with `createCreditRefund`, passing its `fee` as `expected_fee`. A test
organization (`getMe`'s `org.test_org`) cannot get money back: 409 `test_org_no_refunds`. Requires `billing.topup` (owners), like `createTopUp`. Payments failing or not answering within 3
seconds is 503 `payments_unavailable`.

## Query parameters

- `amount_minor`, integer (int64): USD cents to refund. Absent quotes everything refundable.

## Responses

### 200

The quote.

- `refundable`, Money, required: The most that can be refunded now.
- `amount`, Money, required: What would leave the balance.
- `fee`, Money, required: The Stripe processing fee kept. Pass it as `expected_fee` to confirm.
- `payout`, Money, required: What would go back to your cards and bank accounts.
- `parts`, array of CreditRefundPart, required
  - `top_up_id`, string, required: The top-up refunded, the `id` of `listTopUps`.
  - `amount`, Money, required: What leaves the balance for this top-up, its fee included.
  - `fee`, Money, required: The part of this top-up's Stripe fee that is kept.
- `rentals_running`, boolean, required: True while a rental is starting or running (or waiting to come back); the refund is refused until they stop.

Example:

```json
{
  "refundable": {
    "amount_minor": 250,
    "currency": "USD"
  },
  "amount": {
    "amount_minor": 250,
    "currency": "USD"
  },
  "fee": {
    "amount_minor": 250,
    "currency": "USD"
  },
  "payout": {
    "amount_minor": 250,
    "currency": "USD"
  },
  "parts": [
    {
      "top_up_id": "string",
      "amount": {
        "amount_minor": 250,
        "currency": "USD"
      },
      "fee": {
        "amount_minor": 250,
        "currency": "USD"
      }
    }
  ],
  "rentals_running": false
}
```

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

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

### 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)
- 409 [`test_org_no_refunds`](https://legion.ambient.xyz/docs/errors#test_org_no_refunds)
- 409 [`exceeds_refundable`](https://legion.ambient.xyz/docs/errors#exceeds_refundable)
- 503 [`payments_unavailable`](https://legion.ambient.xyz/docs/errors#payments_unavailable)

## Example request

```sh
curl -s "https://api.legion.ambient.xyz/v1/billing/credit-refund-quote" \
  -H "Authorization: Bearer $LEGION_API_KEY"
```
