Upload Contacts CSV
curl --request POST \
--url https://agents.labs.bandwidth.com/api/v1/s3/presigned-upload-url \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"file_name": "<string>",
"file_size": 123,
"content_type": "text/csv"
}
'import requests
url = "https://agents.labs.bandwidth.com/api/v1/s3/presigned-upload-url"
payload = {
"file_name": "<string>",
"file_size": 123,
"content_type": "text/csv"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({file_name: '<string>', file_size: 123, content_type: 'text/csv'})
};
fetch('https://agents.labs.bandwidth.com/api/v1/s3/presigned-upload-url', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://agents.labs.bandwidth.com/api/v1/s3/presigned-upload-url",
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([
'file_name' => '<string>',
'file_size' => 123,
'content_type' => 'text/csv'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://agents.labs.bandwidth.com/api/v1/s3/presigned-upload-url"
payload := strings.NewReader("{\n \"file_name\": \"<string>\",\n \"file_size\": 123,\n \"content_type\": \"text/csv\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://agents.labs.bandwidth.com/api/v1/s3/presigned-upload-url")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"file_name\": \"<string>\",\n \"file_size\": 123,\n \"content_type\": \"text/csv\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://agents.labs.bandwidth.com/api/v1/s3/presigned-upload-url")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"file_name\": \"<string>\",\n \"file_size\": 123,\n \"content_type\": \"text/csv\"\n}"
response = http.request(request)
puts response.read_body{
"upload_url": "<string>",
"file_key": "<string>",
"expires_in": 123
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Campaigns
Upload Contacts CSV
Get a temporary upload URL to upload a contacts CSV for a campaign
POST
/
api
/
v1
/
s3
/
presigned-upload-url
Upload Contacts CSV
curl --request POST \
--url https://agents.labs.bandwidth.com/api/v1/s3/presigned-upload-url \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"file_name": "<string>",
"file_size": 123,
"content_type": "text/csv"
}
'import requests
url = "https://agents.labs.bandwidth.com/api/v1/s3/presigned-upload-url"
payload = {
"file_name": "<string>",
"file_size": 123,
"content_type": "text/csv"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({file_name: '<string>', file_size: 123, content_type: 'text/csv'})
};
fetch('https://agents.labs.bandwidth.com/api/v1/s3/presigned-upload-url', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://agents.labs.bandwidth.com/api/v1/s3/presigned-upload-url",
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([
'file_name' => '<string>',
'file_size' => 123,
'content_type' => 'text/csv'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://agents.labs.bandwidth.com/api/v1/s3/presigned-upload-url"
payload := strings.NewReader("{\n \"file_name\": \"<string>\",\n \"file_size\": 123,\n \"content_type\": \"text/csv\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://agents.labs.bandwidth.com/api/v1/s3/presigned-upload-url")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"file_name\": \"<string>\",\n \"file_size\": 123,\n \"content_type\": \"text/csv\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://agents.labs.bandwidth.com/api/v1/s3/presigned-upload-url")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"file_name\": \"<string>\",\n \"file_size\": 123,\n \"content_type\": \"text/csv\"\n}"
response = http.request(request)
puts response.read_body{
"upload_url": "<string>",
"file_key": "<string>",
"expires_in": 123
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Request an upload URL with
Set
file_name, the actual file_size in bytes, and content_type: "text/csv". The CSV must be non-empty and at most 10 MB.
The response contains upload_url, file_key, and expires_in. PUT your file to upload_url with the same content type; do not send your workspace API key to the upload URL.
curl --fail-with-body --request PUT "${UPLOAD_URL}" \
-H 'Content-Type: text/csv' \
--data-binary @contacts.csv
UPLOAD_URL to the returned URL and upload before it expires. After a successful upload, use file_key as source_id with source_type: "csv" when creating the campaign.
The file must include a phone_number column. Extra columns become initial context:
phone_number,customer_name,plan
+14155550100,Jane Smith,premium
Authorizations
LabsAuthLabsApiKey
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Headers
Body
application/json