> ## Documentation Index
> Fetch the complete documentation index at: https://weights.fyi/run/llms.txt

# POST /v1/credit/topups

```text
POST https://weights.fyi/run/v1/credit/topups
Authorization: Bearer <token>                    scope: manage
Content-Type: application/json
{"usd": "<amount>"}
```

**Available since:** 2026-10-08, when the service went live on weights.fyi/run, wherever card payments are switched on.

**Answer time:** synchronous for the payment page, once Stripe has made it, usually within a second; the credit arrives when the payment is confirmed, 2 s after it in the first live run on 2026-10-08.

Opens a payment page for an amount of credit. The call needs two things: the `manage` scope, and a key issued by the workspace's owner (or the owner's own panel session); an admin's or member's `manage` key answers `403 workspace_role_required`. Whoever pays opens `checkout_url` and pays on Stripe's hosted page; Stripe's signed confirmation adds the amount to your balance as one "Credit added" row, and the browser returns to your panel. No card number reaches this service. Add prepaid credit by card under [Billing & usage](/run/app/credit): you pay on Stripe's hosted payment page and come straight back. No card data reaches this service. Payments on this service run in Stripe's test mode for now, so that page takes Stripe's test cards, not a real card. Credit is prepaid, in US dollars, in whole cents (`"25"`, `"25.00"` and `25` are the same; `"25.001"` is refused), from $0.50, Stripe's minimum, with no maximum of our own. The panel's Balance card does the same with a form.

Until paid, the top-up is under `pending_topups` in [GET /v1/usage](/run/docs/reference/usage.md), `awaiting_payment`, and not in your balance; then it moves to `credits` and jobs waiting for credit carry on. An unpaid page expires on Stripe's side and is dropped, charging nothing. A browser paying without a session of this service returns to the log-in page and misses the panel's notice; the credit lands anyway. The call takes no `Idempotency-Key`: a retry makes a second page; pay one and let the other expire.

## Request

| Name | Where | Required | Meaning |
|---|---|---|---|
| `Authorization` | header | yes | `Bearer` and a token that holds the `manage` scope and was issued by the workspace's owner. |
| `Content-Type` | header | yes | `application/json`. |
| `usd` | body | yes | The amount of credit in US dollars, as a string such as `"25.00"` or as a number, in whole cents and at least the minimum above. |

## Return value

**201 Created** with the payment page.

| Field | Meaning |
|---|---|
| `topup_id` | The payment's identifier: Stripe's id for the payment page. The same id appears in `pending_topups` until the payment is confirmed. |
| `checkout_url` | The address of Stripe's hosted payment page, an `https` address. Open it in a browser to pay. |
| `usd` | The amount the page asks for, in dollars with two decimals, such as `"25.00"`. |

## Errors

| Status | Code | When it happens | What to do |
|---|---|---|---|
| `400` | `invalid_body`, `invalid_json` | The body is not an object with `usd`. | Send `{"usd": "25.00"}`. |
| `400` | `invalid_amount` | The amount is not a number above zero, or not whole cents; `minimum_usd` gives the minimum. | Send dollars and cents. |
| `400` | `below_minimum` | The amount is below the minimum, given in `minimum_usd`. | Send at least that much. |
| `401` | `unauthorized`, `invalid_token`, `token_revoked`, `token_expired` | No token, or one that does not work (any more). | Use a valid token. |
| `403` | `scope_required` | The token lacks `manage`. | Use a token with `manage`, or the panel. |
| `403` | `workspace_role_required` | The token's issuer is not the workspace's owner, or no person issued it. | Use a key the owner issued, or ask the owner to pay under [Billing & usage](/run/app/credit). |
| `403` | `csrf_required` | A panel session made the call without `X-CSRF-Token`. | Use the panel's form, or an API token. |
| `404` | `not_configured` | Card payments are not switched on for this service; `feature` says `stripe`. | Credit is granted by us while they are off. |
| `502` | `stripe_refused` | Stripe refused to make the page. | Try again later; nothing was charged. |
| `503` | `stripe_unavailable` | Stripe did not answer in time. | Try again later; a page Stripe made without answering expires unpaid. |

## Examples

The values in angle brackets are Stripe's and change with every call; they are not shown because these pages link nothing outside this service:

```sh
curl -s https://weights.fyi/run/v1/credit/topups \
  -H "Authorization: Bearer $WEIGHTS_API_KEY" -H "Content-Type: application/json" \
  -d '{"usd": "25.00"}'
```

```json
{
  "topup_id": "<Stripe's id for the payment page>",
  "checkout_url": "<the payment page's https address at Stripe>",
  "usd": "25.00"
}
```

## Patterns

### Topping up from a script

Print `checkout_url` for the person who pays, then poll [GET /v1/usage](/run/docs/reference/usage.md) every few seconds until the top-up has left `pending_topups` and `available_usd_micros` has grown; give any deadline room, since a person pays in between.

## History

- 2026-10-08: live; the first live payment reached the balance 2 s after it was made.
- 2026-11-16: the owner requirement, checked by the call all along, is documented.

## See also

[Prices and billing](/run/docs/prices.md#credit), [Start here](/run/docs/start.md).
