Billing
API reference for billing endpoints.
Auto-generated
make generate-docs to refresh after spec changes.GET /api/v1/billing/audit-log
/api/v1/billing/audit-logGet billing audit log
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| limit | integer | Optional | limitDefault: 20 |
| offset | integer | Optional | offsetDefault: 0 |
Request Example
curl -X GET https://api.alterlab.io/api/v1/billing/audit-log \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json"Response Example
{
"entries": [],
"total": 0,
"has_more": true
}GET /api/v1/billing/auto-recharge
/api/v1/billing/auto-rechargeGet auto-recharge settings
Request Example
curl -X GET https://api.alterlab.io/api/v1/billing/auto-recharge \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json"Response Example
{
"id": "example",
"user_id": "example",
"enabled": true,
"threshold_microcents": 0,
"threshold_display": "example",
"recharge_amount_cents": 0
}PUT /api/v1/billing/auto-recharge
/api/v1/billing/auto-rechargeUpdate auto-recharge settings
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| enabled | boolean | Optional | Enable auto-rechargeDefault: False |
| threshold_microcents | integer | Optional | Recharge when balance drops below this (microcents). 1,000,000 = $1.00Default: 5000000 |
| recharge_amount_cents | integer | Optional | Amount to charge in cents ($25-$2000)Default: 5000 |
| stripe_payment_method_id | string | Optional | stripe_payment_method_id |
| consent_text | string | Optional | consent_text |
| consent_source | "deposit_flow" | "success_page" | "settings" | Optional | consent_source |
| terms_version | string | Optional | terms_version |
Request Example
curl -X PUT https://api.alterlab.io/api/v1/billing/auto-recharge \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"enabled": false,
"threshold_microcents": 5000000,
"recharge_amount_cents": 5000
}'Response Example
{
"id": "example",
"user_id": "example",
"enabled": true,
"threshold_microcents": 0,
"threshold_display": "example",
"recharge_amount_cents": 0
}DELETE /api/v1/billing/auto-recharge
/api/v1/billing/auto-rechargeDisable auto-recharge
Request Example
curl -X DELETE https://api.alterlab.io/api/v1/billing/auto-recharge \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json"Response Example
{
"status": "ok"
}GET /api/v1/billing/auto-recharge/history
/api/v1/billing/auto-recharge/historyGet auto-recharge history
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| page | integer | Optional | Page numberDefault: 1 |
| per_page | integer | Optional | Results per pageDefault: 20 |
Request Example
curl -X GET https://api.alterlab.io/api/v1/billing/auto-recharge/history \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json"Response Example
{
"status": "ok"
}POST /api/v1/billing/auto-recharge/test
/api/v1/billing/auto-recharge/testTest auto-recharge
Request Example
curl -X POST https://api.alterlab.io/api/v1/billing/auto-recharge/test \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json"Response Example
{
"success": true,
"payment_method_valid": true,
"card_expired": true,
"card_days_until_expiry": "example",
"message": "example",
"card_brand": "example"
}GET /api/v1/billing/balance
/api/v1/billing/balanceGet current balance
Request Example
curl -X GET https://api.alterlab.io/api/v1/billing/balance \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json"Response Example
{
"balance_microcents": 0,
"balance_display": "example",
"total_deposited_cents": 0,
"total_spent_cents": 0,
"tier": "example",
"auto_recharge": "example"
}POST /api/v1/billing/change-plan
/api/v1/billing/change-planChange Plan
Request Example
curl -X POST https://api.alterlab.io/api/v1/billing/change-plan \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json"Response Example
{
"status": "ok"
}POST /api/v1/billing/checkout
/api/v1/billing/checkoutRetired. Always returns 410 Gone with detail.code CHECKOUT_RETIRED; fund your balance with POST /api/v1/billing/deposit.
Request Example
curl -X POST https://api.alterlab.io/api/v1/billing/checkout \
-H "X-API-Key: YOUR_API_KEY"Response Example
{
"detail": {
"code": "CHECKOUT_RETIRED",
"message": "POST /billing/checkout is retired. Use POST /billing/deposit."
}
}GET /api/v1/billing/cost-projection
/api/v1/billing/cost-projectionGet cost projection
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| X-Organization-Id | string | Optional | X-Organization-Id |
Request Example
curl -X GET https://api.alterlab.io/api/v1/billing/cost-projection \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json"Response Example
{
"usage_trend": "example",
"credits_used": 0,
"credits_allocated": 0
}GET /api/v1/billing/credit-transactions
/api/v1/billing/credit-transactionsGet credit transactions
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| limit | integer | Optional | limitDefault: 20 |
| offset | integer | Optional | offsetDefault: 0 |
| reference_type | string | Optional | Filter by reference_type (e.g. 'crawl') |
| X-Organization-Id | string | Optional | X-Organization-Id |
Request Example
curl -X GET https://api.alterlab.io/api/v1/billing/credit-transactions \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json"Response Example
{
"transactions": [],
"total": 0,
"has_more": true
}POST /api/v1/billing/deposit
/api/v1/billing/depositCreate a deposit
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| amount_cents | integer | Required | Amount to deposit in cents ($10-$2000) |
| success_url | string | Optional | success_url |
| cancel_url | string | Optional | cancel_url |
| promo_code | string | Optional | promo_code |
| auto_recharge_enabled | boolean | Optional | If true, enable auto-recharge after successful depositDefault: False |
| auto_recharge_threshold_microcents | integer | Optional | auto_recharge_threshold_microcents |
| auto_recharge_amount_cents | integer | Optional | auto_recharge_amount_cents |
Request Example
curl -X POST https://api.alterlab.io/api/v1/billing/deposit \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"amount_cents": 0,
"auto_recharge_enabled": false
}'Response Example
{
"session_id": "example",
"url": "example",
"amount_cents": 0,
"amount_display": "example"
}GET /api/v1/billing/invoices
/api/v1/billing/invoicesGet invoice history
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| limit | integer | Optional | limitDefault: 10 |
| X-Organization-Id | string | Optional | X-Organization-Id |
Request Example
curl -X GET https://api.alterlab.io/api/v1/billing/invoices \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json"Response Example
{
"status": "ok"
}GET /api/v1/billing/payment-methods
/api/v1/billing/payment-methodsList payment methods
Request Example
curl -X GET https://api.alterlab.io/api/v1/billing/payment-methods \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json"Response Example
{
"payment_methods": [],
"default_method_id": "example"
}POST /api/v1/billing/payment-methods
/api/v1/billing/payment-methodsAdd a payment method
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| payment_method_id | string | Required | Payment Method Id |
Request Example
curl -X POST https://api.alterlab.io/api/v1/billing/payment-methods \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"payment_method_id": "example_payment_method_id"
}'Response Example
{
"id": "example",
"stripe_payment_method_id": "example",
"type": "example",
"card_brand": "example",
"card_last4": "example",
"card_exp_month": "example"
}DELETE /api/v1/billing/payment-methods/{payment_method_id}
/api/v1/billing/payment-methods/{payment_method_id}Remove a payment method
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| payment_method_id | string | Required | payment_method_id |
Request Example
curl -X DELETE https://api.alterlab.io/api/v1/billing/payment-methods/<payment_method_id> \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json"Response Example
{
"status": "ok"
}POST /api/v1/billing/payment-methods/{payment_method_id}/default
/api/v1/billing/payment-methods/{payment_method_id}/defaultSet default payment method
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| payment_method_id | string | Required | payment_method_id |
Request Example
curl -X POST https://api.alterlab.io/api/v1/billing/payment-methods/<payment_method_id>/default \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json"Response Example
{
"status": "ok"
}POST /api/v1/billing/portal
/api/v1/billing/portalCreate a Stripe portal session
Request Example
curl -X POST https://api.alterlab.io/api/v1/billing/portal \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json"Response Example
{
"url": "example"
}POST /api/v1/billing/promo/validate
/api/v1/billing/promo/validateValidate Promo Code
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| code | string | Required | Code |
Request Example
curl -X POST https://api.alterlab.io/api/v1/billing/promo/validate \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"code": "example_code"
}'Response Example
{
"valid": true,
"bonus_type": "example",
"bonus_value": "example",
"max_credits_microcents": "example",
"max_credits_display": "example",
"min_deposit_cents": "example"
}GET /api/v1/billing/recent-activity
/api/v1/billing/recent-activityGet recent billing activity
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| limit | integer | Optional | limitDefault: 10 |
| offset | integer | Optional | offsetDefault: 0 |
Request Example
curl -X GET https://api.alterlab.io/api/v1/billing/recent-activity \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json"Response Example
{
"activities": [],
"total": 0,
"has_more": true
}POST /api/v1/billing/setup-intent
/api/v1/billing/setup-intentCreate a setup intent
Request Example
curl -X POST https://api.alterlab.io/api/v1/billing/setup-intent \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json"Response Example
{
"client_secret": "example",
"id": "example"
}GET /api/v1/billing/subscription
/api/v1/billing/subscriptionGet Subscription
Request Example
curl -X GET https://api.alterlab.io/api/v1/billing/subscription \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json"Response Example
{
"status": "ok"
}GET /api/v1/billing/usage-alerts
/api/v1/billing/usage-alertsGet usage alert settings
Request Example
curl -X GET https://api.alterlab.io/api/v1/billing/usage-alerts \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json"Response Example
{
"enabled": true,
"threshold_50_enabled": true,
"threshold_75_enabled": true,
"threshold_90_enabled": true,
"threshold_100_enabled": true,
"email_enabled": true
}PUT /api/v1/billing/usage-alerts
/api/v1/billing/usage-alertsUpdate usage alert settings
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| enabled | boolean | Optional | EnabledDefault: True |
| threshold_50_enabled | boolean | Optional | Threshold 50 EnabledDefault: False |
| threshold_75_enabled | boolean | Optional | Threshold 75 EnabledDefault: True |
| threshold_90_enabled | boolean | Optional | Threshold 90 EnabledDefault: True |
| threshold_100_enabled | boolean | Optional | Threshold 100 EnabledDefault: True |
| email_enabled | boolean | Optional | Email EnabledDefault: True |
| webhook_url | string | Optional | webhook_url |
Request Example
curl -X PUT https://api.alterlab.io/api/v1/billing/usage-alerts \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"enabled": false,
"threshold_50_enabled": false,
"threshold_75_enabled": false,
"threshold_90_enabled": false,
"threshold_100_enabled": false
}'Response Example
{
"enabled": true,
"threshold_50_enabled": true,
"threshold_75_enabled": true,
"threshold_90_enabled": true,
"threshold_100_enabled": true,
"email_enabled": true
}GET /api/v1/billing/usage-breakdown
/api/v1/billing/usage-breakdownGet usage breakdown
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| X-Organization-Id | string | Optional | X-Organization-Id |
Request Example
curl -X GET https://api.alterlab.io/api/v1/billing/usage-breakdown \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json"Response Example
{
"light": "example",
"js": "example",
"pdf": "example",
"ocr": "example",
"crawl": "example",
"total_credits": 0
}GET /api/v1/billing/usage-chart
/api/v1/billing/usage-chartGet usage chart data
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| days | integer | Optional | daysDefault: 30 |
| X-Organization-Id | string | Optional | X-Organization-Id |
Request Example
curl -X GET https://api.alterlab.io/api/v1/billing/usage-chart \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json"Response Example
{
"data": [],
"period": "example"
}GET /api/v1/billing/usage-realtime
/api/v1/billing/usage-realtimeGet real-time usage
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| X-Organization-Id | string | Optional | X-Organization-Id |
Request Example
curl -X GET https://api.alterlab.io/api/v1/billing/usage-realtime \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json"Response Example
{
"credits_used_today": 0,
"credits_used_week": 0,
"credits_used_month": 0,
"requests_today": 0,
"requests_week": 0,
"requests_month": 0,
"balance_microcents": 0,
"account_tier": "free",
"entitlement_source": "balance",
"credits_remaining": 0,
"credits_allocated": 0,
"overage_projected": 0,
"cost_projected": 0,
"next_billing_date": null,
"plan_name": "free",
"avg_daily_usage": 0
}POST /api/v1/billing/verify/confirm
/api/v1/billing/verify/confirmVerify Code
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| challenge_id | string | Required | Challenge Id |
| code | string | Required | Code |
Request Example
curl -X POST https://api.alterlab.io/api/v1/billing/verify/confirm \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"challenge_id": "example_challenge_id",
"code": "example_code"
}'Response Example
{
"success": true,
"message": "example",
"remaining_attempts": 0
}POST /api/v1/billing/verify/initiate
/api/v1/billing/verify/initiateInitiate Verification
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| action | string | Required | Action |
| method | string | Optional | MethodDefault: email |
Request Example
curl -X POST https://api.alterlab.io/api/v1/billing/verify/initiate \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"action": "example_action",
"method": "example_method"
}'Response Example
{
"challenge_id": "example",
"method": "example",
"action": "example",
"expires_at": "example",
"masked_destination": "example"
}GET /api/v1/billing/b2b/summary
/api/v1/billing/b2b/summaryGet B2B billing summary
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| period_start | string | Optional | Period start (inclusive, UTC). Defaults to first day of current calendar month. |
| period_end | string | Optional | Period end (inclusive, UTC). Defaults to last moment of current calendar month. |
| X-Organization-Id | string | Optional | X-Organization-Id |
Request Example
curl -X GET https://api.alterlab.io/api/v1/billing/b2b/summary \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json"Response Example
{
"period_start": "example",
"period_end": "example",
"total_requests": 0,
"successful_requests": 0,
"failed_requests": 0,
"total_cost_microcents": 0
}GET /api/v1/billing/deposit-bonus
/api/v1/billing/deposit-bonusBonus granted for a deposit
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| reference_id | string | Required | reference_id |
| X-Organization-Id | string | Optional | X-Organization-Id |
Request Example
curl -X GET 'https://api.alterlab.io/api/v1/billing/deposit-bonus?reference_id=<reference_id>' \
-H "Authorization: Bearer YOUR_SESSION_TOKEN" \
-H "Content-Type: application/json"Response Example
{
"bonus_cents": 0,
"kind": "example"
}GET /api/v1/billing/deposit-quote
/api/v1/billing/deposit-quoteQuote the credits a deposit would earn
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| cents | integer | Required | Deposit amount in cents |
| X-Organization-Id | string | Optional | X-Organization-Id |
Request Example
curl -X GET 'https://api.alterlab.io/api/v1/billing/deposit-quote?cents=<cents>' \
-H "Authorization: Bearer YOUR_SESSION_TOKEN" \
-H "Content-Type: application/json"Response Example
{
"deposit_cents": 0,
"bonus_cents": 0,
"bonus_source": "example",
"credits_cents": 0,
"tier_after": "example"
}GET /api/v1/billing/deposits
/api/v1/billing/depositsGet deposit history
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| limit | integer | Optional | limitDefault: 50 |
| offset | integer | Optional | offsetDefault: 0 |
| X-Organization-Id | string | Optional | X-Organization-Id |
Request Example
curl -X GET https://api.alterlab.io/api/v1/billing/deposits \
-H "Authorization: Bearer YOUR_SESSION_TOKEN" \
-H "Content-Type: application/json"Response Example
{
"deposits": [],
"total": 0,
"has_more": true
}GET /api/v1/billing/invoice/{invoice_id}
/api/v1/billing/invoice/{invoice_id}Download invoice PDF (first-party, no login required)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| invoice_id | string | Required | invoice_id |
| uid | string | Required | uid |
| exp | integer | Required | exp |
| token | string | Required | token |
Request Example
curl -X GET 'https://api.alterlab.io/api/v1/billing/invoice/<invoice_id>?uid=<uid>&exp=<exp>&token=<token>' \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json"Response Example
{
"status": "ok"
}GET /api/v1/billing/key-limits
/api/v1/billing/key-limitsGet the calling key's budget
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| X-Organization-Id | string | Optional | X-Organization-Id |
Request Example
curl -X GET https://api.alterlab.io/api/v1/billing/key-limits \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json"Response Example
{
"principal": "example",
"limit_microcents": "example",
"used_microcents": 0,
"remaining_microcents": "example",
"limit_usd": "example",
"used_usd": 0
}GET /api/v1/billing/low-balance-threshold
/api/v1/billing/low-balance-thresholdGet credits.low webhook threshold
Request Example
curl -X GET https://api.alterlab.io/api/v1/billing/low-balance-threshold \
-H "Authorization: Bearer YOUR_SESSION_TOKEN" \
-H "Content-Type: application/json"Response Example
{
"threshold_microcents": 0,
"threshold_dollars": 0,
"is_default": true
}PUT /api/v1/billing/low-balance-threshold
/api/v1/billing/low-balance-thresholdUpdate credits.low webhook threshold
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| threshold_microcents | integer | Optional | threshold_microcents |
Request Example
curl -X PUT https://api.alterlab.io/api/v1/billing/low-balance-threshold \
-H "Authorization: Bearer YOUR_SESSION_TOKEN" \
-H "Content-Type: application/json"Response Example
{
"threshold_microcents": 0,
"threshold_dollars": 0,
"is_default": true
}POST /api/v1/billing/quick-deposit
/api/v1/billing/quick-depositOne-click deposit with saved payment method
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| amount_cents | integer | Required | Amount to deposit in cents ($10–$2000) |
| payment_method_id | string | Required | Internal payment_methods.id UUID — ownership verified server-side |
Request Example
curl -X POST https://api.alterlab.io/api/v1/billing/quick-deposit \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"amount_cents": 0,
"payment_method_id": "example_payment_method_id"
}'Response Example
{
"status": "example",
"amount_cents": 0,
"amount_display": "example",
"balance_display": "example",
"client_secret": "example",
"payment_intent_id": "example"
}GET /api/v1/billing/receipts/{receipt_id}
/api/v1/billing/receipts/{receipt_id}Resolve and redirect to a receipt (resolve-on-click)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| receipt_id | string | Required | receipt_id |
| X-Organization-Id | string | Optional | X-Organization-Id |
Request Example
curl -X GET https://api.alterlab.io/api/v1/billing/receipts/<receipt_id> \
-H "Authorization: Bearer YOUR_SESSION_TOKEN" \
-H "Content-Type: application/json"Response Example
{
"status": "ok"
}POST /api/v1/billing/topup-link/open
/api/v1/billing/topup-link/openRecord that a signed top-up link from an insufficient-balance error was opened
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| token | string | Required | Token |
Request Example
curl -X POST https://api.alterlab.io/api/v1/billing/topup-link/open \
-H "Authorization: Bearer YOUR_SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"token": "example_token"
}'Response Example
{
"opened": true
}