Needs keys Buys credits by charging the saved payment method, then records a purchase transaction and an invoice. Real charges need Stripe (STRIPE_SECRET_KEY). Without it, the mock provider approves every charge. Admin only.
Request#
| Field | Type | Required | Description |
|---|---|---|---|
amount |
number | Yes | AUD to add, 5 to 10000. |
Example request#
curl -X POST https://api.tried.com.au/billing/add-credits \
-H "Authorization: Bearer $TRIED_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"amount": 50
}'const res = await fetch("https://api.tried.com.au/billing/add-credits", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.TRIED_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"amount": 50
}),
});
const billing = await res.json();import os, requests
res = requests.post(
"https://api.tried.com.au/billing/add-credits",
headers={"Authorization": f"Bearer {os.environ['TRIED_API_KEY']}"},
json={
"amount": 50,
},
)
billing = res.json()Response#
200 OK
{
"currency": "AUD",
"credit_balance": 41.8725,
"total_credits": 59.995,
"total_usage": 18.1225,
"transactions": [
{
"transaction_id": "ctx_6b8d0f2a4c6e8a0b2d4f6a8c",
"amount": -0.005,
"kind": "usage",
"description": "Contact memory: call_4e6a8c0b2d4f6a8c0e2b4d6f",
"created_timestamp": 1760745600000
},
{
"transaction_id": "ctx_2c4e6a8b0d2f4a6c8e0b2d4f",
"amount": 50,
"kind": "purchase",
"description": "Credit purchase ($50.00)",
"created_timestamp": 1760313600000
},
{
"transaction_id": "ctx_9a1c3e5b7d9f1a3c5e7b9d1f",
"amount": 10,
"kind": "grant",
"description": "Free trial credit",
"created_timestamp": 1758240000000
}
]
}Returns the updated billing summary. Fields are as in Get billing. The purchase invoice appears in List invoices.
Errors#
| Status | When |
|---|---|
400 |
Validation failed, for example amount: Number must be greater than or equal to 5. |
401 |
Missing or invalid API key. |
402 |
The charge failed. With Stripe and no saved card the message is no_valid_payment: no saved card. Other failures carry Stripe's message or Payment <status>. |
403 |
The key's IP allowlist or scopes reject the request. This route needs the admin scope. A dashboard user without the right role gets Requires role: admin. API keys act as admin. |
429 |
Rate limit exceeded. See Rate limits. |
See Errors for the body format.
With Stripe, the charge is an off-session PaymentIntent against the card saved by Set default payment method. To pay on a hosted page instead, use Create checkout.