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

# Create Session

> Create a new session for connecting to a realtime assistant

<Note>
  **Beta Feature**: This endpoint is currently in beta. Features and specifications may change.
</Note>

<Info>
  This endpoint requires authentication with your API key and should be called from your backend server, not directly from client applications.
</Info>

<ParamField path="realtimeAssistantId" type="string" required>
  The unique identifier of the assistant
</ParamField>

<ParamField body="participantName" type="string" required>
  Display name for the user participant
</ParamField>

<ParamField body="roomName" type="string">
  Optional custom room name. If not provided, a unique room name will be generated
</ParamField>

<RequestExample>
  ```bash Example Request theme={null}
  curl -X POST https://api.upliftai.org/v1/realtime-assistants/550e8400-e29b-41d4-a716-446655440000/createSession \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "participantName": "John Doe"
    }'
  ```

  ```javascript JavaScript (Backend) theme={null}
  const assistantId = '550e8400-e29b-41d4-a716-446655440000';

  const response = await fetch(
    `https://api.upliftai.org/v1/realtime-assistants/${assistantId}/createSession`,
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        participantName: 'John Doe',
        // roomName: 'custom-room-123' // optional
      })
    }
  );

  const sessionData = await response.json();

  // Send sessionData to your frontend application
  ```

  ```javascript React Frontend Usage theme={null}
  // After receiving session data from your backend
  import { UpliftAIRoom } from '@upliftai/assistants-react';

  function App({ sessionData }) {
    return (
      <UpliftAIRoom
        token={sessionData.token}
        serverUrl={sessionData.wsUrl}
        connect={true}
        audio={true}
        video={false}
      >
        <YourAssistantUI />
      </UpliftAIRoom>
    );
  }
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MDU0MTAwMDAsImlzcyI6IkFQSWFiY2RlZiIsImp0aSI6InBhcnRpY2lwYW50XzEyMyIsIm5hbWUiOiJKb2huIERvZSIsInJvb20iOiJzdXBwb3J0LWFiYzEyMyIsInN1YiI6InBhcnRpY2lwYW50XzEyMyIsInZpZGVvIjp7InJvb20iOiJqb2luIiwicm9vbUFkbWluIjpmYWxzZSwicm9vbUNyZWF0ZSI6ZmFsc2UsInJvb21Kb2luIjp0cnVlLCJyb29tTGlzdCI6ZmFsc2V9fQ.signature",
    "wsUrl": "wss://upliftai-livekit-url...",
    "roomName": "support-abc123-1705406400"
  }
  ```
</ResponseExample>

## Session Token Details

The returned token is a JWT that contains:

* User identity and display name
* Room access permissions
* Expiration time (based on TTL configuration)
* Audio/video capabilities

## Connection Flow

1. **Backend**: Call this endpoint with your API key
2. **Backend**: Return session data to your frontend
3. **Frontend**: Use the token and wsUrl to connect via SDK
4. **WebRTC**: Establish peer connection for real-time audio

## Security Best Practices

<Warning>
  Never expose your API key in client-side code. Always create sessions from your backend server.
</Warning>

* Validate user authentication before creating sessions
* Implement rate limiting per user
* Monitor session creation for abuse
* Set appropriate TTL values for your use case

## Related Endpoints

* [Create Public Session](/assistants/api-reference/create-public-session) - For public assistants
* [Create Adhoc Session](/assistants/api-reference/create-adhoc-session) - For temporary custom configurations
