Update an agent
curl --request PUT \
--url https://agents.assemblyai.com/v1/agents/{agent_id} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"name": "<string>",
"system_prompt": "<string>",
"greeting": "<string>",
"input": {
"type": "audio",
"format": {
"encoding": "audio/pcm",
"sample_rate": 24000
},
"turn_detection": {},
"keyterms": [
"<string>"
]
},
"output": {
"type": "audio",
"voice": "alba",
"format": {
"encoding": "audio/pcm",
"sample_rate": 24000
},
"volume": 123
},
"tools": [
{
"name": "get_weather",
"description": "Get current weather for a location. Use whenever the user asks about weather.",
"parameters": {
"type": "object",
"properties": {
"order_id": {
"type": "string",
"description": "The customer's order ID.",
"examples": [
"AB-12345"
],
"pattern": "[A-Z]{2}-\\d{5}"
}
},
"required": [
"order_id"
]
},
"timeout_seconds": 120,
"execution_mode": "interactive"
}
],
"llm": [
{
"base_url": "https://api.openai.com/v1",
"model": "gpt-4o-mini",
"api_key": "<string>"
}
],
"pre_connect_requests": [
{
"http": {
"url": "https://api.example.com/weather",
"http_method": "POST",
"headers": {}
},
"sends": [
"caller_number"
],
"returns": [
{
"name": "patient_name",
"path": "patient.first_name",
"default": "there"
}
],
"timeout_ms": 600,
"allow_overrides": [
"greeting"
]
}
]
}
EOFimport requests
url = "https://agents.assemblyai.com/v1/agents/{agent_id}"
payload = {
"name": "<string>",
"system_prompt": "<string>",
"greeting": "<string>",
"input": {
"type": "audio",
"format": {
"encoding": "audio/pcm",
"sample_rate": 24000
},
"turn_detection": {},
"keyterms": ["<string>"]
},
"output": {
"type": "audio",
"voice": "alba",
"format": {
"encoding": "audio/pcm",
"sample_rate": 24000
},
"volume": 123
},
"tools": [
{
"name": "get_weather",
"description": "Get current weather for a location. Use whenever the user asks about weather.",
"parameters": {
"type": "object",
"properties": { "order_id": {
"type": "string",
"description": "The customer's order ID.",
"examples": ["AB-12345"],
"pattern": "[A-Z]{2}-\d{5}"
} },
"required": ["order_id"]
},
"timeout_seconds": 120,
"execution_mode": "interactive"
}
],
"llm": [
{
"base_url": "https://api.openai.com/v1",
"model": "gpt-4o-mini",
"api_key": "<string>"
}
],
"pre_connect_requests": [
{
"http": {
"url": "https://api.example.com/weather",
"http_method": "POST",
"headers": {}
},
"sends": ["caller_number"],
"returns": [
{
"name": "patient_name",
"path": "patient.first_name",
"default": "there"
}
],
"timeout_ms": 600,
"allow_overrides": ["greeting"]
}
]
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
system_prompt: '<string>',
greeting: '<string>',
input: {
type: 'audio',
format: {encoding: 'audio/pcm', sample_rate: 24000},
turn_detection: {},
keyterms: ['<string>']
},
output: {
type: 'audio',
voice: 'alba',
format: {encoding: 'audio/pcm', sample_rate: 24000},
volume: 123
},
tools: [
{
name: 'get_weather',
description: 'Get current weather for a location. Use whenever the user asks about weather.',
parameters: {
type: 'object',
properties: {
order_id: {
type: 'string',
description: 'The customer\'s order ID.',
examples: ['AB-12345'],
pattern: '[A-Z]{2}-\d{5}'
}
},
required: ['order_id']
},
timeout_seconds: 120,
execution_mode: 'interactive'
}
],
llm: [
{
base_url: 'https://api.openai.com/v1',
model: 'gpt-4o-mini',
api_key: '<string>'
}
],
pre_connect_requests: [
{
http: {url: 'https://api.example.com/weather', http_method: 'POST', headers: {}},
sends: ['caller_number'],
returns: [{name: 'patient_name', path: 'patient.first_name', default: 'there'}],
timeout_ms: 600,
allow_overrides: ['greeting']
}
]
})
};
fetch('https://agents.assemblyai.com/v1/agents/{agent_id}', 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://agents.assemblyai.com/v1/agents/{agent_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'system_prompt' => '<string>',
'greeting' => '<string>',
'input' => [
'type' => 'audio',
'format' => [
'encoding' => 'audio/pcm',
'sample_rate' => 24000
],
'turn_detection' => [
],
'keyterms' => [
'<string>'
]
],
'output' => [
'type' => 'audio',
'voice' => 'alba',
'format' => [
'encoding' => 'audio/pcm',
'sample_rate' => 24000
],
'volume' => 123
],
'tools' => [
[
'name' => 'get_weather',
'description' => 'Get current weather for a location. Use whenever the user asks about weather.',
'parameters' => [
'type' => 'object',
'properties' => [
'order_id' => [
'type' => 'string',
'description' => 'The customer\'s order ID.',
'examples' => [
'AB-12345'
],
'pattern' => '[A-Z]{2}-\\d{5}'
]
],
'required' => [
'order_id'
]
],
'timeout_seconds' => 120,
'execution_mode' => 'interactive'
]
],
'llm' => [
[
'base_url' => 'https://api.openai.com/v1',
'model' => 'gpt-4o-mini',
'api_key' => '<string>'
]
],
'pre_connect_requests' => [
[
'http' => [
'url' => 'https://api.example.com/weather',
'http_method' => 'POST',
'headers' => [
]
],
'sends' => [
'caller_number'
],
'returns' => [
[
'name' => 'patient_name',
'path' => 'patient.first_name',
'default' => 'there'
]
],
'timeout_ms' => 600,
'allow_overrides' => [
'greeting'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <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://agents.assemblyai.com/v1/agents/{agent_id}"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"system_prompt\": \"<string>\",\n \"greeting\": \"<string>\",\n \"input\": {\n \"type\": \"audio\",\n \"format\": {\n \"encoding\": \"audio/pcm\",\n \"sample_rate\": 24000\n },\n \"turn_detection\": {},\n \"keyterms\": [\n \"<string>\"\n ]\n },\n \"output\": {\n \"type\": \"audio\",\n \"voice\": \"alba\",\n \"format\": {\n \"encoding\": \"audio/pcm\",\n \"sample_rate\": 24000\n },\n \"volume\": 123\n },\n \"tools\": [\n {\n \"name\": \"get_weather\",\n \"description\": \"Get current weather for a location. Use whenever the user asks about weather.\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"order_id\": {\n \"type\": \"string\",\n \"description\": \"The customer's order ID.\",\n \"examples\": [\n \"AB-12345\"\n ],\n \"pattern\": \"[A-Z]{2}-\\\\d{5}\"\n }\n },\n \"required\": [\n \"order_id\"\n ]\n },\n \"timeout_seconds\": 120,\n \"execution_mode\": \"interactive\"\n }\n ],\n \"llm\": [\n {\n \"base_url\": \"https://api.openai.com/v1\",\n \"model\": \"gpt-4o-mini\",\n \"api_key\": \"<string>\"\n }\n ],\n \"pre_connect_requests\": [\n {\n \"http\": {\n \"url\": \"https://api.example.com/weather\",\n \"http_method\": \"POST\",\n \"headers\": {}\n },\n \"sends\": [\n \"caller_number\"\n ],\n \"returns\": [\n {\n \"name\": \"patient_name\",\n \"path\": \"patient.first_name\",\n \"default\": \"there\"\n }\n ],\n \"timeout_ms\": 600,\n \"allow_overrides\": [\n \"greeting\"\n ]\n }\n ]\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "<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.put("https://agents.assemblyai.com/v1/agents/{agent_id}")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"system_prompt\": \"<string>\",\n \"greeting\": \"<string>\",\n \"input\": {\n \"type\": \"audio\",\n \"format\": {\n \"encoding\": \"audio/pcm\",\n \"sample_rate\": 24000\n },\n \"turn_detection\": {},\n \"keyterms\": [\n \"<string>\"\n ]\n },\n \"output\": {\n \"type\": \"audio\",\n \"voice\": \"alba\",\n \"format\": {\n \"encoding\": \"audio/pcm\",\n \"sample_rate\": 24000\n },\n \"volume\": 123\n },\n \"tools\": [\n {\n \"name\": \"get_weather\",\n \"description\": \"Get current weather for a location. Use whenever the user asks about weather.\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"order_id\": {\n \"type\": \"string\",\n \"description\": \"The customer's order ID.\",\n \"examples\": [\n \"AB-12345\"\n ],\n \"pattern\": \"[A-Z]{2}-\\\\d{5}\"\n }\n },\n \"required\": [\n \"order_id\"\n ]\n },\n \"timeout_seconds\": 120,\n \"execution_mode\": \"interactive\"\n }\n ],\n \"llm\": [\n {\n \"base_url\": \"https://api.openai.com/v1\",\n \"model\": \"gpt-4o-mini\",\n \"api_key\": \"<string>\"\n }\n ],\n \"pre_connect_requests\": [\n {\n \"http\": {\n \"url\": \"https://api.example.com/weather\",\n \"http_method\": \"POST\",\n \"headers\": {}\n },\n \"sends\": [\n \"caller_number\"\n ],\n \"returns\": [\n {\n \"name\": \"patient_name\",\n \"path\": \"patient.first_name\",\n \"default\": \"there\"\n }\n ],\n \"timeout_ms\": 600,\n \"allow_overrides\": [\n \"greeting\"\n ]\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://agents.assemblyai.com/v1/agents/{agent_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"system_prompt\": \"<string>\",\n \"greeting\": \"<string>\",\n \"input\": {\n \"type\": \"audio\",\n \"format\": {\n \"encoding\": \"audio/pcm\",\n \"sample_rate\": 24000\n },\n \"turn_detection\": {},\n \"keyterms\": [\n \"<string>\"\n ]\n },\n \"output\": {\n \"type\": \"audio\",\n \"voice\": \"alba\",\n \"format\": {\n \"encoding\": \"audio/pcm\",\n \"sample_rate\": 24000\n },\n \"volume\": 123\n },\n \"tools\": [\n {\n \"name\": \"get_weather\",\n \"description\": \"Get current weather for a location. Use whenever the user asks about weather.\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"order_id\": {\n \"type\": \"string\",\n \"description\": \"The customer's order ID.\",\n \"examples\": [\n \"AB-12345\"\n ],\n \"pattern\": \"[A-Z]{2}-\\\\d{5}\"\n }\n },\n \"required\": [\n \"order_id\"\n ]\n },\n \"timeout_seconds\": 120,\n \"execution_mode\": \"interactive\"\n }\n ],\n \"llm\": [\n {\n \"base_url\": \"https://api.openai.com/v1\",\n \"model\": \"gpt-4o-mini\",\n \"api_key\": \"<string>\"\n }\n ],\n \"pre_connect_requests\": [\n {\n \"http\": {\n \"url\": \"https://api.example.com/weather\",\n \"http_method\": \"POST\",\n \"headers\": {}\n },\n \"sends\": [\n \"caller_number\"\n ],\n \"returns\": [\n {\n \"name\": \"patient_name\",\n \"path\": \"patient.first_name\",\n \"default\": \"there\"\n }\n ],\n \"timeout_ms\": 600,\n \"allow_overrides\": [\n \"greeting\"\n ]\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "7ad24396-b822-4dca-871a-be9cc4781cf9",
"name": "Support Assistant",
"system_prompt": "<string>",
"greeting": "<string>",
"voice": {
"voice_id": "alba"
},
"input": {
"type": "audio",
"format": {
"encoding": "audio/pcm",
"sample_rate": 24000
},
"turn_detection": {},
"keyterms": [
"<string>"
]
},
"output": {
"type": "audio",
"voice": "alba",
"format": {
"encoding": "audio/pcm",
"sample_rate": 24000
},
"volume": 123
},
"tools": [
{
"id": "<string>",
"name": "<string>",
"description": "<string>",
"http": {
"url": "<string>",
"http_method": "GET",
"headers": {
"Authorization": "***"
}
},
"parameters": {
"type": "object",
"properties": {
"order_id": {
"type": "string",
"description": "The customer's order ID.",
"examples": [
"AB-12345"
],
"pattern": "[A-Z]{2}-\\d{5}"
}
},
"required": [
"order_id"
]
},
"timeout_seconds": 123,
"execution_mode": "interactive"
}
],
"llm": [
{
"base_url": "https://api.openai.com/v1",
"model": "gpt-4o-mini"
}
],
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"pre_connect_requests": [
{
"http": {
"url": "<string>",
"http_method": "GET",
"headers": {
"Authorization": "***"
}
},
"sends": [
"<string>"
],
"returns": [
{
"name": "patient_name",
"path": "patient.first_name",
"default": "there"
}
],
"timeout_ms": 123,
"allow_overrides": [
"<string>"
]
}
]
}{
"detail": "Unauthorized"
}{
"detail": "Unauthorized"
}{
"detail": "Unauthorized"
}{
"detail": "Unauthorized"
}Endpoints
Update an agent
Update an agent. Every field is optional. Send only the fields you want to change. Returns the updated record.
PUT
/
v1
/
agents
/
{agent_id}
Update an agent
curl --request PUT \
--url https://agents.assemblyai.com/v1/agents/{agent_id} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"name": "<string>",
"system_prompt": "<string>",
"greeting": "<string>",
"input": {
"type": "audio",
"format": {
"encoding": "audio/pcm",
"sample_rate": 24000
},
"turn_detection": {},
"keyterms": [
"<string>"
]
},
"output": {
"type": "audio",
"voice": "alba",
"format": {
"encoding": "audio/pcm",
"sample_rate": 24000
},
"volume": 123
},
"tools": [
{
"name": "get_weather",
"description": "Get current weather for a location. Use whenever the user asks about weather.",
"parameters": {
"type": "object",
"properties": {
"order_id": {
"type": "string",
"description": "The customer's order ID.",
"examples": [
"AB-12345"
],
"pattern": "[A-Z]{2}-\\d{5}"
}
},
"required": [
"order_id"
]
},
"timeout_seconds": 120,
"execution_mode": "interactive"
}
],
"llm": [
{
"base_url": "https://api.openai.com/v1",
"model": "gpt-4o-mini",
"api_key": "<string>"
}
],
"pre_connect_requests": [
{
"http": {
"url": "https://api.example.com/weather",
"http_method": "POST",
"headers": {}
},
"sends": [
"caller_number"
],
"returns": [
{
"name": "patient_name",
"path": "patient.first_name",
"default": "there"
}
],
"timeout_ms": 600,
"allow_overrides": [
"greeting"
]
}
]
}
EOFimport requests
url = "https://agents.assemblyai.com/v1/agents/{agent_id}"
payload = {
"name": "<string>",
"system_prompt": "<string>",
"greeting": "<string>",
"input": {
"type": "audio",
"format": {
"encoding": "audio/pcm",
"sample_rate": 24000
},
"turn_detection": {},
"keyterms": ["<string>"]
},
"output": {
"type": "audio",
"voice": "alba",
"format": {
"encoding": "audio/pcm",
"sample_rate": 24000
},
"volume": 123
},
"tools": [
{
"name": "get_weather",
"description": "Get current weather for a location. Use whenever the user asks about weather.",
"parameters": {
"type": "object",
"properties": { "order_id": {
"type": "string",
"description": "The customer's order ID.",
"examples": ["AB-12345"],
"pattern": "[A-Z]{2}-\d{5}"
} },
"required": ["order_id"]
},
"timeout_seconds": 120,
"execution_mode": "interactive"
}
],
"llm": [
{
"base_url": "https://api.openai.com/v1",
"model": "gpt-4o-mini",
"api_key": "<string>"
}
],
"pre_connect_requests": [
{
"http": {
"url": "https://api.example.com/weather",
"http_method": "POST",
"headers": {}
},
"sends": ["caller_number"],
"returns": [
{
"name": "patient_name",
"path": "patient.first_name",
"default": "there"
}
],
"timeout_ms": 600,
"allow_overrides": ["greeting"]
}
]
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
system_prompt: '<string>',
greeting: '<string>',
input: {
type: 'audio',
format: {encoding: 'audio/pcm', sample_rate: 24000},
turn_detection: {},
keyterms: ['<string>']
},
output: {
type: 'audio',
voice: 'alba',
format: {encoding: 'audio/pcm', sample_rate: 24000},
volume: 123
},
tools: [
{
name: 'get_weather',
description: 'Get current weather for a location. Use whenever the user asks about weather.',
parameters: {
type: 'object',
properties: {
order_id: {
type: 'string',
description: 'The customer\'s order ID.',
examples: ['AB-12345'],
pattern: '[A-Z]{2}-\d{5}'
}
},
required: ['order_id']
},
timeout_seconds: 120,
execution_mode: 'interactive'
}
],
llm: [
{
base_url: 'https://api.openai.com/v1',
model: 'gpt-4o-mini',
api_key: '<string>'
}
],
pre_connect_requests: [
{
http: {url: 'https://api.example.com/weather', http_method: 'POST', headers: {}},
sends: ['caller_number'],
returns: [{name: 'patient_name', path: 'patient.first_name', default: 'there'}],
timeout_ms: 600,
allow_overrides: ['greeting']
}
]
})
};
fetch('https://agents.assemblyai.com/v1/agents/{agent_id}', 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://agents.assemblyai.com/v1/agents/{agent_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'system_prompt' => '<string>',
'greeting' => '<string>',
'input' => [
'type' => 'audio',
'format' => [
'encoding' => 'audio/pcm',
'sample_rate' => 24000
],
'turn_detection' => [
],
'keyterms' => [
'<string>'
]
],
'output' => [
'type' => 'audio',
'voice' => 'alba',
'format' => [
'encoding' => 'audio/pcm',
'sample_rate' => 24000
],
'volume' => 123
],
'tools' => [
[
'name' => 'get_weather',
'description' => 'Get current weather for a location. Use whenever the user asks about weather.',
'parameters' => [
'type' => 'object',
'properties' => [
'order_id' => [
'type' => 'string',
'description' => 'The customer\'s order ID.',
'examples' => [
'AB-12345'
],
'pattern' => '[A-Z]{2}-\\d{5}'
]
],
'required' => [
'order_id'
]
],
'timeout_seconds' => 120,
'execution_mode' => 'interactive'
]
],
'llm' => [
[
'base_url' => 'https://api.openai.com/v1',
'model' => 'gpt-4o-mini',
'api_key' => '<string>'
]
],
'pre_connect_requests' => [
[
'http' => [
'url' => 'https://api.example.com/weather',
'http_method' => 'POST',
'headers' => [
]
],
'sends' => [
'caller_number'
],
'returns' => [
[
'name' => 'patient_name',
'path' => 'patient.first_name',
'default' => 'there'
]
],
'timeout_ms' => 600,
'allow_overrides' => [
'greeting'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <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://agents.assemblyai.com/v1/agents/{agent_id}"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"system_prompt\": \"<string>\",\n \"greeting\": \"<string>\",\n \"input\": {\n \"type\": \"audio\",\n \"format\": {\n \"encoding\": \"audio/pcm\",\n \"sample_rate\": 24000\n },\n \"turn_detection\": {},\n \"keyterms\": [\n \"<string>\"\n ]\n },\n \"output\": {\n \"type\": \"audio\",\n \"voice\": \"alba\",\n \"format\": {\n \"encoding\": \"audio/pcm\",\n \"sample_rate\": 24000\n },\n \"volume\": 123\n },\n \"tools\": [\n {\n \"name\": \"get_weather\",\n \"description\": \"Get current weather for a location. Use whenever the user asks about weather.\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"order_id\": {\n \"type\": \"string\",\n \"description\": \"The customer's order ID.\",\n \"examples\": [\n \"AB-12345\"\n ],\n \"pattern\": \"[A-Z]{2}-\\\\d{5}\"\n }\n },\n \"required\": [\n \"order_id\"\n ]\n },\n \"timeout_seconds\": 120,\n \"execution_mode\": \"interactive\"\n }\n ],\n \"llm\": [\n {\n \"base_url\": \"https://api.openai.com/v1\",\n \"model\": \"gpt-4o-mini\",\n \"api_key\": \"<string>\"\n }\n ],\n \"pre_connect_requests\": [\n {\n \"http\": {\n \"url\": \"https://api.example.com/weather\",\n \"http_method\": \"POST\",\n \"headers\": {}\n },\n \"sends\": [\n \"caller_number\"\n ],\n \"returns\": [\n {\n \"name\": \"patient_name\",\n \"path\": \"patient.first_name\",\n \"default\": \"there\"\n }\n ],\n \"timeout_ms\": 600,\n \"allow_overrides\": [\n \"greeting\"\n ]\n }\n ]\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "<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.put("https://agents.assemblyai.com/v1/agents/{agent_id}")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"system_prompt\": \"<string>\",\n \"greeting\": \"<string>\",\n \"input\": {\n \"type\": \"audio\",\n \"format\": {\n \"encoding\": \"audio/pcm\",\n \"sample_rate\": 24000\n },\n \"turn_detection\": {},\n \"keyterms\": [\n \"<string>\"\n ]\n },\n \"output\": {\n \"type\": \"audio\",\n \"voice\": \"alba\",\n \"format\": {\n \"encoding\": \"audio/pcm\",\n \"sample_rate\": 24000\n },\n \"volume\": 123\n },\n \"tools\": [\n {\n \"name\": \"get_weather\",\n \"description\": \"Get current weather for a location. Use whenever the user asks about weather.\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"order_id\": {\n \"type\": \"string\",\n \"description\": \"The customer's order ID.\",\n \"examples\": [\n \"AB-12345\"\n ],\n \"pattern\": \"[A-Z]{2}-\\\\d{5}\"\n }\n },\n \"required\": [\n \"order_id\"\n ]\n },\n \"timeout_seconds\": 120,\n \"execution_mode\": \"interactive\"\n }\n ],\n \"llm\": [\n {\n \"base_url\": \"https://api.openai.com/v1\",\n \"model\": \"gpt-4o-mini\",\n \"api_key\": \"<string>\"\n }\n ],\n \"pre_connect_requests\": [\n {\n \"http\": {\n \"url\": \"https://api.example.com/weather\",\n \"http_method\": \"POST\",\n \"headers\": {}\n },\n \"sends\": [\n \"caller_number\"\n ],\n \"returns\": [\n {\n \"name\": \"patient_name\",\n \"path\": \"patient.first_name\",\n \"default\": \"there\"\n }\n ],\n \"timeout_ms\": 600,\n \"allow_overrides\": [\n \"greeting\"\n ]\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://agents.assemblyai.com/v1/agents/{agent_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"system_prompt\": \"<string>\",\n \"greeting\": \"<string>\",\n \"input\": {\n \"type\": \"audio\",\n \"format\": {\n \"encoding\": \"audio/pcm\",\n \"sample_rate\": 24000\n },\n \"turn_detection\": {},\n \"keyterms\": [\n \"<string>\"\n ]\n },\n \"output\": {\n \"type\": \"audio\",\n \"voice\": \"alba\",\n \"format\": {\n \"encoding\": \"audio/pcm\",\n \"sample_rate\": 24000\n },\n \"volume\": 123\n },\n \"tools\": [\n {\n \"name\": \"get_weather\",\n \"description\": \"Get current weather for a location. Use whenever the user asks about weather.\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"order_id\": {\n \"type\": \"string\",\n \"description\": \"The customer's order ID.\",\n \"examples\": [\n \"AB-12345\"\n ],\n \"pattern\": \"[A-Z]{2}-\\\\d{5}\"\n }\n },\n \"required\": [\n \"order_id\"\n ]\n },\n \"timeout_seconds\": 120,\n \"execution_mode\": \"interactive\"\n }\n ],\n \"llm\": [\n {\n \"base_url\": \"https://api.openai.com/v1\",\n \"model\": \"gpt-4o-mini\",\n \"api_key\": \"<string>\"\n }\n ],\n \"pre_connect_requests\": [\n {\n \"http\": {\n \"url\": \"https://api.example.com/weather\",\n \"http_method\": \"POST\",\n \"headers\": {}\n },\n \"sends\": [\n \"caller_number\"\n ],\n \"returns\": [\n {\n \"name\": \"patient_name\",\n \"path\": \"patient.first_name\",\n \"default\": \"there\"\n }\n ],\n \"timeout_ms\": 600,\n \"allow_overrides\": [\n \"greeting\"\n ]\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "7ad24396-b822-4dca-871a-be9cc4781cf9",
"name": "Support Assistant",
"system_prompt": "<string>",
"greeting": "<string>",
"voice": {
"voice_id": "alba"
},
"input": {
"type": "audio",
"format": {
"encoding": "audio/pcm",
"sample_rate": 24000
},
"turn_detection": {},
"keyterms": [
"<string>"
]
},
"output": {
"type": "audio",
"voice": "alba",
"format": {
"encoding": "audio/pcm",
"sample_rate": 24000
},
"volume": 123
},
"tools": [
{
"id": "<string>",
"name": "<string>",
"description": "<string>",
"http": {
"url": "<string>",
"http_method": "GET",
"headers": {
"Authorization": "***"
}
},
"parameters": {
"type": "object",
"properties": {
"order_id": {
"type": "string",
"description": "The customer's order ID.",
"examples": [
"AB-12345"
],
"pattern": "[A-Z]{2}-\\d{5}"
}
},
"required": [
"order_id"
]
},
"timeout_seconds": 123,
"execution_mode": "interactive"
}
],
"llm": [
{
"base_url": "https://api.openai.com/v1",
"model": "gpt-4o-mini"
}
],
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"pre_connect_requests": [
{
"http": {
"url": "<string>",
"http_method": "GET",
"headers": {
"Authorization": "***"
}
},
"sends": [
"<string>"
],
"returns": [
{
"name": "patient_name",
"path": "patient.first_name",
"default": "there"
}
],
"timeout_ms": 123,
"allow_overrides": [
"<string>"
]
}
]
}{
"detail": "Unauthorized"
}{
"detail": "Unauthorized"
}{
"detail": "Unauthorized"
}{
"detail": "Unauthorized"
}Authorizations
Path Parameters
Body
application/json
Same shape as the create request, but every field is optional. Send only what changes.
Response
The updated agent record.
A stored voice agent.
Was this page helpful?