Import contacts from file
Starts an asynchronous bulk import of contacts from a previously uploaded file (fileId) into the given inbox. Returns an importId immediately; the import itself runs in the background, so newly imported contacts may not appear in contacts.list right away.
curl --request POST \
--url https://app.chatbotx.io/api/v1/contacts/import \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"fileId": "<string>",
"inboxId": "<string>",
"timezone": "<string>",
"countryCode": "<string>",
"phoneNumber": "<string>",
"contactId": "<string>",
"sourceUserId": "<string>",
"email": "<string>",
"firstName": "<string>",
"lastName": "<string>",
"tagId": "<string>",
"fieldMapping": [
{
"column": "<string>",
"customFieldId": "<string>"
}
]
}
'import requests
url = "https://app.chatbotx.io/api/v1/contacts/import"
payload = {
"fileId": "<string>",
"inboxId": "<string>",
"timezone": "<string>",
"countryCode": "<string>",
"phoneNumber": "<string>",
"contactId": "<string>",
"sourceUserId": "<string>",
"email": "<string>",
"firstName": "<string>",
"lastName": "<string>",
"tagId": "<string>",
"fieldMapping": [
{
"column": "<string>",
"customFieldId": "<string>"
}
]
}
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({
fileId: '<string>',
inboxId: '<string>',
timezone: '<string>',
countryCode: '<string>',
phoneNumber: '<string>',
contactId: '<string>',
sourceUserId: '<string>',
email: '<string>',
firstName: '<string>',
lastName: '<string>',
tagId: '<string>',
fieldMapping: [{column: '<string>', customFieldId: '<string>'}]
})
};
fetch('https://app.chatbotx.io/api/v1/contacts/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://app.chatbotx.io/api/v1/contacts/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 => json_encode([
'fileId' => '<string>',
'inboxId' => '<string>',
'timezone' => '<string>',
'countryCode' => '<string>',
'phoneNumber' => '<string>',
'contactId' => '<string>',
'sourceUserId' => '<string>',
'email' => '<string>',
'firstName' => '<string>',
'lastName' => '<string>',
'tagId' => '<string>',
'fieldMapping' => [
[
'column' => '<string>',
'customFieldId' => '<string>'
]
]
]),
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://app.chatbotx.io/api/v1/contacts/import"
payload := strings.NewReader("{\n \"fileId\": \"<string>\",\n \"inboxId\": \"<string>\",\n \"timezone\": \"<string>\",\n \"countryCode\": \"<string>\",\n \"phoneNumber\": \"<string>\",\n \"contactId\": \"<string>\",\n \"sourceUserId\": \"<string>\",\n \"email\": \"<string>\",\n \"firstName\": \"<string>\",\n \"lastName\": \"<string>\",\n \"tagId\": \"<string>\",\n \"fieldMapping\": [\n {\n \"column\": \"<string>\",\n \"customFieldId\": \"<string>\"\n }\n ]\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://app.chatbotx.io/api/v1/contacts/import")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"fileId\": \"<string>\",\n \"inboxId\": \"<string>\",\n \"timezone\": \"<string>\",\n \"countryCode\": \"<string>\",\n \"phoneNumber\": \"<string>\",\n \"contactId\": \"<string>\",\n \"sourceUserId\": \"<string>\",\n \"email\": \"<string>\",\n \"firstName\": \"<string>\",\n \"lastName\": \"<string>\",\n \"tagId\": \"<string>\",\n \"fieldMapping\": [\n {\n \"column\": \"<string>\",\n \"customFieldId\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.chatbotx.io/api/v1/contacts/import")
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 \"fileId\": \"<string>\",\n \"inboxId\": \"<string>\",\n \"timezone\": \"<string>\",\n \"countryCode\": \"<string>\",\n \"phoneNumber\": \"<string>\",\n \"contactId\": \"<string>\",\n \"sourceUserId\": \"<string>\",\n \"email\": \"<string>\",\n \"firstName\": \"<string>\",\n \"lastName\": \"<string>\",\n \"tagId\": \"<string>\",\n \"fieldMapping\": [\n {\n \"column\": \"<string>\",\n \"customFieldId\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"importId": "<string>"
}{
"defined": true,
"code": "businessError",
"status": 400,
"message": "An error occurred while processing your request",
"data": "<unknown>"
}{
"defined": true,
"code": "UNAUTHORIZED",
"status": 401,
"message": "Authentication required",
"data": "<unknown>"
}{
"defined": true,
"code": "FORBIDDEN",
"status": 403,
"message": "You do not have permission to perform this action",
"data": "<unknown>"
}{
"defined": true,
"code": "invalidRequestData",
"status": 422,
"message": "Input validation failed",
"data": {
"issues": [
{
"message": "<string>",
"path": [
"<string>"
]
}
]
}
}{
"defined": true,
"code": "tooManyRequests",
"status": 429,
"message": "Too many requests",
"data": "<unknown>"
}{
"defined": true,
"code": "INTERNAL_SERVER_ERROR",
"status": 500,
"message": "An unexpected error occurred",
"data": "<unknown>"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Id (numeric string) of a previously uploaded CSV/XLSX file to import.
^\d+$Channel to attach imported contacts to.
omnichannel, webchat, messenger, whatsapp, zalo, smtp, telegram, instagram, threads, tiktok, api Inbox id (numeric string) to import contacts into. Get it from inboxes.list.
^\d+$IANA timezone applied to imported contacts, e.g. America/New_York.
1 - 255Default country code used to normalize imported phone numbers.
^\+\d{1,4}$Column name in the file that holds the contact's phone number.
255Column name in the file that holds a channel-specific user id.
255Column name in the file that holds the WhatsApp Business-Scoped User ID. Only used for whatsapp imports.
255Column name in the file that holds the contact's email.
255Column name in the file that holds the contact's first name.
255Column name in the file that holds the contact's last name.
255Tag id (numeric string) to apply to every imported contact.
^\d+$Column-to-custom-field mappings, up to 10.
10Show child attributes
Show child attributes
Response
OK
Id of the background import job. The import runs asynchronously; imported contacts appear in contacts.list once it finishes.
Was this page helpful?
curl --request POST \
--url https://app.chatbotx.io/api/v1/contacts/import \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"fileId": "<string>",
"inboxId": "<string>",
"timezone": "<string>",
"countryCode": "<string>",
"phoneNumber": "<string>",
"contactId": "<string>",
"sourceUserId": "<string>",
"email": "<string>",
"firstName": "<string>",
"lastName": "<string>",
"tagId": "<string>",
"fieldMapping": [
{
"column": "<string>",
"customFieldId": "<string>"
}
]
}
'import requests
url = "https://app.chatbotx.io/api/v1/contacts/import"
payload = {
"fileId": "<string>",
"inboxId": "<string>",
"timezone": "<string>",
"countryCode": "<string>",
"phoneNumber": "<string>",
"contactId": "<string>",
"sourceUserId": "<string>",
"email": "<string>",
"firstName": "<string>",
"lastName": "<string>",
"tagId": "<string>",
"fieldMapping": [
{
"column": "<string>",
"customFieldId": "<string>"
}
]
}
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({
fileId: '<string>',
inboxId: '<string>',
timezone: '<string>',
countryCode: '<string>',
phoneNumber: '<string>',
contactId: '<string>',
sourceUserId: '<string>',
email: '<string>',
firstName: '<string>',
lastName: '<string>',
tagId: '<string>',
fieldMapping: [{column: '<string>', customFieldId: '<string>'}]
})
};
fetch('https://app.chatbotx.io/api/v1/contacts/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://app.chatbotx.io/api/v1/contacts/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 => json_encode([
'fileId' => '<string>',
'inboxId' => '<string>',
'timezone' => '<string>',
'countryCode' => '<string>',
'phoneNumber' => '<string>',
'contactId' => '<string>',
'sourceUserId' => '<string>',
'email' => '<string>',
'firstName' => '<string>',
'lastName' => '<string>',
'tagId' => '<string>',
'fieldMapping' => [
[
'column' => '<string>',
'customFieldId' => '<string>'
]
]
]),
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://app.chatbotx.io/api/v1/contacts/import"
payload := strings.NewReader("{\n \"fileId\": \"<string>\",\n \"inboxId\": \"<string>\",\n \"timezone\": \"<string>\",\n \"countryCode\": \"<string>\",\n \"phoneNumber\": \"<string>\",\n \"contactId\": \"<string>\",\n \"sourceUserId\": \"<string>\",\n \"email\": \"<string>\",\n \"firstName\": \"<string>\",\n \"lastName\": \"<string>\",\n \"tagId\": \"<string>\",\n \"fieldMapping\": [\n {\n \"column\": \"<string>\",\n \"customFieldId\": \"<string>\"\n }\n ]\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://app.chatbotx.io/api/v1/contacts/import")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"fileId\": \"<string>\",\n \"inboxId\": \"<string>\",\n \"timezone\": \"<string>\",\n \"countryCode\": \"<string>\",\n \"phoneNumber\": \"<string>\",\n \"contactId\": \"<string>\",\n \"sourceUserId\": \"<string>\",\n \"email\": \"<string>\",\n \"firstName\": \"<string>\",\n \"lastName\": \"<string>\",\n \"tagId\": \"<string>\",\n \"fieldMapping\": [\n {\n \"column\": \"<string>\",\n \"customFieldId\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.chatbotx.io/api/v1/contacts/import")
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 \"fileId\": \"<string>\",\n \"inboxId\": \"<string>\",\n \"timezone\": \"<string>\",\n \"countryCode\": \"<string>\",\n \"phoneNumber\": \"<string>\",\n \"contactId\": \"<string>\",\n \"sourceUserId\": \"<string>\",\n \"email\": \"<string>\",\n \"firstName\": \"<string>\",\n \"lastName\": \"<string>\",\n \"tagId\": \"<string>\",\n \"fieldMapping\": [\n {\n \"column\": \"<string>\",\n \"customFieldId\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"importId": "<string>"
}{
"defined": true,
"code": "businessError",
"status": 400,
"message": "An error occurred while processing your request",
"data": "<unknown>"
}{
"defined": true,
"code": "UNAUTHORIZED",
"status": 401,
"message": "Authentication required",
"data": "<unknown>"
}{
"defined": true,
"code": "FORBIDDEN",
"status": 403,
"message": "You do not have permission to perform this action",
"data": "<unknown>"
}{
"defined": true,
"code": "invalidRequestData",
"status": 422,
"message": "Input validation failed",
"data": {
"issues": [
{
"message": "<string>",
"path": [
"<string>"
]
}
]
}
}{
"defined": true,
"code": "tooManyRequests",
"status": 429,
"message": "Too many requests",
"data": "<unknown>"
}{
"defined": true,
"code": "INTERNAL_SERVER_ERROR",
"status": 500,
"message": "An unexpected error occurred",
"data": "<unknown>"
}