Billing API
Base path: https://gateway.useyona.com/b/v1
Get billing account
GET /b/v1/billing-accounts/me
Get your billing account details and credit balance.
Check balance
GET /b/v1/billing-accounts/:id/check-balance
Check if your balance can cover a given number of credits.
Path parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Billing account UUID |
Query parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
credits | number | Yes | Number of credits to check |
Create subscription
POST /b/v1/subscriptions
Subscribe to a plan. Uses planCode to identify the plan.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
planCode | string | Yes | Plan code, e.g. starter_monthly |
interval | string | Yes | Billing interval: monthly or yearly |
currency | string | No | Payment currency |
trialDays | number | No | Trial period in days |
| Status | Code | Trigger |
|---|---|---|
| 409 | RES002 | Active subscription already exists |
Get active subscription
GET /b/v1/subscriptions/active
Cancel subscription
PUT /b/v1/subscriptions/:id/cancel
| Status | Code | Trigger |
|---|---|---|
| 404 | RES001 | Subscription not found |
| 409 | RES003 | Subscription already cancelled |
Resume subscription
PUT /b/v1/subscriptions/:id/resume
Change plan
PUT /b/v1/subscriptions/:id/change-plan
Request body
| Field | Type | Required | Description |
|---|---|---|---|
newPlanCode | string | Yes | Target plan code |
Purchase credits
POST /b/v1/payments/purchase
Buy a credit package. Returns a checkout URL to redirect the user.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
packageId | string | Yes | Credit package ID |
currency | string | No | Payment currency |
paymentMethod | string | No | Payment method ID |
successUrl | string | No | Redirect URL after successful payment |
cancelUrl | string | No | Redirect URL if payment cancelled |
useSavedPaymentMethod | boolean | No | Use saved payment method |
customCreditAmount | number | No | Custom credit amount |
Subscription history
GET /b/v1/subscriptions/history
Payment history
GET /b/v1/payments/history
Credit transfer
POST /b/v1/payments/transfer
Transfer PAYG credits between parent and child organizations. Both must be in payg or hybrid billing mode.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
targetOrganizationId | string | Yes | Child organization UUID |
amount | number | Yes | Number of credits to transfer |
description | string | No | Transfer description |
| Status | Code | Trigger |
|---|---|---|
| 400 | BIZ001 | Insufficient credits for transfer |
List payment methods
GET /b/v1/payment-methods
Add payment method
POST /b/v1/payment-methods
Returns a setup URL to add a new payment method.
Remove payment method
DELETE /b/v1/payment-methods/:provider/:id
Set default payment method
PUT /b/v1/payment-methods/:provider/default
Credit transactions
GET /b/v1/transactions
List credit transaction history.
List plans (public)
GET /b/v1/plans/subscriptions
No authentication required.
List credit packages (public)
GET /b/v1/plans/packages
No authentication required.
List credit costs (public)
GET /b/v1/plans/credit-costs
No authentication required. Returns every billable action with its credit cost, label, and description. Sorted alphabetically by action for stable client-side diffing.
Usage analytics
GET /b/v1/transactions/analytics/usage
Consumption breakdown
GET /b/v1/transactions/breakdown/by-endpoint
Get account statistics
GET /b/v1/billing-accounts/:id/stats
Get aggregated statistics for a billing account.
Path parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Billing account UUID |
Get single transaction
GET /b/v1/transactions/:id
Retrieve a single credit transaction by ID.
Path parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Transaction UUID |
Subscribe and pay
POST /b/v1/subscriptions/subscribe
Create a subscription and initiate payment in one step. Returns a checkout URL or client secret for payment completion.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
planCode | string | Yes | Plan code, e.g. starter_monthly |
interval | string | Yes | Billing interval: monthly or yearly |
currency | string | No | Payment currency |
successUrl | string | Yes | Redirect URL after successful payment |
cancelUrl | string | Yes | Redirect URL if payment cancelled |
Renewal history
GET /b/v1/subscriptions/renewals
List subscription renewal history.
Query parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
page | number | No | Page number |
pageSize | number | No | Results per page |
Renewal statistics
GET /b/v1/subscriptions/renewals/stats
Get aggregated renewal statistics.