> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getimmutable.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Viewer Token

> Generate JWT tokens for the embeddable audit log viewer.

## POST /api/v1/viewer-token

Create a short-lived JWT token scoped to specific filters. The token holder can only view events matching the specified constraints.

### Request Body

<ParamField body="tenant_id" type="string">
  Restrict to events for a specific tenant.
</ParamField>

<ParamField body="actor_id" type="string">
  Restrict to events by a specific actor.
</ParamField>

<ParamField body="ttl" type="integer" default="3600">
  Token lifetime in seconds. Minimum 60, maximum 86400 (24 hours).
</ParamField>

### Response

```json theme={null}
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "expires_at": 1774537200
}
```

### Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://getimmutable.dev/api/v1/viewer-token \
    -H "Authorization: Bearer imk_your_api_key_here" \
    -H "Content-Type: application/json" \
    -d '{
      "tenant_id": "org_7rT2xBc",
      "ttl": 7200
    }'
  ```

  ```typescript JavaScript theme={null}
  const { token, expires_at } = await client.createViewerToken({
    tenantId: "org_7rT2xBc",
    ttl: 7200,
  });
  ```

  ```php Laravel theme={null}
  $result = AuditLog::createViewerToken([
      'tenantId' => 'org_7rT2xBc',
      'ttl' => 7200,
  ]);
  ```
</CodeGroup>

### Embedding

Pass the token to your frontend to render the embedded viewer:

```html theme={null}
<iframe
  src="https://getimmutable.dev/viewer?token=eyJhbGciOiJIUzI1NiIs..."
  width="100%"
  height="600"
  frameborder="0"
></iframe>
```

See the [Embeddable Viewer guide](/guides/embeddable-viewer) for React component examples and TTL management.

<Note>
  Viewer tokens are **read-only**. They cannot be used to ingest events or access any write endpoints.
</Note>
