Vapi Support Bot
10/28/2025, 9:38 PMsessionId in your browser (e.g., localStorage) and reusing it for all chat requests. Here’s a quick example:
javascript
// On first load or new session
const session = await fetch('https://api.vapi.ai/session', {
method: 'POST',
headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' },
body: JSON.stringify({ assistantId: 'your-assistant-id' })
}).then(res => res.json());
localStorage.setItem('sessionId', session.id);
// For all chat requests (even after tab switch)
const sessionId = localStorage.getItem('sessionId');
await fetch('https://api.vapi.ai/chat', {
method: 'POST',
headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' },
body: JSON.stringify({ sessionId, input: 'Your message here' })
});
This will help you maintain context and entries across tab switches by always using the same sessionId in your requests.
For more, see the [Session Management documentation](https://docs.vapi.ai/chat/session-management).
Source:
- [Session management](https://docs.vapi.ai/chat/session-management)Chiranjeet Mishra
10/30/2025, 9:00 PM