curl --request GET \
--url https://api.humain.ai/v1/sessions/{sid}/ws \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.humain.ai/v1/sessions/{sid}/ws"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.humain.ai/v1/sessions/{sid}/ws', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.humain.ai/v1/sessions/{sid}/ws",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.humain.ai/v1/sessions/{sid}/ws"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.humain.ai/v1/sessions/{sid}/ws")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.humain.ai/v1/sessions/{sid}/ws")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyText session (WebSocket)
Upgrades to a WebSocket for text conversation turns. Served on agent_url, the
base URL returned by POST /v1/sessions — not necessarily the host that served that
request. Standard HTTP 101 Switching Protocols response.
Auth — non-browser clients send Authorization: Bearer <token> on the upgrade
request. Browsers cannot set that header on a WS handshake, so first call
POST /v1/sessions/{sid}/ws-ticket and pass the result as ?ticket=<raw>.
Sending a message — one JSON text frame per turn:
{"type": "message", "content": "What are your opening hours?"}
Receiving a response:
{"type": "response", "content": "We are open Monday to Friday, 9 AM–6 PM.", "message_id": "3fa85f64-..."}
Errors arrive as a JSON frame on the same connection — the WebSocket is not closed with a 4xxx code:
{"type": "error", "code": "TURN_ERROR", "message": "INPUT_REJECTED: Contains a blocked phrase."}
The code field is TURN_ERROR for any pipeline failure (guardrail rejection,
FraudGuard block, rate limit, provider error); the real machine-readable reason is
the SCREAMING_SNAKE_CASE prefix of message, before the first : . SESSION_ENDED
and SERVICE_UNAVAILABLE are sent as distinct code values.
Session expiry warning — sent once, SESSION_TIME_WARNING_SECONDS (default 60s)
before the session’s time limit:
{"type": "session_expiring", "message": "Your session will expire in 60 seconds."}
curl --request GET \
--url https://api.humain.ai/v1/sessions/{sid}/ws \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.humain.ai/v1/sessions/{sid}/ws"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.humain.ai/v1/sessions/{sid}/ws', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.humain.ai/v1/sessions/{sid}/ws",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.humain.ai/v1/sessions/{sid}/ws"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.humain.ai/v1/sessions/{sid}/ws")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.humain.ai/v1/sessions/{sid}/ws")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyAuthorizations
Device credential issued from the Humain admin panel under Kiosk → Credentials → Issue new credential.
Format: hk_live_ (production) or hk_test_ (sandbox) followed by 43 base64url
characters (32 random bytes). The raw token is shown only once at creation time and
is never stored in plain text.
Path Parameters
Response
Switching Protocols — WebSocket connection established