Customer identity
On this page
Every customer in Tenth has an app_user_id: your ID for them. Your server uses it in calls like tenth.hasEntitlement(appUserId, 'pro'), and the app proves which customer it is by sending a token. This page covers where that ID comes from and how tokens are checked.
Identity is set per app and per environment, on the app's Identity page in the dashboard. Test and live each have their own settings.
Three ways to say who the customer is
| How | Use it when | app_user_id is |
|---|---|---|
| Clerk | Your app signs users in with Clerk. | The token's sub (Clerk's user ID), by default. |
| Another OIDC provider | Your app uses Auth0, Firebase, Supabase Auth or another provider that publishes a JWKS. | The token's sub, by default. |
| Server-minted tokens | You have your own sign-in, or you bill something other than the signed-in user. | Whatever your server puts in the token. |
Before sign-in, the Expo SDK uses an anonymous customer.
In every case, the app's getCustomerToken returns the token, and the SDK sends it with each request. The SDK never stores it.
Clerk
Pick Clerk as the provider type and enter your Clerk Frontend API URL (in Clerk under Configure → API keys, such as https://clerk.example.com). Then pass Clerk's getToken to the SDK:
const { getToken } = useAuth();
<TenthProvider apiKey="tenth_test_pk_..." getCustomerToken={getToken}>
- Which token: Clerk's default session token. You don't need a JWT template. (A template token from the same Clerk instance is accepted too, as long as it keeps
sub.) - What Tenth checks: the signature against your instance's JWKS (
<Frontend API URL>/.well-known/jwks.json, with asymmetric algorithms only), the issuer (your Frontend API URL), and thatexphasn't passed (with 5 seconds of clock tolerance). Clerk session tokens carry no audience, soaudisn't checked. - Authorized parties (
azp): optional. If you list origins under Authorized parties, only tokens whoseazpis one of them are accepted. Tokens from native apps carry noazp, so leave the list empty if your iOS or Android app sends tokens. List your web origins only when web is the only client. - Development and production instances: set up each Tenth environment with its matching Clerk instance. For example, put the development instance's Frontend API URL in the test environment and the production instance's in live. Tokens from one instance are refused by the other environment.
Other OIDC providers
Pick OIDC and enter:
| Field | What to enter |
|---|---|
| Issuer | The iss your provider puts in tokens, exactly. |
| Audience | Required. The aud your provider puts in tokens meant for this app. |
| JWKS URL | Where your provider publishes its public signing keys. https only. |
Tenth checks the signature, issuer, audience and exp. Only asymmetric algorithms (RS, PS, ES and EdDSA) are accepted. Tokens signed with a shared secret (HS256) are refused.
Supabase Auth works this way when the project uses asymmetric JWT signing keys: the issuer is https://<project>.supabase.co/auth/v1, the JWKS is at https://<project>.supabase.co/auth/v1/.well-known/jwks.json, and the audience is authenticated. Projects still on the legacy HS256 shared secret can't be verified directly; switch to signing keys, or use server-minted tokens.
The user ID claim
User ID claim picks the token claim that becomes the customer's app_user_id. It's sub unless you change it. The value must be 1 to 255 characters, with no control characters and no leading or trailing spaces.
So with Clerk, app_user_id is Clerk's user ID (user_...), and your server calls tenth.hasEntitlement(clerkUserId, 'pro').
A customer's app_user_id never changes. If a user's ID changes in your identity provider, the new ID is a different customer to Tenth. Link the two from your server with customers.alias, which can move the purchases across.
Server-minted tokens
Your server can sign customer tokens itself, with a secret from the Server-minted tokens card. Customer tokens in the Node SDK reference has the details and an example. The token's subject is the app_user_id. Mint tokens only for a user your server has authenticated: whoever holds one can read and buy as that customer.
Server-minted tokens work alongside an identity provider. Tenth tells them apart by their issuer.
Anonymous customers and aliases
Before sign-in, the Expo SDK makes up an anonymous ID ($tenth_anon_...) once per install and acts as that customer. On the first request with a token, it asks Tenth to alias the anonymous ID to the signed-in customer:
- If Tenth has no customer for the anonymous ID yet, the ID becomes an alias of the signed-in customer.
- If Tenth already has a customer for it, the app's merge policy decides.
transfer_purchases, the default, moves its purchases, grants and credits to the signed-in customer and merges the two.keep_existingleaves both customers as they are, andrejectrefuses withcustomer_alias_conflict.
Either way, the signed-in customer's app_user_id stays the same. An alias only makes another ID resolve to it. Your server can add aliases too, with customers.alias.
Billing a team or workspace
Some apps sell to a team, workspace or organization, not to a person: one subscription unlocks the workspace for all its members. RevenueCat apps often handle this by storing the workspace ID in a subscriber attribute. In Tenth, make the workspace the customer:
- Use the workspace's ID as the
app_user_id. - Have your server mint the customer token. It checks that the signed-in user belongs to the workspace, and that their role lets them buy, before it mints a token whose subject is the workspace ID.
- The app passes that token to
getCustomerToken. Purchases, entitlements and credits then belong to the workspace, and your server checkstenth.hasEntitlement(workspaceId, 'unlimited').
import { mintCustomerToken } from '@tenthbilling/node';
// GET /tenth-token?workspace=... (behind your own sign-in)
app.get('/tenth-token', requireSignedIn, async (req, res) => {
const workspaceId = String(req.query.workspace);
if (!(await isBillingMember(req.user.id, workspaceId))) return res.sendStatus(403);
const token = mintCustomerToken({
tokenSecret: process.env.TENTH_CUSTOMER_TOKEN_SECRET!,
appId: process.env.TENTH_APP_ID!,
environment: 'live',
appUserId: workspaceId,
});
res.json({ token });
});
When the user switches workspace in the app, change userId on TenthProvider to the workspace ID, so the SDK refreshes right away and never shows one workspace's access in another.
Don't let the app say which workspace a purchase is for. A purchase "context" or attribute sent from the app can be changed by anyone who modifies the app, so it could attach a purchase, or another workspace's access, to the wrong account. That's why Tenth's Expo SDK has no attribute setter. The membership check on your server is what makes the workspace model safe.
On the App Store and Google Play, the store account that pays is still a person's. The purchase belongs to whichever workspace's token was used when it was bought. A restore from that store account later follows the app's restore transfer policy.