Documentation
Credit and usage
View .mdOpenAPI

Open a payment page for credit

POSThttps://weights.fyi/run/v1/credit/topupsscope: manage
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: 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, 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

NameWhereRequiredMeaning
AuthorizationheaderyesBearer and a token that holds the manage scope and was issued by the workspace's owner.
Content-Typeheaderyesapplication/json.
usdbodyyesThe 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.

FieldMeaning
topup_idThe payment's identifier: Stripe's id for the payment page. The same id appears in pending_topups until the payment is confirmed.
checkout_urlThe address of Stripe's hosted payment page, an https address. Open it in a browser to pay.
usdThe amount the page asks for, in dollars with two decimals, such as "25.00".

Errors

StatusCodeWhen it happensWhat to do
400invalid_body, invalid_jsonThe body is not an object with usd.Send {"usd": "25.00"}.
400invalid_amountThe amount is not a number above zero, or not whole cents; minimum_usd gives the minimum.Send dollars and cents.
400below_minimumThe amount is below the minimum, given in minimum_usd.Send at least that much.
401unauthorized, invalid_token, token_revoked, token_expiredNo token, or one that does not work (any more).Use a valid token.
403scope_requiredThe token lacks manage.Use a token with manage, or the panel.
403workspace_role_requiredThe 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.
403csrf_requiredA panel session made the call without X-CSRF-Token.Use the panel's form, or an API token.
404not_configuredCard payments are not switched on for this service; feature says stripe.Credit is granted by us while they are off.
502stripe_refusedStripe refused to make the page.Try again later; nothing was charged.
503stripe_unavailableStripe 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 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, Start here.