Create Public Session - Uplift AI API Docs

Example Request

JavaScript (Frontend)

React Example

curl -X POST https://api.upliftai.org/v1/realtime-assistants/550e8400-e29b-41d4-a716-446655440000/createPublicSession \
  -H "Content-Type: application/json" \
  -d '{
    "participantName": "Guest User"
  }'
// Can be called directly from frontend for public assistants
const assistantId = '550e8400-e29b-41d4-a716-446655440000';

const response = await fetch(
  `https://api.upliftai.org/v1/realtime-assistants/${assistantId}/createPublicSession`,
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      participantName: 'Guest User',
    })
  }
);

if (!response.ok) {
  if (response.status === 403) {
    throw new Error('This assistant is not public');
  }
  if (response.status === 404) {
    throw new Error('Assistant not found');
  }
  throw new Error('Failed to create session');
}

const sessionData = await response.json();
import { useState } from 'react';
import { UpliftAIRoom } from '@upliftai/assistants-react';

function PublicAssistantDemo() {
  const [sessionData, setSessionData] = useState(null);
  const [loading, setLoading] = useState(false);

const connectToAssistant = async () => {
    setLoading(true);
    try {
      const response = await fetch(
        'https://api.upliftai.org/v1/realtime-assistants/YOUR_PUBLIC_ASSISTANT_ID/createPublicSession',
        {
          method: 'POST',
          headers: { 'Content-Type': 'application/json' },
          body: JSON.stringify({
            participantName: 'Demo User'
          })
        }
      );

const data = await response.json();
      setSessionData(data);
    } catch (error) {
      console.error('Failed to connect:', error);
    } finally {
      setLoading(false);
    }
  };

if (!sessionData) {
    return (
      <button onClick={connectToAssistant} disabled={loading}>
        {loading ? 'Connecting...' : 'Connect to Assistant'}
      </button>
    );
  }

return (
    <UpliftAIRoom
      token={sessionData.token}
      serverUrl={sessionData.wsUrl}
      connect={true}
      audio={true}
    >
      <YourAssistantUI />
    </UpliftAIRoom>
  );
}

Response

{
  "token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MDU0MTAwMDAsImlzcyI6IkFQSWFiY2RlZiIsImp0aSI6Imd1ZXN0XzEyMyIsIm5hbWUiOiJHdWVzdCBVc2VyIiwicm9vbSI6InB1YmxpYy1hYmMxMjMiLCJzdWIiOiJndWVzdF8xMjMiLCJ2aWRlbyI6eyJyb29tIjoiam9pbiIsInJvb21BZG1pbiI6ZmFsc2UsInJvb21DcmVhdGUiOmZhbHNlLCJyb29tSm9pbiI6dHJ1ZSwicm9vbUxpc3QiOmZhbHNlfX0.signature",
  "wsUrl": "wss://upliftai-livekit-url...",
  "roomName": "public-abc123-1705406400"
}

Endpoint Details

Use Cases

Public sessions are ideal for:

Security Considerations

Public assistants are accessible to anyone with the assistant ID. Ensure you:

Limitations

Public sessions have the following limitations:

Making an Assistant Public

To enable public access for an assistant:

// Update existing assistant
await fetch(`https://api.upliftai.org/v1/realtime-assistants/${assistantId}`, {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    public: true
  })
});

Related Endpoints