curl --request POST \
--url https://api.lehar.ai/ca/api/v0/campaigns/{campaign_id}/recipients/import \
--header 'Content-Type: multipart/form-data' \
--header 'X-API-KEY: <api-key>' \
--form file='@example-file'import requests
url = "https://api.lehar.ai/ca/api/v0/campaigns/{campaign_id}/recipients/import"
files = { "file": ("example-file", open("example-file", "rb")) }
headers = {"X-API-KEY": "<api-key>"}
response = requests.post(url, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
const options = {method: 'POST', headers: {'X-API-KEY': '<api-key>'}};
options.body = form;
fetch('https://api.lehar.ai/ca/api/v0/campaigns/{campaign_id}/recipients/import', 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://api.lehar.ai/ca/api/v0/campaigns/{campaign_id}/recipients/import",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Content-Type: multipart/form-data",
"X-API-KEY: <api-key>"
],
]);
$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://api.lehar.ai/ca/api/v0/campaigns/{campaign_id}/recipients/import"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.lehar.ai/ca/api/v0/campaigns/{campaign_id}/recipients/import")
.header("X-API-KEY", "<api-key>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lehar.ai/ca/api/v0/campaigns/{campaign_id}/recipients/import")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"import": {
"id": "cimport_01EXAMPLE",
"campaign_id": "campaign_01EXAMPLE",
"filename": "contacts.csv",
"source_uri": null,
"status": "completed_with_errors",
"total_rows": 3,
"accepted_rows": 2,
"rejected_rows": 1,
"errors": [
{
"row": 4,
"error": "phone_number looks like a spreadsheet auto-converted it to a number (for example 9.19911E+11). Re-enter it as text, keeping the leading + and country code, for example +911234567890.",
"value": "9.19911E+11"
}
],
"metadata": {
"content_type": "text/csv"
},
"created_at": "2026-05-22T10:10:00Z",
"completed_at": "2026-05-22T10:10:01Z"
},
"recipients": [
{
"id": "recipient_01EXAMPLE",
"campaign_id": "campaign_01EXAMPLE",
"phone_number_masked": "+9***3210",
"status": "pending",
"variables": {
"callee_name": "Jane",
"company": "Acme"
},
"whatsapp_context": {},
"outcome": {},
"answers": {},
"qualification_status": null,
"sentiment": null,
"next_action_at": null,
"last_customer_message_at": null,
"service_window_expires_at": null,
"created_at": "2026-05-22T10:10:00Z",
"updated_at": "2026-05-22T10:10:00Z"
}
]
}{
"error": {
"code": "invalid_request",
"message": "The file must be a UTF-8 CSV or an .xlsx spreadsheet"
}
}Import recipients (CSV/XLSX)
Bulk-add recipients by uploading a CSV or .xlsx file (multipart/form-data, field file, max 5 MB). The sheet must have a header row with a phone column named phone_number, phone, mobile, or number; every other column becomes a per-recipient variable for prompt placeholders. Unlike POST /recipients (strict JSON), the import is lenient — valid rows are added and invalid rows are reported per-row rather than failing the whole file. Recipients are deduplicated per (campaign, phone). Scope campaigns:write.
curl --request POST \
--url https://api.lehar.ai/ca/api/v0/campaigns/{campaign_id}/recipients/import \
--header 'Content-Type: multipart/form-data' \
--header 'X-API-KEY: <api-key>' \
--form file='@example-file'import requests
url = "https://api.lehar.ai/ca/api/v0/campaigns/{campaign_id}/recipients/import"
files = { "file": ("example-file", open("example-file", "rb")) }
headers = {"X-API-KEY": "<api-key>"}
response = requests.post(url, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
const options = {method: 'POST', headers: {'X-API-KEY': '<api-key>'}};
options.body = form;
fetch('https://api.lehar.ai/ca/api/v0/campaigns/{campaign_id}/recipients/import', 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://api.lehar.ai/ca/api/v0/campaigns/{campaign_id}/recipients/import",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Content-Type: multipart/form-data",
"X-API-KEY: <api-key>"
],
]);
$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://api.lehar.ai/ca/api/v0/campaigns/{campaign_id}/recipients/import"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.lehar.ai/ca/api/v0/campaigns/{campaign_id}/recipients/import")
.header("X-API-KEY", "<api-key>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lehar.ai/ca/api/v0/campaigns/{campaign_id}/recipients/import")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"import": {
"id": "cimport_01EXAMPLE",
"campaign_id": "campaign_01EXAMPLE",
"filename": "contacts.csv",
"source_uri": null,
"status": "completed_with_errors",
"total_rows": 3,
"accepted_rows": 2,
"rejected_rows": 1,
"errors": [
{
"row": 4,
"error": "phone_number looks like a spreadsheet auto-converted it to a number (for example 9.19911E+11). Re-enter it as text, keeping the leading + and country code, for example +911234567890.",
"value": "9.19911E+11"
}
],
"metadata": {
"content_type": "text/csv"
},
"created_at": "2026-05-22T10:10:00Z",
"completed_at": "2026-05-22T10:10:01Z"
},
"recipients": [
{
"id": "recipient_01EXAMPLE",
"campaign_id": "campaign_01EXAMPLE",
"phone_number_masked": "+9***3210",
"status": "pending",
"variables": {
"callee_name": "Jane",
"company": "Acme"
},
"whatsapp_context": {},
"outcome": {},
"answers": {},
"qualification_status": null,
"sentiment": null,
"next_action_at": null,
"last_customer_message_at": null,
"service_window_expires_at": null,
"created_at": "2026-05-22T10:10:00Z",
"updated_at": "2026-05-22T10:10:00Z"
}
]
}{
"error": {
"code": "invalid_request",
"message": "The file must be a UTF-8 CSV or an .xlsx spreadsheet"
}
}Authorizations
Path Parameters
Body
A UTF-8 CSV or .xlsx spreadsheet. Header row required; a phone column (phone_number / phone / mobile / number) is mandatory. Every other column is stored as a recipient variable. Max 5 MB.
Response
Import summary plus the accepted recipients (numbers masked). import.status is completed, or completed_with_errors when some rows were rejected; rejected rows are listed in import.errors and are NOT added.

