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

# Principal Sessions

> Create end-user dashboard sessions

## Overview

Principal sessions allow end-users to view and manage their grants through a dashboard. Create a session to generate a short-lived JWT and dashboard URL.

## Create

```go theme={null}
session, err := client.PrincipalSessions.Create(ctx, grantex.CreatePrincipalSessionParams{
    PrincipalID: "user-123",
    ExpiresIn:   "1h",
})
fmt.Printf("Dashboard: %s\n", session.DashboardURL)
```

### Parameters

| Parameter     | Type     | Required | Description                        |
| ------------- | -------- | -------- | ---------------------------------- |
| `PrincipalID` | `string` | Yes      | The user to create a session for   |
| `ExpiresIn`   | `string` | No       | Session duration (default: `"1h"`) |

### Response (`PrincipalSessionResponse`)

| Field          | Type     | Description                      |
| -------------- | -------- | -------------------------------- |
| `SessionToken` | `string` | Short-lived JWT for API access   |
| `DashboardURL` | `string` | URL to the permissions dashboard |
| `ExpiresAt`    | `string` | ISO 8601 session expiry          |

## Usage

Embed the dashboard URL in your application to let users manage their granted permissions:

```go theme={null}
session, _ := client.PrincipalSessions.Create(ctx, grantex.CreatePrincipalSessionParams{
    PrincipalID: currentUser.ID,
})
// Redirect or embed session.DashboardURL in an iframe
```
