curl -N https://www.verahealth.ai/api/chat/v2/stream/wf_01H9YABC... \
-H "x-api-key: YOUR_API_KEY"async function resumeStream(workflowRunId, apiKey) {
const response = await fetch(
`https://www.verahealth.ai/api/chat/v2/stream/${workflowRunId}`,
{ headers: { 'x-api-key': apiKey } },
);
if (!response.ok) {
throw new Error(`Resume failed: ${response.status}`);
}
const reader = response.body.getReader();
const decoder = new TextDecoder();
let buffer = '';
while (true) {
const { done, value } = await reader.read();
if (done) break;
buffer += decoder.decode(value, { stream: true });
const frames = buffer.split('\n\n');
buffer = frames.pop() ?? '';
for (const frame of frames) {
const line = frame.trim();
if (!line.startsWith('data: ')) continue;
const event = JSON.parse(line.slice(6));
// Same event handling as POST /api/chat/v2
console.log(event);
}
}
}import json
import requests
def resume_stream(workflow_run_id, api_key):
url = f'https://www.verahealth.ai/api/chat/v2/stream/{workflow_run_id}'
headers = {'x-api-key': api_key}
with requests.get(url, headers=headers, stream=True) as response:
response.raise_for_status()
for raw in response.iter_lines(decode_unicode=True):
if not raw or not raw.startswith('data: '):
continue
event = json.loads(raw[6:])
print(event) # same event handling as POST /api/chat/v2<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.verahealth.ai/api/chat/v2/stream/{runId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$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://www.verahealth.ai/api/chat/v2/stream/{runId}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://www.verahealth.ai/api/chat/v2/stream/{runId}")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.verahealth.ai/api/chat/v2/stream/{runId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body<string>{
"error": "Missing runId"
}{
"error": "Unauthorized"
}{
"error": "Workflow run not found"
}{
"error": {
"code": "rate_limited",
"message": "Rate limit exceeded. Retry after the interval in the Retry-After header."
}
}{
"error": "Internal server error",
"message": "An unexpected error occurred while processing your request"
}Resume a chat stream
Reconnect to an in-flight or recently completed chat stream started by POST /api/chat/v2. Any events buffered during the disconnect are replayed, then live events continue.
The response uses the same SSE event format as POST /api/chat/v2.
Obtaining runId
The run ID is delivered in the original POST /api/chat/v2 stream as a workflow-run-id event:
{"type": "workflow-run-id", "workflowRunId": "wf_01H9Y..."}
Authorization
The caller must present the same API key that started the run. Calls from any other key return 404.
curl -N https://www.verahealth.ai/api/chat/v2/stream/wf_01H9YABC... \
-H "x-api-key: YOUR_API_KEY"async function resumeStream(workflowRunId, apiKey) {
const response = await fetch(
`https://www.verahealth.ai/api/chat/v2/stream/${workflowRunId}`,
{ headers: { 'x-api-key': apiKey } },
);
if (!response.ok) {
throw new Error(`Resume failed: ${response.status}`);
}
const reader = response.body.getReader();
const decoder = new TextDecoder();
let buffer = '';
while (true) {
const { done, value } = await reader.read();
if (done) break;
buffer += decoder.decode(value, { stream: true });
const frames = buffer.split('\n\n');
buffer = frames.pop() ?? '';
for (const frame of frames) {
const line = frame.trim();
if (!line.startsWith('data: ')) continue;
const event = JSON.parse(line.slice(6));
// Same event handling as POST /api/chat/v2
console.log(event);
}
}
}import json
import requests
def resume_stream(workflow_run_id, api_key):
url = f'https://www.verahealth.ai/api/chat/v2/stream/{workflow_run_id}'
headers = {'x-api-key': api_key}
with requests.get(url, headers=headers, stream=True) as response:
response.raise_for_status()
for raw in response.iter_lines(decode_unicode=True):
if not raw or not raw.startswith('data: '):
continue
event = json.loads(raw[6:])
print(event) # same event handling as POST /api/chat/v2<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.verahealth.ai/api/chat/v2/stream/{runId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$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://www.verahealth.ai/api/chat/v2/stream/{runId}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://www.verahealth.ai/api/chat/v2/stream/{runId}")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.verahealth.ai/api/chat/v2/stream/{runId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body<string>{
"error": "Missing runId"
}{
"error": "Unauthorized"
}{
"error": "Workflow run not found"
}{
"error": {
"code": "rate_limited",
"message": "Rate limit exceeded. Retry after the interval in the Retry-After header."
}
}{
"error": "Internal server error",
"message": "An unexpected error occurred while processing your request"
}Authorizations
API key for authentication. Contact support@verahealth.ai to obtain your API key.
Path Parameters
Workflow run identifier received from the workflow-run-id event of the original POST /api/chat/v2 stream.
1Response
Reconnected. Returns the same SSE event stream as POST /api/chat/v2, starting with any buffered events followed by live events. See the POST /api/chat/v2 response for the full event catalog.
SSE stream replaying buffered events then continuing live. Same event format as POST /api/chat/v2.
Was this page helpful?