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.

Parameters and responses

Response 200

CustomerState

Errors

400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.

GET/v1/customers/{id}

A customer by app_user_id (secret key)

Parameters and responses

Path parameters

NameTypeDescription
id requiredstringapp_user_id, or me with a publishable key 1 to 255 characters.

Response 200

CustomerState

Errors

400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.

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

NameTypeDescription
id requiredstringapp_user_id, or me with a publishable key 1 to 255 characters.

Request body

Every field is optional.

FieldTypeDescription
emailstring (email) or nullUp to 320 characters.
attributesmap of string or number or boolean or null

Response 200

CustomerState

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.

Parameters and responses

Path parameters

NameTypeDescription
id requiredstringapp_user_id, or me with a publishable key 1 to 255 characters.

Response 204

No body.

Errors

400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.

GET/v1/customers/{id}/entitlements

A customer's entitlements (the hot path)

Parameters and responses

Path parameters

NameTypeDescription
id requiredstringapp_user_id, or me with a publishable key 1 to 255 characters.

Response 200

FieldTypeDescription
entitlementsmap 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

NameTypeDescription
id requiredstringapp_user_id, or me with a publishable key 1 to 255 characters.

Request body

FieldTypeDescription
alias requiredstring1 to 255 characters.
merge_policyone of transfer_purchases, keep_existing, reject

Response 200

FieldTypeDescription
outcomeone of added, already_aliased, merged, kept_existing
customerCustomerState

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

Parameters and responses

Path parameters

NameTypeDescription
id requiredstringapp_user_id, or me with a publishable key 1 to 255 characters.

Response 200

object

Errors

400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.

Credits

GET/v1/customers/{id}/credits

Credit balances and recent transactions

Parameters and responses

Path parameters

NameTypeDescription
id requiredstring1 to 255 characters.

Query parameters

NameTypeDescription
credit_typestringPattern ^[a-z0-9_]{1,64}$.
beforestring (uuid)
limitintegerDefault 25. 1 to 100.

Response 200

FieldTypeDescription
balancesmap of CreditBalance
transactionsarray 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

NameTypeDescription
id requiredstring1 to 255 characters.
type requiredstringPattern ^[a-z0-9_]{1,64}$.

Request body

FieldTypeDescription
amount requiredintegerMore than 0.
idempotency_key requiredstringSame key → same result, never a second debit. Pattern ^[\x21-\x7e]{1,200}$.
metadatamap of string or number or boolean or nullDefault {}.

Response 200

FieldTypeDescription
credit_typestring
amountinteger
balanceinteger
availableinteger
replayedbooleanTrue when this idempotency_key was used before; nothing new was debited.
transactionsarray 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

NameTypeDescription
id requiredstring1 to 255 characters.
type requiredstringPattern ^[a-z0-9_]{1,64}$.

Request body

FieldTypeDescription
amount requiredintegerMore than 0.
idempotency_key requiredstringSame key → same result, never a second debit. Pattern ^[\x21-\x7e]{1,200}$.
ttl_secondsintegerDefault 900. 10 to 86400.

Response 201

CreditHold

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

NameTypeDescription
id requiredstring1 to 255 characters.
type requiredstringPattern ^[a-z0-9_]{1,64}$.
holdId requiredstring (uuid)

Request body

Every field is optional.

FieldTypeDescription
amountintegerMore than 0.

Response 200

FieldTypeDescription
credit_typestring
amountinteger
balanceinteger
availableinteger
replayedbooleanTrue when this idempotency_key was used before; nothing new was debited.
transactionsarray 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

Parameters and responses

Path parameters

NameTypeDescription
id requiredstring1 to 255 characters.
type requiredstringPattern ^[a-z0-9_]{1,64}$.
holdId requiredstring (uuid)

Response 200

CreditHold

Errors

400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.

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

NameTypeDescription
id requiredstring1 to 255 characters.

Request body

FieldTypeDescription
entitlementstringPattern ^[a-z0-9_]{1,64}$.
credit_typestringPattern ^[a-z0-9_]{1,64}$.
amountintegerCredits to grant (credit grants only). More than 0.
starts_atstring (date-time)Entitlement grants can start later. Credits are granted now.
expires_atstring (date-time)Leave out for no expiry.
reason requiredstring1 to 500 characters.

Response 201

Grant

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.

Parameters and responses

Path parameters

NameTypeDescription
grantId requiredstring (uuid)

Response 200

Grant

Errors

400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.

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

NameTypeDescription
platform requiredone of ios, android, web
countrystringStore storefront country, ISO 3166-1 alpha-2. Pattern ^[A-Z]{2}$.
app_versionstringPattern ^\d+(\.\d+){0,3}$.
paywall_schemaintegerThe highest paywall config schema version the SDK renders. Without it, paywall is null. 1 to 1000.

Response 200

CurrentOffering

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

NameTypeDescription
key requiredstring1 to 64 characters.

Query parameters

