Documentation
Account and keys
View .mdOpenAPI

Create an API token

POSThttps://weights.fyi/run/v1/tokensscope: manage
text
POST https://weights.fyi/run/v1/tokens
Authorization: Bearer <token>                    scope: manage
Content-Type: application/json
{"name": "...", "scopes": [...], "expires_at": "...", "daily_cap_usd": "..."}
Available since
2026-10-08, when the service went live on weights.fyi/run. Implemented 2026-10-09: the cap holds training, and panel sessions expire.
Answer time
synchronous: the token is made and returned in the answer.

Makes an API token and returns it once: the service keeps only a digest and the visible prefix, so a lost answer means making another. The first token is made on your panel, /app; later ones there or with this call. A token can do what its scopes allow (Start here); without scopes it gets submit and read, and it can never get a scope the calling token lacks (403 scope_escalation), so a narrow token stays narrow.

New tokens are weights_, 43 random letters and digits, an underscore and a six-character checksum that lets a scanner recognise them; older weights_ tokens of 43 characters stay valid. The call takes no Idempotency-Key: after a lost answer, list GET /v1/tokens and revoke the token you never saw.

Request

NameWhereRequiredMeaning
AuthorizationheaderyesBearer and a token with manage; or a panel session sending its CSRF token in X-CSRF-Token, as the customer journey script does. A panel session ends 720 h after signing in or 10,080 minutes idle (merged 2026-10-09), then answers 401 unauthorized; tokens do not end with it.
Content-Typeheaderyesapplication/json, at most 65,536 bytes.
namebodynoA name of your choice, shown in lists. Without one the token is called token.
scopesbodynoA list of submit, read and manage, at least one of them, each held by the token making the call. The default is submit and read.
expires_atbodynoWhen the token stops working: ISO 8601 with a time zone, in the future, such as 2026-12-31T23:00:00Z. Leave it out for no expiry.
daily_cap_usdbodynoThe spend cap per UTC day in US dollars, a string or number above zero such as "25" or 12.5: new work that would pass it, counting today's charges and the waiting pages at their price, answers 402 token_daily_cap until 00:00 UTC; since the merge of 2026-10-09 it also holds open training (Prices and billing). Changeable later on the panel only.

Return value

201 Created with the new token.

FieldMeaning
idThe token's number in your account, used to revoke it.
tokenThe token itself. It is shown in this answer only.
prefixThe token's first characters, as lists will show it.
nameThe name it was given.
scopesIts scopes, in alphabetical order.
created_atWhen it was made.
expires_atWhen it stops working, or null.
daily_cap_usd_microsIts spend cap per UTC day in micro-dollars, or null.
issued_byThe person who issued it: the person behind the calling credential (the signed-in person, or the person who issued the calling token), or null when that credential names none.
noteA reminder that the token is shown once.

Errors

StatusCodeWhen it happensWhat to do
400invalid_body, invalid_jsonThe body is not a JSON object.Send an object, {} at the least.
400invalid_scopes, no_scopes, unknown_scopescopes is not a list of strings, is empty, or names a scope that does not exist.Name some of submit, read, manage.
400invalid_expiry, expiry_needs_time_zone, expiry_in_the_pastexpires_at cannot be read, has no time zone, or is not in the future.Send a future time with Z or an offset.
400invalid_amountdaily_cap_usd is not an amount above zero.Send dollars, such as "25".
400invalid_namename is not a string.Send text, or leave it out.
401unauthorized, invalid_token, token_revoked, token_expiredNo token, or one that does not work (any more).Use a valid token.
403scope_requiredThe calling token lacks manage.Use a token with manage, or the panel.
403scope_escalationThe new token would hold a scope the calling token does not; asked and granted list both.Ask for less, or make it from a token or panel session that holds the scope.
403csrf_requiredA panel session made the call without X-CSRF-Token.Send the panel's CSRF token, or use an API token.
413body_too_largeThe body is larger than limit_bytes.Send only the fields above.

Examples

A batch runner that may send work and read results, capped at $25 a day (made on a test service; its checksum replaced with x):

sh
curl -s https://weights.fyi/run/v1/tokens \
  -H "Authorization: Bearer $WEIGHTS_API_KEY" -H "Content-Type: application/json" \
  -d '{"name": "batch runner", "scopes": ["submit", "read"], "daily_cap_usd": "25"}'
json
{
  "id": 2,
  "token": "weights_tcYQQluQhy9HxNfOiqWDGmzXAT2a3ryMNT43Ic6TWr3_xxxxxx",
  "prefix": "weights_tcYQQluQ",
  "name": "batch runner",
  "scopes": ["read", "submit"],
  "created_at": "2026-10-09T08:28:09.778Z",
  "expires_at": null,
  "daily_cap_usd_micros": 25000000,
  "issued_by": 12,
  "note": "The token is shown once. Keep it somewhere safe."
}

Patterns

One token per program

Give each program or person a token of its own with only the scopes it needs and a cap that fits its day; when one leaks, revoke it with DELETE /v1/tokens/{token_id} and nothing else stops. Keep one manage token, ideally without submit, for making the others.

History

  • 2026-10-08: live with scopes, expiry, the daily cap and the rule that a token gives no more than it holds; checksummed tokens.
  • 2026-10-09 (merged): the cap holds open training; panel sessions expire.
  • 2026-11-16 (built, live with the deploy that carries it): issued_by in the answer.

See also

GET /v1/tokens, Errors and limits.