Outbound Call Campaign
# support
d
When I create an outbound campaign through the dashboard, I am able to upload a CSV file, but it is not possible through the code. Why is this happening? Can anyone help? It’s urgent.
@Vapi Support Bot @Vapi @User @User
v
CSV upload is only supported in the dashboard UI for convenience. To achieve the same via code, read your CSV file, convert it to a JSON array of customers, and pass it to the API. For example (in Python):
Copy code
python
import csv, requests

with open('customers.csv') as f:
    customers = [{"number": row["number"]} for row in csv.DictReader(f)]
payload = {
    "assistantId": "your-assistant-id",
    "phoneNumberId": "your-phone-number-id",
    "customers": customers
}
requests.post("https://api.vapi.ai/call", json=payload, headers={"Authorization": "Bearer YOUR_TOKEN"})
This lets you run batch campaigns programmatically, matching the dashboard's functionality. [See docs for batch calling](https://docs.vapi.ai/calls/outbound-calling#batch-calling) Source: - [Outbound Calling Documentation](https://docs.vapi.ai/calls/outbound-calling)
Thanks for your question! To clarify, are you looking for a way to upload a CSV file directly via the API/code, or would converting your CSV data to a JSON array (as required by the API for batch calls) work for your use case? This will help me guide you to the best solution. Source: - [Outbound Calling Documentation](https://docs.vapi.ai/calls/outbound-calling)
d
I want to upload the csv file
Because in csv file I can add dynamic Variables like name , notes for each person specifically.
I want these dynamic things
@Kyle
@Shubham Bajaj
Please Help Its urgent
t
Most likely you can create a workflow on make.com that converts your csv into JSON and calls on batch as you requested.
d
But I do not want to use any other tool like make.com for it.
c
Based on what you shared, it looks like you're able to upload a CSV file through the dashboard but are having issues when trying to do it via code. This can sometimes happen due to differences in how the systems handle file uploads. Could you let me know what error message or behavior you’re seeing when you try to upload via code? This info would help us figure it out quicker.
d
I cannot find any way to upload the CSV file via code to start campaign. Do you have any sample code available?
d
I think there might be a confusion. I am asking asking about how to upload csv with code for outbound campaign.
c
To upload a CSV for your outbound campaign, you can follow these steps: 1. Go to the "Campaigns" section in your dashboard. 2. Select the outbound campaign you want to work with. 3. Look for the option to upload your CSV file — it’s usually labeled as "Upload Contacts" or something similar. 4. Follow the prompts to select your CSV file and upload it. Make sure your CSV is formatted correctly to avoid any issues. If you have any questions about the format, feel free to ask.
d
I want this using python code.
c
You can use this:
Copy code
from vapi import CreateCustomerDto, Vapi

client = Vapi(
    token="YOUR_TOKEN",
)
client.campaigns.campaign_controller_create(
    name="Q2 Sales Campaign",
    phone_number_id="phoneNumberId",
    customers=[CreateCustomerDto()],
)
Here is the documentation:
2 Views