Verify Sessions Server-side

For time-based billing, access is controlled through paywall events on the client. But if your backend serves premium content (articles, streams, API data), you need to verify the session on the server before delivering it. This guide walks you through that flow.

Verify sessions flow: frontend captures sessionId, sends to backend, backend validates with tiun API

How it works

  1. The paywallHide event includes a sessionId when the user has access

  2. Your frontend sends that session ID to your backend

  3. Your backend validates it against the tiun API

  4. If valid, you serve the premium content


Setup: API key

Before you can verify sessions, create an API key in the dashboard: go to APIs in the sidebar and click Create new key.

Store it securely in your backend environment variables.


1. Capture the session ID

When paywallHide fires, the payload includes a sessionId. Pass it to your backend when fetching premium content.


2. Validate the session on your server

Call the tiun API to confirm the session is valid before serving content.

Endpoint:

PATCH /live_api/s2s/v1/sessions/{sessionId}/status

Base URLs:

Environment
URL

Production

https://api.tiun.live

Sandbox

https://api-sandbox.tiun.live

Header: X-ACCESS-TOKEN: <your-api-key>

Response codes:

Status
Meaning

200

Session is valid — serve the content

404

Session is invalid, expired, or user has no funds

401

API key is incorrect


3. Backend implementation


Full round-trip

Frontend — capture the session ID and fetch content:

Backend — validate and serve:


circle-info

Use the sandbox base URL while developing. Switch to the production URL when you go live.

For a conceptual overview of session verification, see Verifying Accessarrow-up-right in the Docs.

Last updated

Was this helpful?