Inject context into a session
curl --request POST \
--url https://api.osvi.ai/v1/chat/session/{id}/inject_context \
--header 'API-Token: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"context": "Earlier voice call: customer wants a refund and prefers WhatsApp follow-up."
}
'import requests
url = "https://api.osvi.ai/v1/chat/session/{id}/inject_context"
payload = { "context": "Earlier voice call: customer wants a refund and prefers WhatsApp follow-up." }
headers = {
"API-Token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'API-Token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
context: 'Earlier voice call: customer wants a refund and prefers WhatsApp follow-up.'
})
};
fetch('https://api.osvi.ai/v1/chat/session/{id}/inject_context', 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.osvi.ai/v1/chat/session/{id}/inject_context",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'context' => 'Earlier voice call: customer wants a refund and prefers WhatsApp follow-up.'
]),
CURLOPT_HTTPHEADER => [
"API-Token: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.osvi.ai/v1/chat/session/{id}/inject_context"
payload := strings.NewReader("{\n \"context\": \"Earlier voice call: customer wants a refund and prefers WhatsApp follow-up.\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("API-Token", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.osvi.ai/v1/chat/session/{id}/inject_context")
.header("API-Token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"context\": \"Earlier voice call: customer wants a refund and prefers WhatsApp follow-up.\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.osvi.ai/v1/chat/session/{id}/inject_context")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["API-Token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"context\": \"Earlier voice call: customer wants a refund and prefers WhatsApp follow-up.\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"session_id": "4718a326-417b-4dda-90d0-21fd65a11cb8",
"context": [
"Initial context for this chat",
"Earlier voice call: customer wants a refund and prefers WhatsApp follow-up."
]
}
}{
"success": false,
"error": "agent_not_found"
}{
"success": false,
"error": "agent_not_found"
}{
"success": false,
"error": "agent_not_found"
}{
"success": false,
"error": "Python engine returned 422 for POST /v1/chat/session/{id}/support",
"upstream_body": {
"state": "rejected",
"reason": "tell_not_allowed_during_takeover"
}
}Chat
Inject Context
Appends a single free-text context entry to a running session — for example a summary of an earlier voice call. The entry is added to the session’s context bucket.
POST
/
v1
/
chat
/
session
/
{id}
/
inject_context
Inject context into a session
curl --request POST \
--url https://api.osvi.ai/v1/chat/session/{id}/inject_context \
--header 'API-Token: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"context": "Earlier voice call: customer wants a refund and prefers WhatsApp follow-up."
}
'import requests
url = "https://api.osvi.ai/v1/chat/session/{id}/inject_context"
payload = { "context": "Earlier voice call: customer wants a refund and prefers WhatsApp follow-up." }
headers = {
"API-Token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'API-Token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
context: 'Earlier voice call: customer wants a refund and prefers WhatsApp follow-up.'
})
};
fetch('https://api.osvi.ai/v1/chat/session/{id}/inject_context', 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.osvi.ai/v1/chat/session/{id}/inject_context",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'context' => 'Earlier voice call: customer wants a refund and prefers WhatsApp follow-up.'
]),
CURLOPT_HTTPHEADER => [
"API-Token: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.osvi.ai/v1/chat/session/{id}/inject_context"
payload := strings.NewReader("{\n \"context\": \"Earlier voice call: customer wants a refund and prefers WhatsApp follow-up.\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("API-Token", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.osvi.ai/v1/chat/session/{id}/inject_context")
.header("API-Token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"context\": \"Earlier voice call: customer wants a refund and prefers WhatsApp follow-up.\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.osvi.ai/v1/chat/session/{id}/inject_context")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["API-Token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"context\": \"Earlier voice call: customer wants a refund and prefers WhatsApp follow-up.\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"session_id": "4718a326-417b-4dda-90d0-21fd65a11cb8",
"context": [
"Initial context for this chat",
"Earlier voice call: customer wants a refund and prefers WhatsApp follow-up."
]
}
}{
"success": false,
"error": "agent_not_found"
}{
"success": false,
"error": "agent_not_found"
}{
"success": false,
"error": "agent_not_found"
}{
"success": false,
"error": "Python engine returned 422 for POST /v1/chat/session/{id}/support",
"upstream_body": {
"state": "rejected",
"reason": "tell_not_allowed_during_takeover"
}
}Authorizations
16-character API token associated with your OSVI account. Find it in your dashboard under Settings → API.
Path Parameters
The session UUID.
Example:
"4718a326-417b-4dda-90d0-21fd65a11cb8"
Body
application/json
A single, non-empty context string to append to the session.
Example:
"Earlier voice call: customer wants a refund and prefers WhatsApp follow-up."
⌘I
