Billing
BillingService reads what an organization is billed: its invoices, the statement for the period now accruing, its payment standing, its monthly budget, and its outstanding balance. Invoices are generated automatically when a period ends. There is no call to create, edit or delete one.
Base path: transcodely.v1.BillingService
Who can call it
Every call on this service settles a whole organization, so none of them accept an API key. An API key belongs to one app, and an invoice covers every app.
| Caller | Result |
|---|---|
API key (ak_…) | Refused with permission_denied: “billing is scoped to an organization and is not available to API keys; sign in to the dashboard as an owner”. |
Dashboard session of an organization owner, with the X-Organization-ID header | Allowed. |
| Dashboard session of an admin or member | Refused with permission_denied. |
Dashboard session without X-Organization-ID | Refused with invalid_argument. |
In practice the dashboard’s Billing page makes these calls. They are documented here so you can read the same numbers from a script running with an owner’s session. For a cap an API key can set, see Spend Limits: AppService.UpdateSpendLimit and AppService.GetSpend are per app and accept API keys.
The SDKs expose the service as billing. Construct the client with the session token and the organization:
import { Transcodely } from "@transcodely/sdk";
const client = new Transcodely({ apiKey: process.env.TRANSCODELY_SESSION_TOKEN!, organizationId: "org_f6g7h8i9j0" });client = Transcodely(session_token, organization_id="org_f6g7h8i9j0")client, err := transcodely.New(sessionToken, transcodely.WithOrganization("org_f6g7h8i9j0"))Amounts on invoices and balances are integer cents of currency (always EUR today), sent as JSON strings because they are 64-bit integers: "1250" is €12.50. Budget amounts are euros as numbers.
The Invoice object
| Attribute | Type | Description |
|---|---|---|
id | string | Unique identifier, prefixed inv_. Empty on the upcoming invoice, which is computed and not stored. |
object | string | Always invoice. |
org_id | string | The organization billed. |
status | string | One of: draft, open, paid, void, uncollectible. Only the upcoming invoice is draft. |
period_start | string | Start of the billing period (inclusive), ISO 8601. |
period_end | string | End of the billing period (exclusive). A job that settles at or after it belongs to the next period. |
currency | string | ISO 4217 code. Always EUR today. |
subtotal_cents | string | Sum of the itemized lines, excluding the rounding adjustment. |
total_cents | string | Amount charged: every line including the rounding adjustment. |
provider_invoice_number | string | The payment provider’s invoice number, once matched. Omitted until then; its absence never means unpaid. |
finalized_at | string | When the statement was finalized. null on the upcoming invoice. |
paid_at | string | When payment was received. null unless paid. |
line_items | array | The breakdown, in display order. Empty in list results. |
created_at | string | When the statement row was created. |
The InvoiceLineItem object
| Attribute | Type | Description |
|---|---|---|
id | string | Prefixed li_. Empty on the upcoming invoice. Not stable until the invoice is finalized. |
line_type | string | One of: usage, fee, min_charge, adjustment, hosting. |
description | string | Human-readable, for example Encoding — h264 1080p standard. |
quantity | number | Units covered, for example 12 outputs. Omitted for lines that are not metered, such as the adjustment. |
unit | string | What quantity counts, for example output or minute. |
amount_cents | string | Amount for the line. Signed: the adjustment is often negative. |
dimensions | object | The grouping key behind the line, for example {"app_id": "app_k1l2m3n4o5", "codec": "h264"}. Keys vary by line_type. |
List invoices
Lists finalized invoices, newest period first, without line items.
POST /transcodely.v1.BillingService/ListInvoicesParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
pagination | object | No | limit (default 20, at most 100) and cursor, the next_cursor of the previous page. |
Returns
invoices, and pagination with next_cursor (empty on the last page) and total_count.
curl -X POST https://api.transcodely.com/transcodely.v1.BillingService/ListInvoices
-H "Authorization: Bearer your_session_token"
-H "X-Organization-ID: org_your_org_id"
-H "Content-Type: application/json"
-d '{"pagination": {"limit": 20}}'for await (const invoice of client.billing.listInvoices({ pagination: { limit: 20 } }).autoPage()) {
console.log(invoice.id, invoice.totalCents);
}for invoice in client.billing.list_invoices(limit=20).auto_paging_iter():
print(invoice.id, invoice.total_cents)iter := client.Billing.ListInvoices(ctx, nil)
for iter.Next() {
invoice := iter.Current()
fmt.Println(invoice.GetId(), invoice.GetTotalCents())
}{
"invoices": [
{
"id": "inv_a1b2c3d4e5f6",
"object": "invoice",
"org_id": "org_f6g7h8i9j0",
"status": "paid",
"period_start": "2026-11-01T00:00:00Z",
"period_end": "2026-12-01T00:00:00Z",
"currency": "EUR",
"subtotal_cents": "1252",
"total_cents": "1250",
"provider_invoice_number": "TR-0042",
"finalized_at": "2026-12-01T00:20:00Z",
"paid_at": "2026-12-01T09:02:11Z",
"line_items": [],
"created_at": "2026-12-01T00:20:00Z"
}
],
"pagination": { "next_cursor": "", "total_count": "1" }
}Retrieve an invoice
POST /transcodely.v1.BillingService/GetInvoiceParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The invoice (inv_ prefix). An invoice of another organization is reported as not_found. |
Returns
The invoice in invoice, with its line items.
curl -X POST https://api.transcodely.com/transcodely.v1.BillingService/GetInvoice
-H "Authorization: Bearer your_session_token"
-H "X-Organization-ID: org_your_org_id"
-H "Content-Type: application/json"
-d '{"id": "inv_a1b2c3d4e5f6"}'const invoice = await client.billing.retrieve("inv_a1b2c3d4e5f6");invoice = client.billing.retrieve("inv_a1b2c3d4e5f6")invoice, err := client.Billing.GetInvoice(ctx, "inv_a1b2c3d4e5f6"){
"invoice": {
"id": "inv_a1b2c3d4e5f6",
"object": "invoice",
"org_id": "org_f6g7h8i9j0",
"status": "open",
"period_start": "2026-11-01T00:00:00Z",
"period_end": "2026-12-01T00:00:00Z",
"currency": "EUR",
"subtotal_cents": "1252",
"total_cents": "1250",
"finalized_at": "2026-12-01T00:20:00Z",
"paid_at": null,
"line_items": [
{
"id": "li_a1b2c3d4e5f6g7",
"line_type": "usage",
"description": "Encoding — h264 1080p standard",
"quantity": 12,
"unit": "output",
"amount_cents": "1252",
"dimensions": { "app_id": "app_k1l2m3n4o5", "codec": "h264", "resolution": "1080p", "quality_tier": "standard" }
},
{
"id": "li_h8i9j0k1l2m3n4",
"line_type": "adjustment",
"description": "Rounding adjustment",
"unit": "",
"amount_cents": "-2",
"dimensions": {}
}
],
"created_at": "2026-12-01T00:20:00Z"
}
}Retrieve the upcoming invoice
The statement for the period now accruing, computed live from jobs that have settled. It has no id, its status is draft, and it changes as jobs finish; jobs still running are not included. It becomes a real invoice, with the same totals, shortly after the period ends.
POST /transcodely.v1.BillingService/GetUpcomingInvoiceParameters
None.
Returns
The statement in invoice. Totals are "0" when nothing has settled this period.
curl -X POST https://api.transcodely.com/transcodely.v1.BillingService/GetUpcomingInvoice
-H "Authorization: Bearer your_session_token"
-H "X-Organization-ID: org_your_org_id"
-H "Content-Type: application/json"
-d '{}'const upcoming = await client.billing.retrieveUpcoming();upcoming = client.billing.retrieve_upcoming()upcoming, err := client.Billing.GetUpcomingInvoice(ctx){
"invoice": {
"id": "",
"object": "invoice",
"org_id": "org_f6g7h8i9j0",
"status": "draft",
"period_start": "2026-12-01T00:00:00Z",
"period_end": "2027-01-01T00:00:00Z",
"currency": "EUR",
"subtotal_cents": "310",
"total_cents": "310",
"finalized_at": null,
"paid_at": null,
"line_items": [
{
"id": "",
"line_type": "usage",
"description": "Encoding — h264 720p standard",
"quantity": 4,
"unit": "output",
"amount_cents": "310",
"dimensions": { "app_id": "app_k1l2m3n4o5", "codec": "h264", "resolution": "720p", "quality_tier": "standard" }
}
],
"created_at": null
}
}Retrieve the billing profile
Whether a payment method is on file, the card details the payment provider exposes for display, and the organization’s billing standing. Payment methods are read live from the provider. Never creates anything at the provider.
POST /transcodely.v1.BillingService/GetBillingProfileParameters
None.
Returns
The profile in profile:
| Attribute | Type | Description |
|---|---|---|
object | string | Always billing_profile. |
org_id | string | The organization. |
payment_method_state | string | One of: none, on_file. The only reliable signal that a method is on file. |
payment_methods | array | For display: id, type (card or generic), and when the provider exposes them brand, last4, exp_month, exp_year; plus is_default. Card details are often absent for a working card. |
billing_email | string | The organization’s billing email. Omitted when unset. |
standing | string | One of: free, active, grace, delinquent. |
grace_until | string | When the grace window closes. Present only when standing is grace. |
standing_reason | string | Why, as a token to switch on: empty, exempt, no_payment_method, billing_setup_incomplete, card_expired, card_removed, invoice_past_due or repeated_invoice_failure. New tokens may be added. |
payment_method_required | boolean | false when the organization is exempt from holding a payment method. It is still invoiced. |
checkout_available | boolean | Whether Create a billing portal session can start a hosted checkout for an organization that has no subscription yet, the step that saves its first card. When false, that call answers billing_setup_unavailable for such an organization, so show that payment setup is not open yet instead of a button that fails. The same for every organization; an organization that already has a subscription always gets a portal session. |
curl -X POST https://api.transcodely.com/transcodely.v1.BillingService/GetBillingProfile
-H "Authorization: Bearer your_session_token"
-H "X-Organization-ID: org_your_org_id"
-H "Content-Type: application/json"
-d '{}'const profile = await client.billing.retrieveProfile();profile = client.billing.retrieve_profile()profile, err := client.Billing.GetBillingProfile(ctx){
"profile": {
"object": "billing_profile",
"org_id": "org_f6g7h8i9j0",
"payment_method_state": "on_file",
"payment_methods": [
{
"id": "3f2c1a7e-5b4d-4e8a-9c1f-2d7b6a5e4c3b",
"type": "card",
"brand": "visa",
"last4": "4242",
"exp_month": 8,
"exp_year": 2028,
"is_default": true
}
],
"billing_email": "billing@example.com",
"standing": "active",
"standing_reason": "",
"payment_method_required": true,
"checkout_available": false
}
}Create a billing portal session
Starts adding or managing a payment method. Card details never reach the Transcodely API: the response sends the customer to the payment provider. It carries exactly one of:
session: the provider’s billing portal (url,expires_at, andsession_tokenfor an embedded card form, empty when the provider has none). Returned once billing setup is complete.checkout: a hosted checkout (url,expires_at) that saves a payment method and completes billing setup in one step. Nothing is charged at checkout.
Both are single-use and short-lived: request a new one rather than storing it. Safe to call repeatedly.
An organization with no subscription yet can only get a checkout, and only while the billing profile’s checkout_available is true. When it is false, this call answers billing_setup_unavailable for such an organization and nothing is created: say that payment setup is not open yet rather than offering a button that fails.
POST /transcodely.v1.BillingService/CreateBillingPortalSessionParameters
None. Where the portal returns to is fixed by the API.
curl -X POST https://api.transcodely.com/transcodely.v1.BillingService/CreateBillingPortalSession
-H "Authorization: Bearer your_session_token"
-H "X-Organization-ID: org_your_org_id"
-H "Content-Type: application/json"
-d '{}'const { session, checkout } = await client.billing.createBillingSession();
const destination = session?.url ?? checkout?.url;result = client.billing.create_billing_session()result, err := client.Billing.CreateBillingSession(ctx){
"session": null,
"checkout": {
"object": "billing_checkout_session",
"url": "https://checkout.example.com/c/abc123",
"expires_at": "2026-12-04T11:00:00Z"
}
}Retrieve the budget
The organization’s monthly budget and the spend it is measured against. A budget only sends emails, at 50%, 80% and 100%; it never stops anything. See Budgets.
POST /transcodely.v1.BillingService/GetBudgetParameters
None.
Returns
The budget in budget, always present:
| Attribute | Type | Description |
|---|---|---|
object | string | Always budget. |
org_id | string | The organization. |
amount_eur | number | The monthly budget in euros. Omitted when no budget is set. |
spent_eur | number | Spend this billing period across every app, transcoding and hosting, from the same ledger as the upcoming invoice. |
used_percent | number | spent_eur as a percentage of amount_eur, not capped at 100. Omitted when no budget is set. |
period_start | string | Start of the current period (inclusive). |
period_end | string | End of the current period (exclusive). Spend resets here. |
alert_steps | array | Percentages that send an email: 50, 80 and 100 today. |
notified_steps | array | Steps already emailed this period against the current budget. A step listed here does not send again. Changing the budget empties the list and re-arms the steps against the new amount: a step the spend is already above at the moment of the change is skipped silently, and a step crossed after the change sends, even if it was sent under the old amount. |
currency | string | Always EUR today. |
curl -X POST https://api.transcodely.com/transcodely.v1.BillingService/GetBudget
-H "Authorization: Bearer your_session_token"
-H "X-Organization-ID: org_your_org_id"
-H "Content-Type: application/json"
-d '{}'const budget = await client.billing.retrieveBudget();budget = client.billing.retrieve_budget()budget, err := client.Billing.GetBudget(ctx){
"budget": {
"object": "budget",
"org_id": "org_f6g7h8i9j0",
"amount_eur": 200,
"spent_eur": 112.4,
"used_percent": 56.2,
"period_start": "2026-12-01T00:00:00Z",
"period_end": "2027-01-01T00:00:00Z",
"alert_steps": [50, 80, 100],
"notified_steps": [50],
"currency": "EUR"
}
}Update the budget
Sets or clears the monthly budget. Changing the amount never re-sends a step already emailed this period.
POST /transcodely.v1.BillingService/UpdateBudgetParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
amount_eur | number | No | The budget in euros, greater than 0 and at most 9999999999.99. Omit it to clear the budget and stop the emails. |
Returns
The budget in budget, with spend recomputed.
curl -X POST https://api.transcodely.com/transcodely.v1.BillingService/UpdateBudget
-H "Authorization: Bearer your_session_token"
-H "X-Organization-ID: org_your_org_id"
-H "Content-Type: application/json"
-d '{"amount_eur": 200}'await client.billing.setBudget(200);
await client.billing.clearBudget();client.billing.set_budget(200)
client.billing.clear_budget()budget, err := client.Billing.SetBudget(ctx, 200)
budget, err = client.Billing.ClearBudget(ctx)Retrieve the outstanding balance
Usage accrued and not yet billed, across every app, and the threshold it is measured against. Reminder emails go out from 80% of the threshold; only at hard_stop_cents, twice the threshold, are new jobs refused with outstanding_balance_exceeded. Paying lifts that on the next request. See Outstanding Balance.
POST /transcodely.v1.BillingService/GetOutstandingBalanceParameters
None.
Returns
The balance in balance, always present:
| Attribute | Type | Description |
|---|---|---|
object | string | Always outstanding_balance. |
org_id | string | The organization. |
outstanding_cents | string | The unsettled amount, in cents. |
tier | string | One of: new, established, proven. From the number of paid statements. |
settled_payments | string | How many statements the organization has paid. |
threshold_cents | string | The threshold. Omitted when none applies. |
threshold_source | string | One of: override, trust_tier, org_plan, platform_default, unbounded. |
hard_stop_cents | string | Where new jobs stop: twice the threshold. Omitted with threshold_cents. |
blocked | boolean | Whether new jobs are refused right now for this reason. |
used_percent | number | outstanding_cents as a percentage of the threshold. Omitted when none applies. |
alert_steps | array | Reminder percentages: 80, 100, 125, 150, 175 and 200 today. |
notified_steps | array | Steps already emailed in the current accrual window. |
currency | string | Always EUR today. |
settlement_available | boolean | Whether settling now is switched on. Do not offer “pay now” when it is false. |
curl -X POST https://api.transcodely.com/transcodely.v1.BillingService/GetOutstandingBalance
-H "Authorization: Bearer your_session_token"
-H "X-Organization-ID: org_your_org_id"
-H "Content-Type: application/json"
-d '{}'const balance = await client.billing.retrieveOutstandingBalance();balance = client.billing.retrieve_outstanding_balance()balance, err := client.Billing.GetOutstandingBalance(ctx){
"balance": {
"object": "outstanding_balance",
"org_id": "org_f6g7h8i9j0",
"outstanding_cents": "4120",
"tier": "new",
"settled_payments": "0",
"threshold_cents": "5000",
"threshold_source": "trust_tier",
"hard_stop_cents": "10000",
"blocked": false,
"used_percent": 82.4,
"alert_steps": [80, 100, 125, 150, 175, 200],
"notified_steps": [80],
"currency": "EUR",
"settlement_available": false
}
}Settle the outstanding balance
Pays the outstanding balance now: closes the current period at this instant into a real invoice for everything owed, which the payment provider then charges. The request has no amount; the figure is whatever is owed when it runs.
POST /transcodely.v1.BillingService/SettleOutstandingBalanceParameters
None.
Returns
settlement (invoice_id of the new invoice, amount_cents, period_start, period_end, currency) and balance, the outstanding balance as it now stands.
Refused with failed_precondition and error code settlement_unavailable when settling is switched off (see settlement_available), or nothing_outstanding when nothing is owed.
curl -X POST https://api.transcodely.com/transcodely.v1.BillingService/SettleOutstandingBalance
-H "Authorization: Bearer your_session_token"
-H "X-Organization-ID: org_your_org_id"
-H "Content-Type: application/json"
-d '{}'const { settlement, balance } = await client.billing.settleOutstandingBalance();result = client.billing.settle_outstanding_balance()result, err := client.Billing.SettleOutstandingBalance(ctx)Errors
| Connect code | Error code | Cause |
|---|---|---|
permission_denied | An API key, or a dashboard session that is not an owner of the organization. | |
invalid_argument | No X-Organization-ID header, or a malformed id. | |
not_found | invoice_not_found | The invoice does not exist or belongs to another organization. |
failed_precondition | settlement_unavailable | Settling now is switched off. |
failed_precondition | nothing_outstanding | There is nothing to settle. |
failed_precondition | billing_email_required | A billing portal session needs a billing email on the organization first. |
unavailable | billing_provider_unavailable | The payment provider did not answer. Try again. |
unavailable | billing_setup_unavailable | Billing setup could not be completed right now. Nothing was changed or charged. |