making call- structureddata in API
# support
s
Are there any examples of how I can create structured data when calling my API to make a call please?
v
@soc86 Certainly! Structured data is typically used to organize and provide information in a way that is easily understood by APIs. When creating structured data for an API call, you would define it in a format such as JSON, which is a common data interchange format. Here's a simple example of how you might structure data for an API call to make a phone call:
Copy code
json
{
  "phoneNumber": "+1234567890",
  "message": "Hello, this is a test call from our service.",
  "callDuration": 30,
  "callerId": "+0987654321"
}
In this example, the structured data includes: - `phoneNumber`: The phone number you want to call. - `message`: The pre-recorded message or text-to-speech message to be delivered. - `callDuration`: The maximum duration of the call in seconds. - `callerId`: The phone number that will be displayed as the caller. When you send this structured data to your API, the API will use these details to make the call according to your specifications. Make sure to follow the schema required by your specific API for the call to be successful. If you need to know how to implement this in code or have any other questions, please let me know!
You can continue this conversation by mentioning me in the message.
s
Can you elaborate?
s
Hi @Sahil , yes I'm trying to add some call analysis when making a call, but I can't seem to make this work within my php code? { "structuredDataSchema": { "type": "object", "properties": { "field1": { "type": "string" }, "field2": { "type": "number" } }, "required": ["field1", "field2"] } }
s
Can you send me a curl request command?
s
$curl = curl_init(); curl_setopt_array($curl, [ CURLOPT_URL => "https://api.vapi.ai/call/phone", 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($data), CURLOPT_HTTPHEADER => [ "Authorization: Bearer "####", "Content-Type: application/json" ], ]); $response = curl_exec($curl); $results = json_decode($response, true);
s
Can you send me in this format, so that I can directly test it out? curl -X POST -H 'Content-type: application/json' --data '{"text":"Hello, World!"}' https://api.vapi.ai/call/phone
6 Views