Skip to main content
Multi-tenant SaaS applications often need to show customers their own activity history — who on their team did what and when. Immutable’s viewer tokens let you securely expose a read-only, tenant-scoped view of the audit log without giving customers access to your API key or other tenants’ data.

How It Works

  1. Your backend creates a viewer token scoped to a specific tenant_id
  2. The token is passed to your frontend
  3. Your frontend either embeds the Immutable viewer iframe or queries the public events endpoint directly
  4. The token expires after the configured TTL

Creating Viewer Tokens

Backend: Generate a Token

Scoping by Actor

You can also scope a viewer token to a specific actor, so a user only sees their own activity:
Viewer tokens are read-only and cannot be used to ingest events. They only grant access to events matching the scoped tenant_id (and optionally actor_id).

Embedding the Viewer

Option 1: Iframe Embed

The simplest integration — embed the Immutable viewer directly in your app:

Option 2: React Component

Build a custom activity feed by querying the public events endpoint with the viewer token:
When building a custom activity feed, implement cursor-based pagination using the cursor parameter from the API response. This ensures you can load older events without missing any.

TTL Management

Choose a TTL that matches your use case:

Refreshing Tokens

Create a backend endpoint that generates fresh tokens on demand:
On the frontend, refresh the token before it expires:

Querying Events with a Viewer Token

Viewer tokens work with the same events API, but responses are automatically filtered to the token’s scope:
Even if a query doesn’t include tenant_id as a filter, the viewer token enforces it. A viewer token scoped to org_acme_corp can never see events from other tenants.

What’s Next

Embeddable Viewer

Full guide to the Immutable viewer widget.

Events API

API reference for querying events.

Viewer Token API

API reference for creating viewer tokens.

SaaS Activity Tracking

End-to-end example of tracking user activity in a SaaS app.