API Reference
Profile
Update account settings — token balance, plan, and other profile fields — authenticated by your Reliant API Key. This is the endpoint the Stripe webhook calls when a token pack purchase is confirmed.
PATCH/api/profile
Updates one or more allowed fields on your profile. Only fields in the whitelist below are accepted — any other field in the body is silently ignored.
Authentication
Pass your Reliant API Key in the X-Reliant-Key header. The request is scoped to the account that owns that key.
http
PATCH /api/profile
X-Reliant-Key: rel_your_api_key
Content-Type: application/json
Allowed fields
| Field | Type | Description |
|---|---|---|
| plan | string | Sets the account plan directly. Accepted values: free, starter, enterprise. |
| tokens_balance | integer | Sets the token balance to an exact value. Use tokens_increment instead when adding to the current balance. |
| tokens_increment | integer | Adds the given amount to the current token balance. Accepts negative values to subtract. The result is floored at 0. |
Examples
Credit tokens after a purchase
The Stripe webhook calls this automatically when a token pack is confirmed. You can also call it manually:
json — body
{
"tokens_increment": 100000
}
Update plan and credit tokens in one call
json — body
{
"plan": "starter",
"tokens_increment": 50000
}
Reset token balance
json — body
{
"tokens_balance": 0
}
Response
Returns the updated profile fields on success.
json — 200 OK
{
"success": true,
"profile": {
"id": "usr_...",
"plan": "starter",
"tokens_balance": 150000
}
}
Token balance behavior
| Balance value | Effect on the assistant |
|---|---|
null | No token limit enforced. Default for all accounts that never purchased a token pack. |
> 0 | Each assistant request debits the actual Anthropic tokens consumed (input + output across all turns). |
0 | Requests are blocked with 402 Payment Required until more tokens are credited. |
Error responses
| Status | Error | Cause |
|---|---|---|
400 | No valid fields provided | Body contains no recognized field. |
400 | tokens must be a positive integer | tokens_increment is zero, non-integer, or missing. |
401 | Missing X-Reliant-Key header | Header not sent. |
401 | Invalid API key | No account found for the provided key. |