NameTypeDescription
platform requiredone of ios, android, web
paywall_schemaintegerThe highest paywall config schema version the SDK renders. Without it, paywall is null. 1 to 1000.

Response 200

CurrentOffering

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

NameTypeDescription
id requiredstring

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

FieldTypeDescription
app_user_idstringme with a publishable key and customer token; any app_user_id with a secret key. Default "me". 1 to 255 characters.
product requiredstringPattern ^[a-z0-9_]{1,64}$.
success_urlstringUp to 2048 characters.
cancel_urlstringUp to 2048 characters.
returnappReturn to the app through its return_url_scheme, instead of URLs.

Response 200

FieldTypeDescription
idstring
urlstring

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

FieldTypeDescription
app_user_idstringme with a publishable key and customer token; any app_user_id with a secret key. Default "me". 1 to 255 characters.
product requiredstringPattern ^[a-z0-9_]{1,64}$.
formone of elements, payment_sheetDefault "elements".
return_urlstringWhere redirect-based payment methods return (elements). Up to 2048 characters.

Response 200

FieldTypeDescription
idstring
formone of elements, payment_sheet
client_secretstring or null
publishable_keystring or null
stripe_accountstring or nullPass 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

Query parameters

NameTypeDescription
subscription_id requiredstring (uuid)
return_urlstringStripe portal only: where its back link goes. Up to 2048 characters.

Response 200

FieldTypeDescription
urlstring

Errors

400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.

POST/v1/subscriptions/{id}/change

Move a Stripe subscription to another product (upgrade, downgrade)

Parameters and responses

Path parameters

NameTypeDescription
id requiredstring (uuid)

Request body

FieldTypeDescription
product requiredstringPattern ^[a-z0-9_]{1,64}$.
timingone of immediately, period_endDefaults to the new product's setting.
prorationone of create_prorations, none, always_invoice

Response 200

CustomerState

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

Parameters and responses

Path parameters

NameTypeDescription
id requiredstring (uuid)

Request body

Every field is optional.

FieldTypeDescription
at_period_endbooleanDefault true.

Response 200

CustomerState

Errors

400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.

POST/v1/subscriptions/{id}/resume

Undo a scheduled cancellation, or resume a paused Stripe subscription

Parameters and responses

Path parameters

NameTypeDescription
id requiredstring (uuid)

Response 200

CustomerState

Errors

400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.

POST/v1/subscriptions/{id}/anchor

Move a Stripe subscription to a fixed billing day

Parameters and responses

Path parameters

NameTypeDescription
id requiredstring (uuid)

Request body

FieldTypeDescription
day requiredinteger1 to 31.
monthinteger1 to 12.
timezonestringUp to 64 characters.
first_period requiredone of prorate, free_until_anchor, full_then_anchor
minimum_first_period_daysinteger0 to 31.

Response 200

CustomerState

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

Path parameters

NameTypeDescription
id requiredstring (uuid)

Request body

Every field is optional.

FieldTypeDescription
amountintegerMinor units; leave out for the full amount. More than 0.

Response 200

CustomerState

Errors

400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.

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

FieldTypeDescription
product_id requiredstringThe App Store product id 1 to 255 characters.
offer_id requiredstring1 to 64 characters.

Response 200

FieldTypeDescription
key_identifierstring
noncestring
timestampinteger
signaturestring
app_account_tokenstring

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

FieldTypeDescription
platform requiredios
signed_transaction requiredstringUp to 32768 characters.
app_user_idstring1 to 255 characters.

platform is android

FieldTypeDescription
purchase_token requiredstringPattern ^[A-Za-z0-9._-]{8,2048}$.
product_id requiredstringThe Play product id (for subscriptions, the subscription id). Pattern ^[a-z0-9][a-z0-9._]{0,149}$.
type requiredone of subscription, one_time
platform requiredandroid
app_user_idstring1 to 255 characters.

Response 200

FieldTypeDescription
provisionalbooleanGranted from the verified transaction while Apple was unreachable.
customerCustomerState

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

FieldTypeDescription
platform requiredios
signed_transactions requiredarray of stringUp to 100 items.

platform is android

FieldTypeDescription
platform requiredandroid
purchases requiredarray of objectUp to 100 items.
purchases[].purchase_token requiredstringPattern ^[A-Za-z0-9._-]{8,2048}$.
purchases[].product_id requiredstringThe Play product id (for subscriptions, the subscription id). Pattern ^[a-z0-9][a-z0-9._]{0,149}$.
purchases[].type requiredone of subscription, one_time

Response 200

FieldTypeDescription
resultsarray of object
results[].transaction_idstring or nullThe App Store transaction id, or the Play purchase token.
results[].outcomeone of owned, transferred, shared, kept_with_original, invalid
customerCustomerState

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

NameTypeDescription
afterstring (uuid)
limitintegerDefault 50. 1 to 100.
typestringUp to 64 characters.
customerstringOnly events for this app_user_id. 1 to 255 characters.

Response 200

FieldTypeDescription
dataarray of Event
has_moreboolean

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

