REST API reference
On this page
The public Tenth API: customers, entitlements, credits, grants, offerings, purchases and the event feed. Authenticate with a secret key from your server, or a publishable key plus a customer token from an app.
Generated from openapi.json, version 1.0.0. The REST API page covers authentication, idempotency, pagination, rate limits and versioning.
Base URL and authentication
Every path is relative to https://api.tenthbilling.com. Send your API key as a bearer token: Authorization: Bearer tenth_test_sk_.... With a publishable key, use me as the customer ID and name the customer with a header, as Customers in the path explains.
Customers and access
GET/v1/customers/me
The calling customer's entitlements, credit balances and subscriptions
Authenticate with a publishable key plus X-Customer-Token (or X-Anonymous-Id). The customer is created on first call.
GET/v1/customers/{id}
A customer by app_user_id (secret key)
PATCH/v1/customers/{id}
Update a customer's email or attributes
Attributes merge into the existing ones; set a key to null to remove it.
Parameters and responses
Path parameters
| Name | Type | Description |
|---|---|---|
id required | string | app_user_id, or me with a publishable key 1 to 255 characters. |
Request body
Every field is optional.
| Field | Type | Description |
|---|---|---|
email | string (email) or null | Up to 320 characters. |
attributes | map of string or number or boolean or null |
Response 200
Errors
400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.
DELETE/v1/customers/{id}
Privacy delete: remove personal data, keep financial records
Email, attributes and every app_user_id for this customer are removed. Purchases, revenue and credit history stay, without personal data, because tenants need them for accounting.
GET/v1/customers/{id}/entitlements
A customer's entitlements (the hot path)
Parameters and responses
Path parameters
| Name | Type | Description |
|---|---|---|
id required | string | app_user_id, or me with a publishable key 1 to 255 characters. |
Response 200
| Field | Type | Description |
|---|---|---|
entitlements | map of EntitlementState |
Errors
400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.
POST/v1/customers/{id}/alias
Make another app_user_id resolve to this customer (identify, or merge)
With a publishable key, alias must be the SDK's anonymous id ($tenth_anon_…): it's merged into the signed-in customer. The app's merge policy decides what happens when the id already belongs to another customer.
Parameters and responses
Path parameters
| Name | Type | Description |
|---|---|---|
id required | string | app_user_id, or me with a publishable key 1 to 255 characters. |
Request body
| Field | Type | Description |
|---|---|---|
alias required | string | 1 to 255 characters. |
merge_policy | one of transfer_purchases, keep_existing, reject |
Response 200
| Field | Type | Description |
|---|---|---|
outcome | one of added, already_aliased, merged, kept_existing | |
customer | CustomerState |
Errors
400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.
GET/v1/customers/{id}/export
Everything Tenth holds about one customer, as JSON, for an access request
Credits
GET/v1/customers/{id}/credits
Credit balances and recent transactions
Parameters and responses
Path parameters
| Name | Type | Description |
|---|---|---|
id required | string | 1 to 255 characters. |
Query parameters
| Name | Type | Description |
|---|---|---|
credit_type | string | Pattern ^[a-z0-9_]{1,64}$. |
before | string (uuid) | |
limit | integer | Default 25. 1 to 100. |
Response 200
| Field | Type | Description |
|---|---|---|
balances | map of CreditBalance | |
transactions | array of CreditTransaction |
Errors
400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.
POST/v1/customers/{id}/credits/{type}/debit
Spend credits
Secret key by default. A publishable key works only when the credit type allows app-side debits, and only for the signed-in customer. Anyone who modifies an app can skip an app-side debit, so use server-side debits when payment matters.
Parameters and responses
Path parameters
| Name | Type | Description |
|---|---|---|
id required | string | 1 to 255 characters. |
type required | string | Pattern ^[a-z0-9_]{1,64}$. |
Request body
| Field | Type | Description |
|---|---|---|
amount required | integer | More than 0. |
idempotency_key required | string | Same key → same result, never a second debit. Pattern ^[\x21-\x7e]{1,200}$. |
metadata | map of string or number or boolean or null | Default {}. |
Response 200
| Field | Type | Description |
|---|---|---|
credit_type | string | |
amount | integer | |
balance | integer | |
available | integer | |
replayed | boolean | True when this idempotency_key was used before; nothing new was debited. |
transactions | array of CreditTransaction |
Errors
400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.
POST/v1/customers/{id}/credits/{type}/reserve
Hold credits for long-running work; commit or release the hold later
Held credits can't be spent by other debits. A hold that isn't committed or released expires after ttl_seconds (default 900).
Parameters and responses
Path parameters
| Name | Type | Description |
|---|---|---|
id required | string | 1 to 255 characters. |
type required | string | Pattern ^[a-z0-9_]{1,64}$. |
Request body
| Field | Type | Description |
|---|---|---|
amount required | integer | More than 0. |
idempotency_key required | string | Same key → same result, never a second debit. Pattern ^[\x21-\x7e]{1,200}$. |
ttl_seconds | integer | Default 900. 10 to 86400. |
Response 201
Errors
400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.
POST/v1/customers/{id}/credits/{type}/holds/{holdId}/commit
Spend held credits. Commit less than the hold to release the rest.
Parameters and responses
Path parameters
| Name | Type | Description |
|---|---|---|
id required | string | 1 to 255 characters. |
type required | string | Pattern ^[a-z0-9_]{1,64}$. |
holdId required | string (uuid) |
Request body
Every field is optional.
| Field | Type | Description |
|---|---|---|
amount | integer | More than 0. |
Response 200
| Field | Type | Description |
|---|---|---|
credit_type | string | |
amount | integer | |
balance | integer | |
available | integer | |
replayed | boolean | True when this idempotency_key was used before; nothing new was debited. |
transactions | array of CreditTransaction |
Errors
400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.
POST/v1/customers/{id}/credits/{type}/holds/{holdId}/release
Release a hold without spending
Grants
POST/v1/customers/{id}/grants
Give an entitlement or credits without payment
Creates the customer if this app_user_id is new. Grants never create revenue.
Parameters and responses
Path parameters
| Name | Type | Description |
|---|---|---|
id required | string | 1 to 255 characters. |
Request body
| Field | Type | Description |
|---|---|---|
entitlement | string | Pattern ^[a-z0-9_]{1,64}$. |
credit_type | string | Pattern ^[a-z0-9_]{1,64}$. |
amount | integer | Credits to grant (credit grants only). More than 0. |
starts_at | string (date-time) | Entitlement grants can start later. Credits are granted now. |
expires_at | string (date-time) | Leave out for no expiry. |
reason required | string | 1 to 500 characters. |
Response 201
Errors
400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.
DELETE/v1/grants/{grantId}
Revoke a grant. Unspent granted credits are removed.
Offerings
GET/v1/offerings/current
The offering this user should see, for their platform
Targeted offerings whose rules all match win by priority; otherwise the default offering. offering is null when the app has none.
Parameters and responses
Query parameters
| Name | Type | Description |
|---|---|---|
platform required | one of ios, android, web | |
country | string | Store storefront country, ISO 3166-1 alpha-2. Pattern ^[A-Z]{2}$. |
app_version | string | Pattern ^\d+(\.\d+){0,3}$. |
paywall_schema | integer | The highest paywall config schema version the SDK renders. Without it, paywall is null. 1 to 1000. |
Response 200
Errors
400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.
GET/v1/offerings/{key}
An offering by key, for a platform
Parameters and responses
Path parameters
| Name | Type | Description |
|---|---|---|
key required | string | 1 to 64 characters. |
Query parameters
| Name | Type | Description |
|---|---|---|
platform required | one of ios, android, web | |
paywall_schema | integer | The highest paywall config schema version the SDK renders. Without it, paywall is null. 1 to 1000. |
Response 200
Errors
400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.
GET/v1/paywall-assets/{id}
A paywall image (no authentication)
The image bytes with their stored content type. Offerings return these URLs in paywall.assets.
Parameters and responses
Path parameters
| Name | Type | Description |
|---|---|---|
id required | string |
Response 200
See the description above.
Stripe
POST/v1/checkout-sessions
Start a hosted Stripe Checkout for a product
Send success_url and cancel_url (web), or return: "app" (native link-out): Checkout then returns through Tenth to the app's return_url_scheme as <scheme>://tenth/checkout-return?status=success|cancel.
Parameters and responses
Request body
| Field | Type | Description |
|---|---|---|
app_user_id | string | me with a publishable key and customer token; any app_user_id with a secret key. Default "me". 1 to 255 characters. |
product required | string | Pattern ^[a-z0-9_]{1,64}$. |
success_url | string | Up to 2048 characters. |
cancel_url | string | Up to 2048 characters. |
return | app | Return to the app through its return_url_scheme, instead of URLs. |
Response 200
| Field | Type | Description |
|---|---|---|
id | string | |
url | string |
Errors
400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.
POST/v1/payment-intents
Start an embedded Stripe payment for a product
elements (default, web): the Payment Element over a Checkout Session; tax, trials and billing anchors all apply. payment_sheet (native, where store rules allow): a PaymentIntent, or an unpaid subscription; Stripe Tax is not available on it.
Parameters and responses
Request body
| Field | Type | Description |
|---|---|---|
app_user_id | string | me with a publishable key and customer token; any app_user_id with a secret key. Default "me". 1 to 255 characters. |
product required | string | Pattern ^[a-z0-9_]{1,64}$. |
form | one of elements, payment_sheet | Default "elements". |
return_url | string | Where redirect-based payment methods return (elements). Up to 2048 characters. |
Response 200
| Field | Type | Description |
|---|---|---|
id | string | |
form | one of elements, payment_sheet | |
client_secret | string or null | |
publishable_key | string or null | |
stripe_account | string or null | Pass to Stripe.js for Connect accounts. |
Errors
400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.
GET/v1/customers/me/management-url
Where the signed-in customer manages a subscription
The App Store settings page, the Google Play subscription page, or a Stripe customer portal session.
Parameters and responses
POST/v1/subscriptions/{id}/change
Move a Stripe subscription to another product (upgrade, downgrade)
Parameters and responses
Path parameters
| Name | Type | Description |
|---|---|---|
id required | string (uuid) |
Request body
| Field | Type | Description |
|---|---|---|
product required | string | Pattern ^[a-z0-9_]{1,64}$. |
timing | one of immediately, period_end | Defaults to the new product's setting. |
proration | one of create_prorations, none, always_invoice |
Response 200
Errors
400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.
POST/v1/subscriptions/{id}/cancel
Cancel a Stripe subscription, at period end (default) or now
POST/v1/subscriptions/{id}/resume
Undo a scheduled cancellation, or resume a paused Stripe subscription
POST/v1/subscriptions/{id}/anchor
Move a Stripe subscription to a fixed billing day
Parameters and responses
Path parameters
| Name | Type | Description |
|---|---|---|
id required | string (uuid) |
Request body
| Field | Type | Description |
|---|---|---|
day required | integer | 1 to 31. |
month | integer | 1 to 12. |
timezone | string | Up to 64 characters. |
first_period required | one of prorate, free_until_anchor, full_then_anchor | |
minimum_first_period_days | integer | 0 to 31. |
Response 200
Errors
400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.
POST/v1/purchases/{id}/refund
Refund a Stripe one-time purchase, fully or in part
Parameters and responses
Store purchases
POST/v1/apple/offer-signatures
Sign an App Store promotional offer for the signed-in customer
Only offers configured on the app's product in Tenth can be signed (apple_promotional_offer_ids). Pass the result to StoreKit's promotional offer purchase option, with the customer's app_account_token.
Parameters and responses
Request body
| Field | Type | Description |
|---|---|---|
product_id required | string | The App Store product id 1 to 255 characters. |
offer_id required | string | 1 to 64 characters. |
Response 200
| Field | Type | Description |
|---|---|---|
key_identifier | string | |
nonce | string | |
timestamp | integer | |
signature | string | |
app_account_token | string |
Errors
400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.
POST/v1/receipts
Submit an App Store or Google Play purchase for verification
iOS: send StoreKit 2's signed transaction after a purchase, and finish the transaction only once this succeeds. Android: send Play Billing's purchase token, product id and type; Tenth acknowledges or consumes the purchase itself once it's recorded, so the app must not. With a secret key, name the customer in app_user_id. A purchase whose appAccountToken or obfuscatedAccountId belongs to another customer is refused; use restore for that.
Parameters and responses
Request body
One of 2 shapes:
platform is ios
| Field | Type | Description |
|---|---|---|
platform required | ios | |
signed_transaction required | string | Up to 32768 characters. |
app_user_id | string | 1 to 255 characters. |
platform is android
| Field | Type | Description |
|---|---|---|
purchase_token required | string | Pattern ^[A-Za-z0-9._-]{8,2048}$. |
product_id required | string | The Play product id (for subscriptions, the subscription id). Pattern ^[a-z0-9][a-z0-9._]{0,149}$. |
type required | one of subscription, one_time | |
platform required | android | |
app_user_id | string | 1 to 255 characters. |
Response 200
| Field | Type | Description |
|---|---|---|
provisional | boolean | Granted from the verified transaction while Apple was unreachable. |
customer | CustomerState |
Errors
400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.
POST/v1/receipts/restore
Restore App Store or Google Play purchases
iOS: send StoreKit 2's Transaction.currentEntitlements. Android: send what queryPurchasesAsync returned. A purchase that belongs to another customer of this app follows the app's restore transfer policy. Restores never create revenue.
Parameters and responses
Request body
One of 2 shapes:
platform is ios
| Field | Type | Description |
|---|---|---|
platform required | ios | |
signed_transactions required | array of string | Up to 100 items. |
platform is android
| Field | Type | Description |
|---|---|---|
platform required | android | |
purchases required | array of object | Up to 100 items. |
purchases[].purchase_token required | string | Pattern ^[A-Za-z0-9._-]{8,2048}$. |
purchases[].product_id required | string | The Play product id (for subscriptions, the subscription id). Pattern ^[a-z0-9][a-z0-9._]{0,149}$. |
purchases[].type required | one of subscription, one_time |
Response 200
| Field | Type | Description |
|---|---|---|
results | array of object | |
results[].transaction_id | string or null | The App Store transaction id, or the Play purchase token. |
results[].outcome | one of owned, transferred, shared, kept_with_original, invalid | |
customer | CustomerState |
Errors
400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.
Feeds
GET/v1/events
Events for this app and environment, oldest first
The same events webhooks deliver, for apps that prefer to poll. Pass the last id you processed as after.
Parameters and responses
Query parameters
| Name | Type | Description |
|---|---|---|
after | string (uuid) | |
limit | integer | Default 50. 1 to 100. |
type | string | Up to 64 characters. |
customer | string | Only events for this app_user_id. 1 to 255 characters. |
Response 200
| Field | Type | Description |
|---|---|---|
data | array of Event | |
has_more | boolean |
Errors
400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.
GET/v1/revenue/transactions
Revenue rows for this app and environment (the data behind the transactions export)
One row per money movement. Store fees are estimates from your commission settings; Stripe fees are actual.
Parameters and responses
Query parameters
| Name | Type | Description |
|---|---|---|
after | string (uuid) | |
limit | integer | Default 50. 1 to 100. |
from | string (date-time) | occurred_at at or after |
to | string (date-time) | occurred_at before |
Response 200
| Field | Type | Description |
|---|---|---|
data | array of RevenueTransaction | |
has_more | boolean |
Errors
400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.
Schemas
Problem
| Field | Type | Description |
|---|---|---|
type | string | |
title | string | |
status | number | |
code | string | |
detail optional | string | |
request_id optional | string | |
errors optional | any |
EntitlementState
| Field | Type | Description |
|---|---|---|
active | boolean | |
source | one of purchase, subscription, grant or null | |
store | one of stripe, apple, google or null | Where to manage it: App Store, Google Play or web (Stripe). |
expires_at | string or null | |
will_renew | boolean | |
in_grace | boolean | |
billing_issue | boolean | |
quantity | integer or null |
CreditBalance
| Field | Type | Description |
|---|---|---|
balance | integer | |
available | integer | Balance minus credits reserved by open holds. |
SubscriptionSummary
| Field | Type | Description |
|---|---|---|
id | string | |
product | string or null | |
store | one of stripe, apple, google | |
status | string | |
current_period_start | string or null | |
current_period_end | string or null | |
trial_end | string or null | |
grace_period_end | string or null | |
cancel_at | string or null | |
will_renew | boolean | |
provisional | boolean |
CustomerState
| Field | Type | Description |
|---|---|---|
customer | object | |
customer.id | string | |
customer.app_user_id | string | |
customer.app_account_token | string | Set this as appAccountToken on every StoreKit purchase, so Tenth can tell whose it is. |
customer.obfuscated_account_id | string | Set this as obfuscatedAccountId on every Play Billing purchase, so Tenth can tell whose it is. |
customer.created_at | string | |
entitlements | map of EntitlementState | |
credits | map of CreditBalance | |
subscriptions | array of SubscriptionSummary |
CreditTransaction
| Field | Type | Description |
|---|---|---|
id | string | |
credit_type | string | |
type | one of grant, debit, expire, clawback, adjustment, refill | |
amount | integer | |
lot_id | string or null | |
metadata | object | |
occurred_at | string (date-time) |
CreditHold
| Field | Type | Description |
|---|---|---|
id | string | |
credit_type | string | |
amount | integer | |
status | one of held, committed, released, expired | |
expires_at | string (date-time) | |
created_at | string (date-time) |
Grant
| Field | Type | Description |
|---|---|---|
id | string | |
customer_id | string | |
entitlement | string or null | |
credit_type | string or null | |
amount | integer or null | |
starts_at | string (date-time) | |
expires_at | string (date-time) or null | |
reason | string | |
created_by | string | |
revoked_at | string (date-time) or null | |
created_at | string (date-time) |
Event
| Field | Type | Description |
|---|---|---|
id | string | |
type | string | |
created_at | string (date-time) | |
payload | object |
RevenueTransaction
| Field | Type | Description |
|---|---|---|
id | string | |
customer_id | string | |
provider | one of stripe, apple, google | |
platform | one of ios, android, web | |
type | one of purchase, renewal, refund, refund_reversal, chargeback, chargeback_reversal | |
provider_transaction_id | string | |
original_transaction_id | string or null | |
refunded_transaction_id | string or null | |
subscription_id | string or null | |
purchase_id | string or null | |
product_id | string or null | |
occurred_at | string (date-time) | |
period_start | string (date-time) or null | |
period_end | string (date-time) or null | |
country | string or null | |
currency | string | |
gross_amount | integer | Minor units of currency. |
tax_amount | integer or null | |
fee_amount | integer | |
net_amount | integer | |
fee_is_estimated | boolean | |
amount_is_estimated | boolean | |
gross_amount_usd | integer or null | USD cents. Null until the day’s FX rate is known. |
fee_amount_usd | integer or null | |
net_amount_usd | integer or null | |
fx_rate | string or null | |
fx_rate_date | string or null | |
fx_source | one of identity, stripe_balance_transaction, daily_rate or null | |
is_trial_conversion | boolean |
DisplayPrice
| Field | Type | Description |
|---|---|---|
amount_minor | string | Minor units of currency, as an integer string. Pattern ^\d+$. |
currency | string | ISO 4217, uppercase. |
recurring | object or null | Null for one-time prices. |
recurring.interval | one of day, week, month, year | |
recurring.interval_count | integer | More than 0. |
trial_period_days | integer or null |
ServedPaywall
| Field | Type | Description |
|---|---|---|
id | string | |
version | integer | More than 0. |
config | object | A published paywall config (@tenthbilling/paywall/schema) whose schema_version is at most paywall_schema. Parse it with parseServedPaywall. |
assets | map of string | Image id → URL, on the API's own origin. |
CurrentOffering
| Field | Type | Description |
|---|---|---|
offering | object or null | |
offering.key | string | |
offering.purchase_path | one of store, web_link_out, in_app_stripe, none | |
offering.products | array of object | |
offering.products[].key | string | |
offering.products[].type | one of subscription, non_consumable, consumable | |
offering.products[].display_name | string or null | |
offering.products[].label | string or null | |
offering.products[].badge | string or null | |
offering.products[].is_highlighted | boolean | |
offering.products[].store_product_id | string | App Store product id, Google Play product id, or Stripe price id, for this platform and purchase path. |
offering.products[].google_base_plan_id | string or null | |
offering.products[].google_offer_id | string or null | |
offering.products[].price | DisplayPrice or null | Web (Stripe) products only: Stripe's current price. Null for store products (the device reads store prices) and when Stripe can't be reached; hide a web product without a price. |
offering.products[].entitlements | array of string | |
offering.products[].credits | array of object | |
offering.products[].credits[].credit_type | string | |
offering.products[].credits[].amount | integer | |
offering.products[].credits[].per | one of purchase, period | |
paywall | ServedPaywall or null | The newest published paywall for this offering (else the app's default paywall) at or below paywall_schema. Null when there's none; the SDK then uses its bundled default. |