curl --request POST \
--url https://api.instantly.ai/api/v2/lifecycle/contacts/imports \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"file_name": "contacts.csv",
"consent_confirmed": true
}
'import requests
url = "https://api.instantly.ai/api/v2/lifecycle/contacts/imports"
payload = {
"file_name": "contacts.csv",
"consent_confirmed": True
}
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: 'contacts.csv', consent_confirmed: true})
};
fetch('https://api.instantly.ai/api/v2/lifecycle/contacts/imports', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.post("https://api.instantly.ai/api/v2/lifecycle/contacts/imports")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"file_name\": \"contacts.csv\",\n \"consent_confirmed\": true\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.instantly.ai/api/v2/lifecycle/contacts/imports",
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' => 'contacts.csv',
'consent_confirmed' => true
]),
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://api.instantly.ai/api/v2/lifecycle/contacts/imports"
payload := strings.NewReader("{\n \"file_name\": \"contacts.csv\",\n \"consent_confirmed\": true\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))
}{
"import_id": "01234567-89ab-cdef-0123-456789abcdef",
"status": "uploading",
"upload_url": "https://uploads.example.com/contacts.csv?signature=abc123",
"expires_in": 300,
"content_type": "text/csv",
"file_id": "01234567-89ab-cdef-0123-456789abcdef",
"tag_id": "01234567-89ab-cdef-0123-456789abcdef",
"segment_id": "01234567-89ab-cdef-0123-456789abcdef"
}{
"statusCode": 400,
"error": "Bad Request",
"message": "limit: must be at most 50",
"code": "VALIDATION_ERROR"
}{
"statusCode": 401,
"error": "Unauthorized",
"message": "Missing Authorization header"
}{
"statusCode": 402,
"error": "Payment Required",
"message": "Workspace does not have an active paid plan"
}{
"statusCode": 403,
"error": "Forbidden",
"message": "Workspace suspended due to a high bounce or spam complaint rate. Please contact support.",
"code": "WORKSPACE_SUSPENDED"
}{
"statusCode": 404,
"error": "Not Found",
"message": "Not found",
"code": "NOT_FOUND"
}{
"statusCode": 408,
"error": "Request Timeout",
"message": "An internal error occurred"
}{
"statusCode": 409,
"error": "Conflict",
"message": "The resource has changed. Reload it and try again.",
"code": "CONFLICT"
}{
"statusCode": 429,
"error": "Too Many Requests",
"message": "Rate limit exceeded"
}{
"statusCode": 500,
"error": "Internal Server Error",
"message": "An internal error occurred"
}Import contacts from a CSV file
Starts a CSV import into the workspace contacts in two steps: (1) call this endpoint to create the import and get upload_url, (2) PUT your file to upload_url within 5 minutes, with content_type as the Content-Type header. To get a fresh URL after it expires, call this endpoint again with the same client_token; without one, a new call creates a second import. Then follow the import with GET /api/v2/lifecycle/contacts/imports/{id}.
The file needs a header row with an email column named email, email_address, emailaddress, e-mail or mail (any capitalization); without one the import fails with COLUMN_ERROR. Optional name columns: first_name, firstname, first name, given_name, fname or forename, and last_name, lastname, last name, surname, family_name, lname or familyname. A status column named is_subscribed, subscribed, subscription, accepts_marketing, accepts_email_marketing, accepts email marketing, email_marketing, marketing_consent, opt_in, optin or consent is read for each row: true, 1, yes, y, subscribed, active, opt-in, optin or consent subscribes the contact; false, 0, no, n, unsubscribed, inactive, opt-out, optout or opt_out unsubscribes it, including an existing contact; any other value makes the row invalid. Every other column becomes a text custom attribute.
Every imported contact receives the import tag. Pass segment to also create a segment that selects it; a workspace holds at most 1000 segments, and past that the import is refused with 400.
Requires one of the following scopes: lifecycle_contacts:create, lifecycle_contacts:all, all:create, all:all
curl --request POST \
--url https://api.instantly.ai/api/v2/lifecycle/contacts/imports \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"file_name": "contacts.csv",
"consent_confirmed": true
}
'import requests
url = "https://api.instantly.ai/api/v2/lifecycle/contacts/imports"
payload = {
"file_name": "contacts.csv",
"consent_confirmed": True
}
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: 'contacts.csv', consent_confirmed: true})
};
fetch('https://api.instantly.ai/api/v2/lifecycle/contacts/imports', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.post("https://api.instantly.ai/api/v2/lifecycle/contacts/imports")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"file_name\": \"contacts.csv\",\n \"consent_confirmed\": true\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.instantly.ai/api/v2/lifecycle/contacts/imports",
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' => 'contacts.csv',
'consent_confirmed' => true
]),
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://api.instantly.ai/api/v2/lifecycle/contacts/imports"
payload := strings.NewReader("{\n \"file_name\": \"contacts.csv\",\n \"consent_confirmed\": true\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))
}{
"import_id": "01234567-89ab-cdef-0123-456789abcdef",
"status": "uploading",
"upload_url": "https://uploads.example.com/contacts.csv?signature=abc123",
"expires_in": 300,
"content_type": "text/csv",
"file_id": "01234567-89ab-cdef-0123-456789abcdef",
"tag_id": "01234567-89ab-cdef-0123-456789abcdef",
"segment_id": "01234567-89ab-cdef-0123-456789abcdef"
}{
"statusCode": 400,
"error": "Bad Request",
"message": "limit: must be at most 50",
"code": "VALIDATION_ERROR"
}{
"statusCode": 401,
"error": "Unauthorized",
"message": "Missing Authorization header"
}{
"statusCode": 402,
"error": "Payment Required",
"message": "Workspace does not have an active paid plan"
}{
"statusCode": 403,
"error": "Forbidden",
"message": "Workspace suspended due to a high bounce or spam complaint rate. Please contact support.",
"code": "WORKSPACE_SUSPENDED"
}{
"statusCode": 404,
"error": "Not Found",
"message": "Not found",
"code": "NOT_FOUND"
}{
"statusCode": 408,
"error": "Request Timeout",
"message": "An internal error occurred"
}{
"statusCode": 409,
"error": "Conflict",
"message": "The resource has changed. Reload it and try again.",
"code": "CONFLICT"
}{
"statusCode": 429,
"error": "Too Many Requests",
"message": "Rate limit exceeded"
}{
"statusCode": 500,
"error": "Internal Server Error",
"message": "An internal error occurred"
}Authorizations
Body
Idempotency token, required when segment is provided. Calling again with the same token returns the same import with a fresh upload_url instead of creating a second import or segment.
1 - 128^[A-Za-z0-9._:-]+$"01234567-89ab-cdef-0123-456789abcdef"
Response
The import and its upload URL. A repeated client_token returns the same import.