Import contacts from a CSV
POST /contacts/imports
Upload a file of up to 50 MB; the rows are processed in the background.
Body
filefileRequiredThe CSV, up to 50 MB, as a multipart part.
column_mapstringA JSON object mapping
email,first_name,last_name,unsubscribedandpropertiesto column names. A property entry is a column name, or{ column, type }withtypeone ofstring,numberorboolean.on_conflictstringupsertupdates a contact whose address already exists;skip(the default) leaves it alone.
2 more fields (segments, topics)
segmentsstringA JSON array of
{ id }segments every imported contact is added to.topicsstringA JSON array of
{ id, subscription }topic choices applied to every imported contact.
Request
curl -X POST "https://api.rasket.com/contacts/imports" \
-H "Authorization: Bearer $RASKET_API_KEY" \
-H "User-Agent: acme-billing/1.0" \
-F "file=@contacts.csv" \
-F "column_map={\"email\":\"Email\",\"first_name\":\"First name\",\"properties\":{\"plan\":\"Plan\"}}" \
-F "on_conflict=upsert" \
-F "segments=[{\"id\":\"78261eea-8f8b-4381-83c6-79fa7120f1cf\"}]"const form = new FormData();
form.append("file", new Blob([csv]), "contacts.csv");
form.append("column_map", "{\"email\":\"Email\",\"first_name\":\"First name\",\"properties\":{\"plan\":\"Plan\"}}");
form.append("on_conflict", "upsert");
form.append("segments", "[{\"id\":\"78261eea-8f8b-4381-83c6-79fa7120f1cf\"}]");
const response = await fetch("https://api.rasket.com/contacts/imports", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.RASKET_API_KEY}`,
"User-Agent": "acme-billing/1.0",
},
body: form,
});
const { id } = await response.json();import os
import requests
response = requests.post(
"https://api.rasket.com/contacts/imports",
headers={
"Authorization": f"Bearer {os.environ['RASKET_API_KEY']}",
"User-Agent": "acme-billing/1.0",
},
files={"file": open("contacts.csv", "rb")},
data={
"column_map": "{\"email\":\"Email\",\"first_name\":\"First name\",\"properties\":{\"plan\":\"Plan\"}}",
"on_conflict": "upsert",
"segments": "[{\"id\":\"78261eea-8f8b-4381-83c6-79fa7120f1cf\"}]",
},
)
id = response.json()["id"]Response 201
{
"object": "contact_import",
"id": "0199d2f1-4c4e-7a20-9c31-6f2b8a0e5d17"
}- The response is immediate; poll the import for its counts.
- No
contact.createdorcontact.updatedwebhook is sent per row. One audit entry records the import. - Rows past your plan's contact limit are counted as
failed.