NameTypeDescription
afterstring (uuid)
limitintegerDefault 50. 1 to 100.
fromstring (date-time)occurred_at at or after
tostring (date-time)occurred_at before

Response 200

FieldTypeDescription
dataarray of RevenueTransaction
has_moreboolean

Errors

400, 401, 403, 404, 409, 422, with a Problem body. Errors lists every code.

Schemas

Problem

FieldTypeDescription
typestring
titlestring
statusnumber
codestring
detail optionalstring
request_id optionalstring
errors optionalany

EntitlementState

FieldTypeDescription
activeboolean
sourceone of purchase, subscription, grant or null
storeone of stripe, apple, google or nullWhere to manage it: App Store, Google Play or web (Stripe).
expires_atstring or null
will_renewboolean
in_graceboolean
billing_issueboolean
quantityinteger or null

CreditBalance

FieldTypeDescription
balanceinteger
availableintegerBalance minus credits reserved by open holds.

SubscriptionSummary

FieldTypeDescription
idstring
productstring or null
storeone of stripe, apple, google
statusstring
current_period_startstring or null
current_period_endstring or null
trial_endstring or null
grace_period_endstring or null
cancel_atstring or null
will_renewboolean
provisionalboolean

CustomerState

FieldTypeDescription
customerobject
customer.idstring
customer.app_user_idstring
customer.app_account_tokenstringSet this as appAccountToken on every StoreKit purchase, so Tenth can tell whose it is.
customer.obfuscated_account_idstringSet this as obfuscatedAccountId on every Play Billing purchase, so Tenth can tell whose it is.
customer.created_atstring
entitlementsmap of EntitlementState
creditsmap of CreditBalance
subscriptionsarray of SubscriptionSummary

CreditTransaction

FieldTypeDescription
idstring
credit_typestring
typeone of grant, debit, expire, clawback, adjustment, refill
amountinteger
lot_idstring or null
metadataobject
occurred_atstring (date-time)

CreditHold

FieldTypeDescription
idstring
credit_typestring
amountinteger
statusone of held, committed, released, expired
expires_atstring (date-time)
created_atstring (date-time)

Grant

FieldTypeDescription
idstring
customer_idstring
entitlementstring or null
credit_typestring or null
amountinteger or null
starts_atstring (date-time)
expires_atstring (date-time) or null
reasonstring
created_bystring
revoked_atstring (date-time) or null
created_atstring (date-time)

Event

FieldTypeDescription
idstring
typestring
created_atstring (date-time)
payloadobject

RevenueTransaction

FieldTypeDescription
idstring
customer_idstring
providerone of stripe, apple, google
platformone of ios, android, web
typeone of purchase, renewal, refund, refund_reversal, chargeback, chargeback_reversal
provider_transaction_idstring
original_transaction_idstring or null
refunded_transaction_idstring or null
subscription_idstring or null
purchase_idstring or null
product_idstring or null
occurred_atstring (date-time)
period_startstring (date-time) or null
period_endstring (date-time) or null
countrystring or null
currencystring
gross_amountintegerMinor units of currency.
tax_amountinteger or null
fee_amountinteger
net_amountinteger
fee_is_estimatedboolean
amount_is_estimatedboolean
gross_amount_usdinteger or nullUSD cents. Null until the day’s FX rate is known.
fee_amount_usdinteger or null
net_amount_usdinteger or null
fx_ratestring or null
fx_rate_datestring or null
fx_sourceone of identity, stripe_balance_transaction, daily_rate or null
is_trial_conversionboolean

DisplayPrice

FieldTypeDescription
amount_minorstringMinor units of currency, as an integer string. Pattern ^\d+$.
currencystringISO 4217, uppercase.
recurringobject or nullNull for one-time prices.
recurring.intervalone of day, week, month, year
recurring.interval_countintegerMore than 0.
trial_period_daysinteger or null

ServedPaywall

FieldTypeDescription
idstring
versionintegerMore than 0.
configobjectA published paywall config (@tenthbilling/paywall/schema) whose schema_version is at most paywall_schema. Parse it with parseServedPaywall.
assetsmap of stringImage id → URL, on the API's own origin.

CurrentOffering

FieldTypeDescription
offeringobject or null
offering.keystring
offering.purchase_pathone of store, web_link_out, in_app_stripe, none
offering.productsarray of object
offering.products[].keystring
offering.products[].typeone of subscription, non_consumable, consumable
offering.products[].display_namestring or null
offering.products[].labelstring or null
offering.products[].badgestring or null
offering.products[].is_highlightedboolean
offering.products[].store_product_idstringApp Store product id, Google Play product id, or Stripe price id, for this platform and purchase path.
offering.products[].google_base_plan_idstring or null
offering.products[].google_offer_idstring or null
offering.products[].priceDisplayPrice or nullWeb (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[].entitlementsarray of string
offering.products[].creditsarray of object
offering.products[].credits[].credit_typestring
offering.products[].credits[].amountinteger
offering.products[].credits[].perone of purchase, period
paywallServedPaywall or nullThe 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.