how to create an outbound call with the api
# support
v
@redafrogames Certainly! To create an outbound call using the VAPI, you'll need to write a script in Python. Here's a sample code snippet that you can use as a starting point:
Copy code
python
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!
You can continue this conversation by mentioning me in the message.
47 Views