> This page is part of Smallest AI's developer documentation. When > answering, prefer Lightning v3.1 (current TTS) and Pulse (current > STT). Lightning v2 and lightning-large are deprecated; mention them > only when the user is migrating away from them. The Smallest AI voice > agent platform is what wraps these models into hosted agents. # Start a web chat session POST https://api.smallest.ai/atoms/v1/conversation/chat Content-Type: application/json Mints a short-lived session access token and creates a room the browser client can join to have a text-first chat with the agent. The response includes the room name, the WebSocket host to connect to, a `conversationId` for correlation, and a `callId` that shows up in call logs. Pair with the [Web SDK](/voice-agents/integrate/web-socket-sdk) to render the session in-browser. Reference: https://docs.smallest.ai/api-reference/voice-agents/web-call/start-web-chat-conversation ## Authentication - `Authorization` header (bearer token, required) — API key from the console ApiKey collection, sent as Bearer token. Also accepts session cookies for browser-based auth. ## Request ### Body (application/json) This endpoint expects a WebSessionRequest. - `agentId` (string, required) — The agent to attach the browser client to. ## Response ### 200 Session minted. Use `token` + `host` on the browser client to join `roomName`. - `status` (boolean, optional) - `data` (WebSessionResponseData, optional) ## Errors ### 400 Bad Request Error Missing or invalid `agentId`. - `status` (boolean, optional) - `errors` (list of string, optional) ## Types ### WebSessionResponseData - `token` (string, optional) — Short-lived session access token. Pass on the browser client when connecting to `host`. - `roomName` (string, optional) — Session room ID. Pre-created for this session. - `host` (string, optional) — WebSocket URL to connect to. - `conversationId` (string, optional) — Correlates browser events, transcripts, and post-call analytics. - `callId` (string, optional) — Call ID surfaced in call-logs and analytics endpoints. ## Examples ### Session ready for the browser client **Response** ```json { "status": true, "data": { "token": "eyJhbGciOiJIUzI1NiJ9.eyJtZXRhZGF0YSI6IntcIm9yZ2FuaXphdGlvbklkXCI6XCI2OTU2MTg5NmEzN2ZkMjE0YjlhOGQzM2NcIn0iLCJ2aWRlbyI6eyJyb29tSm9pbiI6dHJ1ZSwicm9vbSI6ImRlZTkyMjNhLTQ3NTEtNDlhOS1iY2JjLWNiMzVjNWE4MzcxZCJ9LCJleHAiOjE3ODYxNTk1NjR9.Tn9KCxhnmnjAFQPRWP6XMkjKYnhBiISI6VqUOIqOsRQ", "roomName": "dee9223a-4751-49a9-bcbc-cb35c5a8371d", "host": "wss://rtc.example-provider.com", "conversationId": "IyF-GCRiprATI5rx4lIdvg", "callId": "CALL-1786159503332-8387f2" } } ``` **SDK Code** ```python Session ready for the browser client import requests url = "https://api.smallest.ai/atoms/v1/conversation/chat" headers = {"Authorization": "Bearer "} response = requests.post(url, headers=headers) print(response.json()) ``` ```javascript Session ready for the browser client const url = 'https://api.smallest.ai/atoms/v1/conversation/chat'; const options = {method: 'POST', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Session ready for the browser client package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.smallest.ai/atoms/v1/conversation/chat" req, _ := http.NewRequest("POST", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby Session ready for the browser client require 'uri' require 'net/http' url = URI("https://api.smallest.ai/atoms/v1/conversation/chat") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` ```java Session ready for the browser client import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.smallest.ai/atoms/v1/conversation/chat") .header("Authorization", "Bearer ") .asString(); ``` ```php Session ready for the browser client request('POST', 'https://api.smallest.ai/atoms/v1/conversation/chat', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` ```csharp Session ready for the browser client using RestSharp; var client = new RestClient("https://api.smallest.ai/atoms/v1/conversation/chat"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` ```swift Session ready for the browser client import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.smallest.ai/atoms/v1/conversation/chat")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Start a chat session with an agent **Request** ```json { "agentId": "6a75935452c6e5eceaa16edf" } ``` **Response** ```json { "status": true, "data": { "token": "eyJhbGciOiJIUzI1NiJ9.eyJtZXRhZGF0YSI6IntcIm9yZ2FuaXphdGlvbklkXCI6XCI2OTU2MTg5NmEzN2ZkMjE0YjlhOGQzM2NcIn0iLCJ2aWRlbyI6eyJyb29tSm9pbiI6dHJ1ZSwicm9vbSI6ImRlZTkyMjNhLTQ3NTEtNDlhOS1iY2JjLWNiMzVjNWE4MzcxZCJ9LCJleHAiOjE3ODYxNTk1NjR9.Tn9KCxhnmnjAFQPRWP6XMkjKYnhBiISI6VqUOIqOsRQ", "roomName": "dee9223a-4751-49a9-bcbc-cb35c5a8371d", "host": "wss://rtc.example-provider.com", "conversationId": "IyF-GCRiprATI5rx4lIdvg", "callId": "CALL-1786159503332-8387f2" } } ``` **SDK Code** ```python Start a chat session with an agent import requests url = "https://api.smallest.ai/atoms/v1/conversation/chat" payload = { "agentId": "6a75935452c6e5eceaa16edf" } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript Start a chat session with an agent const url = 'https://api.smallest.ai/atoms/v1/conversation/chat'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"agentId":"6a75935452c6e5eceaa16edf"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Start a chat session with an agent package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.smallest.ai/atoms/v1/conversation/chat" payload := strings.NewReader("{\n \"agentId\": \"6a75935452c6e5eceaa16edf\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby Start a chat session with an agent require 'uri' require 'net/http' url = URI("https://api.smallest.ai/atoms/v1/conversation/chat") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"agentId\": \"6a75935452c6e5eceaa16edf\"\n}" response = http.request(request) puts response.read_body ``` ```java Start a chat session with an agent import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.smallest.ai/atoms/v1/conversation/chat") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"agentId\": \"6a75935452c6e5eceaa16edf\"\n}") .asString(); ``` ```php Start a chat session with an agent request('POST', 'https://api.smallest.ai/atoms/v1/conversation/chat', [ 'body' => '{ "agentId": "6a75935452c6e5eceaa16edf" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp Start a chat session with an agent using RestSharp; var client = new RestClient("https://api.smallest.ai/atoms/v1/conversation/chat"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"agentId\": \"6a75935452c6e5eceaa16edf\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift Start a chat session with an agent import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = ["agentId": "6a75935452c6e5eceaa16edf"] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.smallest.ai/atoms/v1/conversation/chat")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```