<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cartesia.ai/v1/agents/tools",
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' => 'webhook',
'name' => 'lookup_customer',
'description' => 'Look up the caller to find their customer details.',
'pre_tool_speech' => 'auto',
'execution_mode' => 'immediate',
'api_schema' => [
'url' => 'https://api.example.com/customers/lookup',
'method' => 'GET',
'query_params_schema' => [
'properties' => [
'phone_number' => [
'type' => 'string',
'dynamic_variable' => 'system__caller_id'
]
]
]
],
'assignments' => [
[
'dynamic_variable' => 'customer_name',
'value_path' => 'customer.name'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Cartesia-Version: <cartesia-version>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}