Agents
Preview a realtime voice prompt template
Renders an unsaved template with this agent’s values and reports warnings (a capability token missing, an unknown token). Nothing is persisted. estimatedTokens is ceil(characters / 4).
POST
/
agents
/
{id}
/
voice-prompt
/
preview
Preview a realtime voice prompt template
curl --request POST \
--url https://api-trial.cognigy.ai/v1/agents/{id}/voice-prompt/preview \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"template": "<string>"
}
'import requests
url = "https://api-trial.cognigy.ai/v1/agents/{id}/voice-prompt/preview"
payload = { "template": "<string>" }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({template: '<string>'})
};
fetch('https://api-trial.cognigy.ai/v1/agents/{id}/voice-prompt/preview', 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-trial.cognigy.ai/v1/agents/{id}/voice-prompt/preview",
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([
'template' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"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"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-trial.cognigy.ai/v1/agents/{id}/voice-prompt/preview"
payload := strings.NewReader("{\n \"template\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<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-trial.cognigy.ai/v1/agents/{id}/voice-prompt/preview")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"template\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-trial.cognigy.ai/v1/agents/{id}/voice-prompt/preview")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"template\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"characters": 123,
"estimatedTokens": 123,
"prompt": "<string>",
"warnings": [
{
"kind": "missing_system_token",
"message": "<string>",
"token": "<string>"
}
]
}{
"detail": "request body validation failed",
"errors": [
{
"field": "<string>",
"message": "<string>"
}
],
"instance": "/v1/{resource}",
"status": 400,
"title": "Bad Request",
"traceId": "api--a4d2f126-bec4-4544-a049-7c0cf08524ed",
"type": "about:blank"
}{
"detail": "access denied: insufficient permissions",
"instance": "/v1/{resource}/{id}",
"status": 403,
"title": "Forbidden",
"traceId": "api--a4d2f126-bec4-4544-a049-7c0cf08524ed",
"type": "about:blank"
}{
"detail": "the requested resource does not exist",
"instance": "/v1/{resource}/{id}",
"status": 404,
"title": "Not Found",
"traceId": "api--a4d2f126-bec4-4544-a049-7c0cf08524ed",
"type": "about:blank"
}{
"detail": "internal server error",
"instance": "/v1/{resource}",
"status": 500,
"title": "Internal Server Error",
"traceId": "api--a4d2f126-bec4-4544-a049-7c0cf08524ed",
"type": "about:blank"
}Authorizations
[Production] API key for production authentication
Path Parameters
The unique identifier for the agent.
Body
application/json
Template to render
⌘I
Preview a realtime voice prompt template
curl --request POST \
--url https://api-trial.cognigy.ai/v1/agents/{id}/voice-prompt/preview \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"template": "<string>"
}
'import requests
url = "https://api-trial.cognigy.ai/v1/agents/{id}/voice-prompt/preview"
payload = { "template": "<string>" }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({template: '<string>'})
};
fetch('https://api-trial.cognigy.ai/v1/agents/{id}/voice-prompt/preview', 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-trial.cognigy.ai/v1/agents/{id}/voice-prompt/preview",
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([
'template' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"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"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-trial.cognigy.ai/v1/agents/{id}/voice-prompt/preview"
payload := strings.NewReader("{\n \"template\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<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-trial.cognigy.ai/v1/agents/{id}/voice-prompt/preview")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"template\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-trial.cognigy.ai/v1/agents/{id}/voice-prompt/preview")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"template\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"characters": 123,
"estimatedTokens": 123,
"prompt": "<string>",
"warnings": [
{
"kind": "missing_system_token",
"message": "<string>",
"token": "<string>"
}
]
}{
"detail": "request body validation failed",
"errors": [
{
"field": "<string>",
"message": "<string>"
}
],
"instance": "/v1/{resource}",
"status": 400,
"title": "Bad Request",
"traceId": "api--a4d2f126-bec4-4544-a049-7c0cf08524ed",
"type": "about:blank"
}{
"detail": "access denied: insufficient permissions",
"instance": "/v1/{resource}/{id}",
"status": 403,
"title": "Forbidden",
"traceId": "api--a4d2f126-bec4-4544-a049-7c0cf08524ed",
"type": "about:blank"
}{
"detail": "the requested resource does not exist",
"instance": "/v1/{resource}/{id}",
"status": 404,
"title": "Not Found",
"traceId": "api--a4d2f126-bec4-4544-a049-7c0cf08524ed",
"type": "about:blank"
}{
"detail": "internal server error",
"instance": "/v1/{resource}",
"status": 500,
"title": "Internal Server Error",
"traceId": "api--a4d2f126-bec4-4544-a049-7c0cf08524ed",
"type": "about:blank"
}