NewWacht Bench is live — AI-assisted development for Wacht

createSessionTicket()

Creates a short-lived session ticket for impersonation or scoped backend access flows.

Usage

The following example shows a basic usage of the backend client from @wacht/nextjs/server.

import { createSessionTicket, initClient } from '@wacht/backend';export async function createAgentAccessTicket(actorId: string, agentIds: string[]) {  initClient({ apiKey: process.env.WACHT_API_KEY! });  return createSessionTicket({    ticket_type: 'agent_access',    actor_id: actorId,    agent_ids: agentIds,  });}

Signature

function createSessionTicket(  request: CreateSessionTicketRequest,): Promise<SessionTicketResponse>

Parameters

ticket_type: 'impersonation' | 'agent_access' | 'webhook_app_access' | 'api_auth_access';
Ticket mode.
user_id?: string | undefined;
User id for impersonation flow.
agent_ids?: string[] | undefined;
Agent ids for agent access tickets.
webhook_app_slug?: string | undefined;
Webhook app scope for webhook access ticket.
api_auth_app_slug?: string | undefined;
API auth app scope for api-auth ticket.
expires_in?: number | undefined;
Optional custom expiry (seconds).

Return value

ticket?: string | undefined;
Issued session ticket value.
expires_at?: number | undefined;
Epoch timestamp when ticket expires.

Behavior

  • Creates a new resource and returns the created object from the backend.
  • Validate required fields before calling to avoid predictable request failures.

On this page