Prepare the read of a turn
curl --request POST \
--url https://{space}.{region}.api.niadra.com/v1/context/prefetch \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "<string>",
"about": {
"value": "<string>",
"scope": "<string>"
},
"conversation_id": "<string>",
"object": {
"id": "<string>",
"namespace": "<string>",
"type": "<string>"
},
"subject": {
"value": "<string>",
"scope": "<string>"
},
"task_id": "<string>",
"verification": "V0",
"view": "voice"
}
'import requests
url = "https://{space}.{region}.api.niadra.com/v1/context/prefetch"
payload = {
"query": "<string>",
"about": {
"value": "<string>",
"scope": "<string>"
},
"conversation_id": "<string>",
"object": {
"id": "<string>",
"namespace": "<string>",
"type": "<string>"
},
"subject": {
"value": "<string>",
"scope": "<string>"
},
"task_id": "<string>",
"verification": "V0",
"view": "voice"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
query: '<string>',
about: {value: '<string>', scope: '<string>'},
conversation_id: '<string>',
object: {id: '<string>', namespace: '<string>', type: '<string>'},
subject: {value: '<string>', scope: '<string>'},
task_id: '<string>',
verification: 'V0',
view: 'voice'
})
};
fetch('https://{space}.{region}.api.niadra.com/v1/context/prefetch', 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://{space}.{region}.api.niadra.com/v1/context/prefetch",
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([
'query' => '<string>',
'about' => [
'value' => '<string>',
'scope' => '<string>'
],
'conversation_id' => '<string>',
'object' => [
'id' => '<string>',
'namespace' => '<string>',
'type' => '<string>'
],
'subject' => [
'value' => '<string>',
'scope' => '<string>'
],
'task_id' => '<string>',
'verification' => 'V0',
'view' => 'voice'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://{space}.{region}.api.niadra.com/v1/context/prefetch"
payload := strings.NewReader("{\n \"query\": \"<string>\",\n \"about\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"conversation_id\": \"<string>\",\n \"object\": {\n \"id\": \"<string>\",\n \"namespace\": \"<string>\",\n \"type\": \"<string>\"\n },\n \"subject\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"task_id\": \"<string>\",\n \"verification\": \"V0\",\n \"view\": \"voice\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://{space}.{region}.api.niadra.com/v1/context/prefetch")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"<string>\",\n \"about\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"conversation_id\": \"<string>\",\n \"object\": {\n \"id\": \"<string>\",\n \"namespace\": \"<string>\",\n \"type\": \"<string>\"\n },\n \"subject\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"task_id\": \"<string>\",\n \"verification\": \"V0\",\n \"view\": \"voice\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{space}.{region}.api.niadra.com/v1/context/prefetch")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": \"<string>\",\n \"about\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"conversation_id\": \"<string>\",\n \"object\": {\n \"id\": \"<string>\",\n \"namespace\": \"<string>\",\n \"type\": \"<string>\"\n },\n \"subject\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"task_id\": \"<string>\",\n \"verification\": \"V0\",\n \"view\": \"voice\"\n}"
response = http.request(request)
puts response.read_body{
"queued": true
}{
"code": "<string>",
"status": 123,
"title": "<string>",
"detail": "<string>",
"request_id": "<string>",
"type": "about:blank"
}Context
Prepare the read of a turn
The partial transcript while the customer speaks; the read with the same query answers from work already done. 202 at once, no receipt. The SDKs also read the turn with the partial once it settles.
POST
/
v1
/
context
/
prefetch
Prepare the read of a turn
curl --request POST \
--url https://{space}.{region}.api.niadra.com/v1/context/prefetch \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "<string>",
"about": {
"value": "<string>",
"scope": "<string>"
},
"conversation_id": "<string>",
"object": {
"id": "<string>",
"namespace": "<string>",
"type": "<string>"
},
"subject": {
"value": "<string>",
"scope": "<string>"
},
"task_id": "<string>",
"verification": "V0",
"view": "voice"
}
'import requests
url = "https://{space}.{region}.api.niadra.com/v1/context/prefetch"
payload = {
"query": "<string>",
"about": {
"value": "<string>",
"scope": "<string>"
},
"conversation_id": "<string>",
"object": {
"id": "<string>",
"namespace": "<string>",
"type": "<string>"
},
"subject": {
"value": "<string>",
"scope": "<string>"
},
"task_id": "<string>",
"verification": "V0",
"view": "voice"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
query: '<string>',
about: {value: '<string>', scope: '<string>'},
conversation_id: '<string>',
object: {id: '<string>', namespace: '<string>', type: '<string>'},
subject: {value: '<string>', scope: '<string>'},
task_id: '<string>',
verification: 'V0',
view: 'voice'
})
};
fetch('https://{space}.{region}.api.niadra.com/v1/context/prefetch', 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://{space}.{region}.api.niadra.com/v1/context/prefetch",
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([
'query' => '<string>',
'about' => [
'value' => '<string>',
'scope' => '<string>'
],
'conversation_id' => '<string>',
'object' => [
'id' => '<string>',
'namespace' => '<string>',
'type' => '<string>'
],
'subject' => [
'value' => '<string>',
'scope' => '<string>'
],
'task_id' => '<string>',
'verification' => 'V0',
'view' => 'voice'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://{space}.{region}.api.niadra.com/v1/context/prefetch"
payload := strings.NewReader("{\n \"query\": \"<string>\",\n \"about\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"conversation_id\": \"<string>\",\n \"object\": {\n \"id\": \"<string>\",\n \"namespace\": \"<string>\",\n \"type\": \"<string>\"\n },\n \"subject\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"task_id\": \"<string>\",\n \"verification\": \"V0\",\n \"view\": \"voice\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://{space}.{region}.api.niadra.com/v1/context/prefetch")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"<string>\",\n \"about\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"conversation_id\": \"<string>\",\n \"object\": {\n \"id\": \"<string>\",\n \"namespace\": \"<string>\",\n \"type\": \"<string>\"\n },\n \"subject\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"task_id\": \"<string>\",\n \"verification\": \"V0\",\n \"view\": \"voice\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{space}.{region}.api.niadra.com/v1/context/prefetch")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": \"<string>\",\n \"about\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"conversation_id\": \"<string>\",\n \"object\": {\n \"id\": \"<string>\",\n \"namespace\": \"<string>\",\n \"type\": \"<string>\"\n },\n \"subject\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"task_id\": \"<string>\",\n \"verification\": \"V0\",\n \"view\": \"voice\"\n}"
response = http.request(request)
puts response.read_body{
"queued": true
}{
"code": "<string>",
"status": 123,
"title": "<string>",
"detail": "<string>",
"request_id": "<string>",
"type": "about:blank"
}Body
application/json
POST /v1/context/prefetch: the customer's turn so far, sent while they are still speaking, so the
read that answers the turn finds its work done. Same target, view and level as that read.

