Initiate a Call
Trigger a single outbound call using a published assistant. Calls are non-blocking — the API returns immediately once the call is queued.
curl -X POST "https://api.twentytwo.in/api/agent/trigger-outbound-call" \
-H "Content-Type: application/json" \
-H "x-workspace-id: 69b671241b2dacf0c0f15885" \
-H "Authorization: Basic YOUR_CREDENTIALS" \
-d '{
"agent_id": "69de483c68b23495c853b43a",
"callee_phone": "9999999999",
"caller_phone": "9999999999",
"input_parameters": {
"agentName": "Rohit"
}
}'
import requests
import json
url = "https://api.twentytwo.in/api/agent/trigger-outbound-call"
headers = {
"Content-Type": "application/json",
"x-workspace-id": "69b671241b2dacf0c0f15885",
"Authorization": "Basic YOUR_CREDENTIALS"
}
data = {
"agent_id": "69de483c68b23495c853b43a",
"callee_phone": "9999999999",
"caller_phone": "9999999999",
"input_parameters": {
"agentName": "Rohit"
}
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
const response = await fetch("https://api.twentytwo.in/api/agent/trigger-outbound-call", {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-workspace-id": "69b671241b2dacf0c0f15885",
"Authorization": "Basic YOUR_CREDENTIALS"
},
body: JSON.stringify({
"agent_id": "69de483c68b23495c853b43a",
"callee_phone": "9999999999",
"caller_phone": "9999999999",
"input_parameters": {
"agentName": "Rohit"
}
})
});
const data = await response.json();
console.log(data);
package main
import (
"fmt"
"net/http"
"bytes"
"encoding/json"
)
func main() {
data := []byte(`{
"agent_id": "69de483c68b23495c853b43a",
"callee_phone": "9999999999",
"caller_phone": "9999999999",
"input_parameters": {
"agentName": "Rohit"
}
}`)
req, err := http.NewRequest("POST", "https://api.twentytwo.in/api/agent/trigger-outbound-call", bytes.NewBuffer(data))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("x-workspace-id", "69b671241b2dacf0c0f15885")
req.Header.Set("Authorization", "Basic YOUR_CREDENTIALS")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("Response Status:", resp.Status)
}
require 'net/http'
require 'json'
uri = URI('https://api.twentytwo.in/api/agent/trigger-outbound-call')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Content-Type'] = 'application/json'
request['x-workspace-id'] = '69b671241b2dacf0c0f15885'
request['Authorization'] = 'Basic YOUR_CREDENTIALS'
request.body = '{
"agent_id": "69de483c68b23495c853b43a",
"callee_phone": "9999999999",
"caller_phone": "9999999999",
"input_parameters": {
"agentName": "Rohit"
}
}'
response = http.request(request)
puts response.body
{
"success": true,
"call_id": "call_9c4d7e12ab",
"status": "initiated",
"message": "Call queued successfully."
}
{
"success": false,
"error": {
"code": "INVALID_AGENT",
"message": "The agent_id provided does not exist or is not published.",
"status": 400
}
}
{
"success": false,
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid or missing credentials.",
"status": 401
}
}
/agent/trigger-outbound-call
Username for basic authentication
Password for basic authentication
The media type of the request body
Your Twenty2 workspace ID
The ID of the published agent to use for the call.
The phone number to call (recipient), without country code.
The phone number to call from, without country code. Must be active in your Twenty2 workspace.
Key-value pairs to pass into the agent's script at runtime. Keys must match the input parameters defined on the agent.
Request Preview
Response
Response will appear here after sending the request
Authentication
Basic authentication credentials. Pass your Basic auth token in the Authorization header along with your workspace ID in the x-workspace-id header on every request.
Headers
Your Twenty2 workspace ID
Body
The ID of the published agent to use for the call.
The phone number to call (recipient), without country code.
The phone number to call from, without country code. Must be active in your Twenty2 workspace.
Key-value pairs to pass into the agent's script at runtime. Keys must match the input parameters defined on the agent.
Responses
Last updated 2 weeks ago
Built with Documentation.AI