Create portal session
Create a short-lived session token for an end user to access the Customer Portal.
The returned session ID is valid for 15 minutes and can be exchanged exactly once
for a 24-hour browser session via portal.exchangeSession. Redirect the end user
to the returned URL to start the portal experience.
Required Permissions
Your root key must be associated with a workspace that has an enabled portal configuration.
Documentation Index
Fetch the complete documentation index at: https://unkey-mintlify-b9e3cc05.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Authorizations
Unkey uses API keys (root keys) for authentication. These keys authorize access to management operations in the API. To authenticate, include your root key in the Authorization header of each request:
Authorization: Bearer unkey_123
Root keys have specific permissions attached to them, controlling what operations they can perform. Key permissions follow a hierarchical structure with patterns like resource.resource_id.action (e.g., apis.*.create_key, apis.*.read_api).
Security best practices:
- Keep root keys secure and never expose them in client-side code
- Use different root keys for different environments
- Rotate keys periodically, especially after team member departures
- Create keys with minimal necessary permissions following least privilege principle
- Monitor key usage with audit logs.
Body
The human-readable slug of the portal configuration to create the session against. Identifies which app's portal the end user will access. Must be 3-64 characters, lowercase alphanumeric and hyphens only, must not start or end with a hyphen, and must not contain consecutive hyphens.
3 - 64^[a-z0-9][a-z0-9-]*[a-z0-9]$"my-portal"
The end user's identifier in the customer's system. Accepts arbitrary string values (user IDs, emails, UUIDs, etc.).
1 - 256"user_123"
List of RBAC tuple permissions defining what the end user can do in the Portal.
Each permission is a string in the format {resourceType}.{resourceId}.{action}.
Use * as resourceId to grant access to all resources of that type.
Tab visibility is derived from the action segment:
- Keys tab:
read_key,create_key,update_key,delete_key - Analytics tab:
read_analytics - Docs tab: visible when any permission is present
1^[^.]+\.[^.]+\.[^.]+$[
"api.*.read_key",
"api.*.create_key",
"api.*.read_analytics"
]
When true, creates a preview session for testing the portal experience.
Response
Session token created successfully. Redirect the end user to the returned URL.

