curl --request POST \
--url https://api.tryhamsa.com/v2/voice-agents/web-tool \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"type": "FUNCTION",
"name": "Get Weather Data",
"description": "Fetches current weather data for a given location",
"collectionId": "48f7656f-098b-4c43-b165-7cfd2cc8ac30",
"async": false,
"messages": [
{
"type": "REQUEST_START",
"content": "Fetching weather data..."
}
],
"params": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city name to get weather for"
},
"units": {
"type": "string",
"description": "Temperature units",
"enum": [
"celsius",
"fahrenheit"
]
}
},
"required": [
"location"
]
}
}
'import requests
url = "https://api.tryhamsa.com/v2/voice-agents/web-tool"
payload = {
"type": "FUNCTION",
"name": "Get Weather Data",
"description": "Fetches current weather data for a given location",
"collectionId": "48f7656f-098b-4c43-b165-7cfd2cc8ac30",
"async": False,
"messages": [
{
"type": "REQUEST_START",
"content": "Fetching weather data..."
}
],
"params": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city name to get weather for"
},
"units": {
"type": "string",
"description": "Temperature units",
"enum": ["celsius", "fahrenheit"]
}
},
"required": ["location"]
}
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
type: 'FUNCTION',
name: 'Get Weather Data',
description: 'Fetches current weather data for a given location',
collectionId: '48f7656f-098b-4c43-b165-7cfd2cc8ac30',
async: false,
messages: [{type: 'REQUEST_START', content: 'Fetching weather data...'}],
params: {
type: 'object',
properties: {
location: {type: 'string', description: 'The city name to get weather for'},
units: {
type: 'string',
description: 'Temperature units',
enum: ['celsius', 'fahrenheit']
}
},
required: ['location']
}
})
};
fetch('https://api.tryhamsa.com/v2/voice-agents/web-tool', 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.tryhamsa.com/v2/voice-agents/web-tool",
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([
'type' => 'FUNCTION',
'name' => 'Get Weather Data',
'description' => 'Fetches current weather data for a given location',
'collectionId' => '48f7656f-098b-4c43-b165-7cfd2cc8ac30',
'async' => false,
'messages' => [
[
'type' => 'REQUEST_START',
'content' => 'Fetching weather data...'
]
],
'params' => [
'type' => 'object',
'properties' => [
'location' => [
'type' => 'string',
'description' => 'The city name to get weather for'
],
'units' => [
'type' => 'string',
'description' => 'Temperature units',
'enum' => [
'celsius',
'fahrenheit'
]
]
],
'required' => [
'location'
]
]
]),
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://api.tryhamsa.com/v2/voice-agents/web-tool"
payload := strings.NewReader("{\n \"type\": \"FUNCTION\",\n \"name\": \"Get Weather Data\",\n \"description\": \"Fetches current weather data for a given location\",\n \"collectionId\": \"48f7656f-098b-4c43-b165-7cfd2cc8ac30\",\n \"async\": false,\n \"messages\": [\n {\n \"type\": \"REQUEST_START\",\n \"content\": \"Fetching weather data...\"\n }\n ],\n \"params\": {\n \"type\": \"object\",\n \"properties\": {\n \"location\": {\n \"type\": \"string\",\n \"description\": \"The city name to get weather for\"\n },\n \"units\": {\n \"type\": \"string\",\n \"description\": \"Temperature units\",\n \"enum\": [\n \"celsius\",\n \"fahrenheit\"\n ]\n }\n },\n \"required\": [\n \"location\"\n ]\n }\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.tryhamsa.com/v2/voice-agents/web-tool")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"type\": \"FUNCTION\",\n \"name\": \"Get Weather Data\",\n \"description\": \"Fetches current weather data for a given location\",\n \"collectionId\": \"48f7656f-098b-4c43-b165-7cfd2cc8ac30\",\n \"async\": false,\n \"messages\": [\n {\n \"type\": \"REQUEST_START\",\n \"content\": \"Fetching weather data...\"\n }\n ],\n \"params\": {\n \"type\": \"object\",\n \"properties\": {\n \"location\": {\n \"type\": \"string\",\n \"description\": \"The city name to get weather for\"\n },\n \"units\": {\n \"type\": \"string\",\n \"description\": \"Temperature units\",\n \"enum\": [\n \"celsius\",\n \"fahrenheit\"\n ]\n }\n },\n \"required\": [\n \"location\"\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tryhamsa.com/v2/voice-agents/web-tool")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"type\": \"FUNCTION\",\n \"name\": \"Get Weather Data\",\n \"description\": \"Fetches current weather data for a given location\",\n \"collectionId\": \"48f7656f-098b-4c43-b165-7cfd2cc8ac30\",\n \"async\": false,\n \"messages\": [\n {\n \"type\": \"REQUEST_START\",\n \"content\": \"Fetching weather data...\"\n }\n ],\n \"params\": {\n \"type\": \"object\",\n \"properties\": {\n \"location\": {\n \"type\": \"string\",\n \"description\": \"The city name to get weather for\"\n },\n \"units\": {\n \"type\": \"string\",\n \"description\": \"Temperature units\",\n \"enum\": [\n \"celsius\",\n \"fahrenheit\"\n ]\n }\n },\n \"required\": [\n \"location\"\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Web tool created successfully",
"messageKey": "WebToolCreatedSuccessfully",
"data": {
"id": "48f7656f-098b-4c43-b165-7cfd2cc8ac30",
"persistentId": "48f7656f-098b-4c43-b165-7cfd2cc8ac30",
"version": 1,
"name": "Get Weather Data",
"type": "FUNCTION",
"userId": "48f7656f-098b-4c43-b165-7cfd2cc8ac30",
"projectId": "48f7656f-098b-4c43-b165-7cfd2cc8ac30",
"isActive": true,
"async": false,
"description": "Fetches current weather data for a given location",
"collectionId": "48f7656f-098b-4c43-b165-7cfd2cc8ac30",
"toolSettings": {
"httpHeaders": {},
"pathParameters": {},
"serverUrl": "<string>",
"timeout": 123,
"authToken": "<string>",
"methodType": "<string>"
},
"params": {},
"messages": [
{
"type": "REQUEST_START",
"content": "Fetching weather data..."
}
]
}
}{
"code": 123,
"message": "<string>"
}{
"code": 123,
"message": "<string>"
}{
"code": 123,
"message": "<string>"
}Create Web Tool
Creates a new web tool for a project. Web tools can be of type FUNCTION, MCP, or WEB_TOOL.
curl --request POST \
--url https://api.tryhamsa.com/v2/voice-agents/web-tool \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"type": "FUNCTION",
"name": "Get Weather Data",
"description": "Fetches current weather data for a given location",
"collectionId": "48f7656f-098b-4c43-b165-7cfd2cc8ac30",
"async": false,
"messages": [
{
"type": "REQUEST_START",
"content": "Fetching weather data..."
}
],
"params": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city name to get weather for"
},
"units": {
"type": "string",
"description": "Temperature units",
"enum": [
"celsius",
"fahrenheit"
]
}
},
"required": [
"location"
]
}
}
'import requests
url = "https://api.tryhamsa.com/v2/voice-agents/web-tool"
payload = {
"type": "FUNCTION",
"name": "Get Weather Data",
"description": "Fetches current weather data for a given location",
"collectionId": "48f7656f-098b-4c43-b165-7cfd2cc8ac30",
"async": False,
"messages": [
{
"type": "REQUEST_START",
"content": "Fetching weather data..."
}
],
"params": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city name to get weather for"
},
"units": {
"type": "string",
"description": "Temperature units",
"enum": ["celsius", "fahrenheit"]
}
},
"required": ["location"]
}
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
type: 'FUNCTION',
name: 'Get Weather Data',
description: 'Fetches current weather data for a given location',
collectionId: '48f7656f-098b-4c43-b165-7cfd2cc8ac30',
async: false,
messages: [{type: 'REQUEST_START', content: 'Fetching weather data...'}],
params: {
type: 'object',
properties: {
location: {type: 'string', description: 'The city name to get weather for'},
units: {
type: 'string',
description: 'Temperature units',
enum: ['celsius', 'fahrenheit']
}
},
required: ['location']
}
})
};
fetch('https://api.tryhamsa.com/v2/voice-agents/web-tool', 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.tryhamsa.com/v2/voice-agents/web-tool",
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([
'type' => 'FUNCTION',
'name' => 'Get Weather Data',
'description' => 'Fetches current weather data for a given location',
'collectionId' => '48f7656f-098b-4c43-b165-7cfd2cc8ac30',
'async' => false,
'messages' => [
[
'type' => 'REQUEST_START',
'content' => 'Fetching weather data...'
]
],
'params' => [
'type' => 'object',
'properties' => [
'location' => [
'type' => 'string',
'description' => 'The city name to get weather for'
],
'units' => [
'type' => 'string',
'description' => 'Temperature units',
'enum' => [
'celsius',
'fahrenheit'
]
]
],
'required' => [
'location'
]
]
]),
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://api.tryhamsa.com/v2/voice-agents/web-tool"
payload := strings.NewReader("{\n \"type\": \"FUNCTION\",\n \"name\": \"Get Weather Data\",\n \"description\": \"Fetches current weather data for a given location\",\n \"collectionId\": \"48f7656f-098b-4c43-b165-7cfd2cc8ac30\",\n \"async\": false,\n \"messages\": [\n {\n \"type\": \"REQUEST_START\",\n \"content\": \"Fetching weather data...\"\n }\n ],\n \"params\": {\n \"type\": \"object\",\n \"properties\": {\n \"location\": {\n \"type\": \"string\",\n \"description\": \"The city name to get weather for\"\n },\n \"units\": {\n \"type\": \"string\",\n \"description\": \"Temperature units\",\n \"enum\": [\n \"celsius\",\n \"fahrenheit\"\n ]\n }\n },\n \"required\": [\n \"location\"\n ]\n }\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.tryhamsa.com/v2/voice-agents/web-tool")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"type\": \"FUNCTION\",\n \"name\": \"Get Weather Data\",\n \"description\": \"Fetches current weather data for a given location\",\n \"collectionId\": \"48f7656f-098b-4c43-b165-7cfd2cc8ac30\",\n \"async\": false,\n \"messages\": [\n {\n \"type\": \"REQUEST_START\",\n \"content\": \"Fetching weather data...\"\n }\n ],\n \"params\": {\n \"type\": \"object\",\n \"properties\": {\n \"location\": {\n \"type\": \"string\",\n \"description\": \"The city name to get weather for\"\n },\n \"units\": {\n \"type\": \"string\",\n \"description\": \"Temperature units\",\n \"enum\": [\n \"celsius\",\n \"fahrenheit\"\n ]\n }\n },\n \"required\": [\n \"location\"\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tryhamsa.com/v2/voice-agents/web-tool")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"type\": \"FUNCTION\",\n \"name\": \"Get Weather Data\",\n \"description\": \"Fetches current weather data for a given location\",\n \"collectionId\": \"48f7656f-098b-4c43-b165-7cfd2cc8ac30\",\n \"async\": false,\n \"messages\": [\n {\n \"type\": \"REQUEST_START\",\n \"content\": \"Fetching weather data...\"\n }\n ],\n \"params\": {\n \"type\": \"object\",\n \"properties\": {\n \"location\": {\n \"type\": \"string\",\n \"description\": \"The city name to get weather for\"\n },\n \"units\": {\n \"type\": \"string\",\n \"description\": \"Temperature units\",\n \"enum\": [\n \"celsius\",\n \"fahrenheit\"\n ]\n }\n },\n \"required\": [\n \"location\"\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Web tool created successfully",
"messageKey": "WebToolCreatedSuccessfully",
"data": {
"id": "48f7656f-098b-4c43-b165-7cfd2cc8ac30",
"persistentId": "48f7656f-098b-4c43-b165-7cfd2cc8ac30",
"version": 1,
"name": "Get Weather Data",
"type": "FUNCTION",
"userId": "48f7656f-098b-4c43-b165-7cfd2cc8ac30",
"projectId": "48f7656f-098b-4c43-b165-7cfd2cc8ac30",
"isActive": true,
"async": false,
"description": "Fetches current weather data for a given location",
"collectionId": "48f7656f-098b-4c43-b165-7cfd2cc8ac30",
"toolSettings": {
"httpHeaders": {},
"pathParameters": {},
"serverUrl": "<string>",
"timeout": 123,
"authToken": "<string>",
"methodType": "<string>"
},
"params": {},
"messages": [
{
"type": "REQUEST_START",
"content": "Fetching weather data..."
}
]
}
}{
"code": 123,
"message": "<string>"
}{
"code": 123,
"message": "<string>"
}{
"code": 123,
"message": "<string>"
}Authorizations
Pass the API key in the Authorization header, You need to put Token keyword before the API key. e.g. 'Authorization: Token '
Body
The type of web tool to create
FUNCTION, MCP, WEB_TOOL "FUNCTION"
The name of the web tool
250"Get Weather Data"
A description of what the web tool does
1000"Fetches current weather data for a given location"
Optional collection ID to group the web tool
"48f7656f-098b-4c43-b165-7cfd2cc8ac30"
Whether the tool runs asynchronously. Required for FUNCTION type, not allowed for MCP type.
false
Server configuration for the web tool. Required for FUNCTION and MCP types, not allowed for WEB_TOOL type.
Show child attributes
Show child attributes
Messages to display during tool execution
Show child attributes
Show child attributes
OpenAPI-style schema defining the parameters for the web tool. Not allowed for MCP type.
Show child attributes
Show child attributes
Was this page helpful?