Skip to content
Billing

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.

CallerResult
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 headerAllowed.
Dashboard session of an admin or memberRefused with permission_denied.
Dashboard session without X-Organization-IDRefused 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

AttributeTypeDescription
idstringUnique identifier, prefixed inv_. Empty on the upcoming invoice, which is computed and not stored.
objectstringAlways invoice.
org_idstringThe organization billed.
statusstringOne of: draft, open, paid, void, uncollectible. Only the upcoming invoice is draft.
period_startstringStart of the billing period (inclusive), ISO 8601.
period_endstringEnd of the billing period (exclusive). A job that settles at or after it belongs to the next period.
currencystringISO 4217 code. Always EUR today.
subtotal_centsstringSum of the itemized lines, excluding the rounding adjustment.
total_centsstringAmount charged: every line including the rounding adjustment.
provider_invoice_numberstringThe payment provider’s invoice number, once matched. Omitted until then; its absence never means unpaid.
finalized_atstringWhen the statement was finalized. null on the upcoming invoice.
paid_atstringWhen payment was received. null unless paid.
line_itemsarrayThe breakdown, in display order. Empty in list results.
created_atstringWhen the statement row was created.

The InvoiceLineItem object

AttributeTypeDescription
idstringPrefixed li_. Empty on the upcoming invoice. Not stable until the invoice is finalized.
line_typestringOne of: usage, fee, min_charge, adjustment, hosting.
descriptionstringHuman-readable, for example Encoding — h264 1080p standard.
quantitynumberUnits covered, for example 12 outputs. Omitted for lines that are not metered, such as the adjustment.
unitstringWhat quantity counts, for example output or minute.
amount_centsstringAmount for the line. Signed: the adjustment is often negative.
dimensionsobjectThe 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/ListInvoices

Parameters

ParameterTypeRequiredDescription
paginationobjectNolimit (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/GetInvoice

Parameters

ParameterTypeRequiredDescription
idstringYesThe 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/GetUpcomingInvoice

Parameters

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/GetBillingProfile

Parameters

None.

Returns

The profile in profile:

AttributeTypeDescription
objectstringAlways billing_profile.
org_idstringThe organization.
payment_method_statestringOne of: none, on_file. The only reliable signal that a method is on file.
payment_methodsarrayFor 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_emailstringThe organization’s billing email. Omitted when unset.
standingstringOne of: free, active, grace, delinquent.
grace_untilstringWhen the grace window closes. Present only when standing is grace.
standing_reasonstringWhy, 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_requiredbooleanfalse when the organization is exempt from holding a payment method. It is still invoiced.
checkout_availablebooleanWhether 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, and session_token for 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/CreateBillingPortalSession

Parameters

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/GetBudget

Parameters

None.

Returns

The budget in budget, always present:

AttributeTypeDescription
objectstringAlways budget.
org_idstringThe organization.
amount_eurnumberThe monthly budget in euros. Omitted when no budget is set.
spent_eurnumberSpend this billing period across every app, transcoding and hosting, from the same ledger as the upcoming invoice.
used_percentnumberspent_eur as a percentage of amount_eur, not capped at 100. Omitted when no budget is set.
period_startstringStart of the current period (inclusive).
period_endstringEnd of the current period (exclusive). Spend resets here.
alert_stepsarrayPercentages that send an email: 50, 80 and 100 today.
notified_stepsarraySteps 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.
currencystringAlways 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/UpdateBudget

Parameters

ParameterTypeRequiredDescription
amount_eurnumberNoThe 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/GetOutstandingBalance

Parameters

None.

Returns

The balance in balance, always present:

AttributeTypeDescription
objectstringAlways outstanding_balance.
org_idstringThe organization.
outstanding_centsstringThe unsettled amount, in cents.
tierstringOne of: new, established, proven. From the number of paid statements.
settled_paymentsstringHow many statements the organization has paid.
threshold_centsstringThe threshold. Omitted when none applies.
threshold_sourcestringOne of: override, trust_tier, org_plan, platform_default, unbounded.
hard_stop_centsstringWhere new jobs stop: twice the threshold. Omitted with threshold_cents.
blockedbooleanWhether new jobs are refused right now for this reason.
used_percentnumberoutstanding_cents as a percentage of the threshold. Omitted when none applies.
alert_stepsarrayReminder percentages: 80, 100, 125, 150, 175 and 200 today.
notified_stepsarraySteps already emailed in the current accrual window.
currencystringAlways EUR today.
settlement_availablebooleanWhether 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/SettleOutstandingBalance

Parameters

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 codeError codeCause
permission_deniedAn API key, or a dashboard session that is not an owner of the organization.
invalid_argumentNo X-Organization-ID header, or a malformed id.
not_foundinvoice_not_foundThe invoice does not exist or belongs to another organization.
failed_preconditionsettlement_unavailableSettling now is switched off.
failed_preconditionnothing_outstandingThere is nothing to settle.
failed_preconditionbilling_email_requiredA billing portal session needs a billing email on the organization first.
unavailablebilling_provider_unavailableThe payment provider did not answer. Try again.
unavailablebilling_setup_unavailableBilling setup could not be completed right now. Nothing was changed or charged.

Run this against your own file

A free account runs standard-quality encodes up to 2 minutes, one at a time (a longer upload is shortened to its first 2 minutes), so the Quickstart runs with nothing set up but an API key.