Framework guide

TypeScript/Node entitlements

Check entitlements and verify purchases from TypeScript/Node.js backends. Plain REST API — use fetch, axios, or any HTTP client. One call to gate a feature.

1

Store your API key securely

Your Tierux API key is a server-side secret. Store it in environment variables — never in client code, never in a public repo.

// .env (never commit)
TIERUX_API_KEY=pe_live_xxxxxxxxxxxxxxxxxxxx

// config.ts
export const TIERUX_API_KEY = process.env.TIERUX_API_KEY!;
export const TIERUX_BASE = 'https://tierux.com/api';
2

Verify a purchase

After your app sends a purchase token to your backend, call Tierux to verify it server-side.

// verify-purchase.ts
export async function verifyGooglePlayPurchase(params: {
  appId: string;
  userId: string;
  packageName: string;
  productId: string;
  purchaseToken: string;
}) {
  const res = await fetch(
    `${TIERUX_BASE}/v1/purchases/google-play/verify`,
    {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${TIERUX_API_KEY}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify(params),
    }
  );
  return res.json() as Promise<{
    ok: boolean;
    entitlement: string;
    active: boolean;
    expiresAt: string;
    status: string;
  }>;
}
3

Check an entitlement

Gate a feature by checking the user's entitlement state from your backend. One GET call — no caching, no state machine to maintain.

// check-entitlement.ts
export async function isEntitled(
  userId: string,
  entitlement: string
): Promise<boolean> {
  const res = await fetch(
    `${TIERUX_BASE}/v1/entitlements/${userId}/${entitlement}`,
    {
      headers: {
        'Authorization': `Bearer ${TIERUX_API_KEY}`,
      },
    }
  );
  const data = await res.json();
  return data.active === true;
}
4

Use with any Node.js framework

Tierux is framework-agnostic. Use it with Express, Fastify, Next.js API routes, or any other Node.js backend.

// Next.js API route example
export async function POST(request: Request) {
  const { purchaseToken, productId, userId } = await request.json();

  const result = await verifyGooglePlayPurchase({
    appId: 'app_123',
    userId,
    packageName: 'com.yourapp',
    productId,
    purchaseToken,
  });

  return Response.json({
    active: result.active,
    entitlement: result.entitlement,
    expiresAt: result.expiresAt,
  });
}
5

Apple verification too

For iOS purchases, send the StoreKit 2 JWS to the Apple verify endpoint. Same response shape, same entitlement logic.

// Apple verification
const res = await fetch(
  `${TIERUX_BASE}/v1/purchases/apple/verify`,
  {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${TIERUX_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      appId: 'app_123',
      userId,
      transactionId,
      jwsRepresentation,
    }),
  }
);
Related guides

Server-side entitlements

Gate features from any backend — one REST call per entitlement, platform-agnostic.

Purchase verification

Deep dive on how Tierux verifies tokens server-side for Google Play and Apple.

Quickstart docs

Full integration path with curl examples and all available endpoints.

TypeScript/Node backend, verified in one call

Free tier — unlimited apps, 1 paywall. No credit card, no revenue share.

Start free