Vapi
09/27/2024, 6:42 PMpython
import requests
# Your Vapi API Authorization token
auth_token = 'your_auth_token_here'
# The Phone Number ID, and the Customer details for the call
phone_number_id = 'your_phone_number_id_here'
customer_number = "+14151231234" # Replace with the customer's phone number
# Create the header with Authorization token
headers = {
'Authorization': f'Bearer {auth_token}',
}
# The API endpoint for creating an outbound call
api_endpoint = 'https://api.vapi.com/outbound_calls'
# The payload with the details of the call
payload = {
'phone_number_id': phone_number_id,
'to': customer_number,
'answer_url': 'https://yourdomain.com/answer_url', # Replace with your answer URL
}
# Make the POST request to the API to initiate the call
response = requests.post(api_endpoint, headers=headers, json=payload)
# Check the response
if response.status_code == 200:
print("Call initiated successfully.")
else:
print(f"Failed to initiate call. Status code: {response.status_code}, Response: {response.text}")
Make sure to replace 'your_auth_token_here'
, 'your_phone_number_id_here'
, and 'https://yourdomain.com/answer_url'
with your actual VAPI API authorization token, your phone number ID, and the URL that provides the call flow instructions (answer URL), respectively.
If you have any further questions or need additional assistance, please let me know!Vapi
09/27/2024, 6:42 PM