Skip to content

Export & Import

The export/import endpoints back the CSV Export and Import actions in the Contacts screen. They are generic: a small set of server-defined tables are exportable and importable, each with an allow-listed set of columns. Only two resources are supported today:

TableExport permissionImport permission
contactscontacts:exportcontacts:import
tagstags:exporttags:import

Export rows of a table as a CSV file. The response is a CSV file download (not a JSON envelope), with Content-Type: text/csv and a Content-Disposition: attachment header naming the file <table>_export_<timestamp>.csv.

Terminal window
POST /api/export
{
"table": "contacts",
"columns": ["phone_number", "profile_name", "tags"],
"filters": {
"search": "john",
"tags": "vip,lead"
},
"format": "csv"
}
FieldTypeRequiredDescription
tablestringYesTable to export: contacts or tags.
columnsarrayNoColumns to include. Must be a subset of the table's allowed columns. Defaults to the table's default columns when omitted or empty.
filtersobjectNoMap of filter name → value (see below).
formatstringNoOutput format. Only csv is produced.
FilterApplies toDescription
searchcontacts, tagsCase-insensitive match. Contacts match on phone number or name; tags match on name or description.
tagscontactsComma-separated tag list; returns contacts having any of the tags.
ColumnDefaultLabel
phone_numberYesPhone Number
profile_nameYesName
tagsYesTags
whats_app_accountNoWhatsApp Account
assigned_user_idNoAssigned User ID
last_message_atNoLast Message At
created_atNoCreated At
updated_atNoUpdated At
ColumnDefaultLabel
nameYesName
colorYesColor
descriptionYesDescription
created_atNoCreated At

A CSV payload. The first row is the header (using the human labels above), followed by one row per record:

Phone Number,Name,Tags
14155550123,John Doe,"vip,lead"

Import rows from a CSV file via multipart/form-data. Duplicates are detected on the table's unique column.

Terminal window
POST /api/import
FieldTypeRequiredDescription
tabletextYesTable to import into: contacts or tags.
filefileYesThe CSV file (max 10 MB, max 10,000 data rows).
column_mappingtext (JSON)NoJSON object mapping a CSV header → target column, e.g. {"Mobile":"phone_number"}. Unmapped headers are matched by (lower-cased) name or label.
update_on_duplicatetextNo"true" to update existing rows on a unique-column match; otherwise duplicates are skipped.
TableRequiredOptionalUnique column
contactsphone_numberprofile_name, whats_app_account, tags, assigned_user_idphone_number
tagsnamecolor, descriptionname
{
"status": "success",
"data": {
"created": 42,
"updated": 3,
"skipped": 5,
"errors": 1,
"messages": [
"Row 12: phone_number - phone number is required"
]
}
}
FieldTypeDescription
createdintegerNew rows inserted.
updatedintegerExisting rows updated (only when update_on_duplicate is true).
skippedintegerDuplicate rows left unchanged.
errorsintegerRows that failed validation or insertion.
messagesarrayHuman-readable per-row error messages.

Describe the exportable columns for a table — used by the UI to build the column picker.

Terminal window
GET /api/export/{table}/config

Requires the table's export permission (e.g. contacts:export).

{
"status": "success",
"data": {
"table": "contacts",
"columns": [
{ "key": "phone_number", "label": "Phone Number" },
{ "key": "profile_name", "label": "Name" },
{ "key": "tags", "label": "Tags" }
],
"default_columns": ["phone_number", "profile_name", "tags"]
}
}

Describe the importable columns for a table — used by the UI to build the column-mapping step.

Terminal window
GET /api/import/{table}/config

Requires the table's import permission (e.g. contacts:import).

{
"status": "success",
"data": {
"table": "contacts",
"required_columns": [
{ "key": "phone_number", "label": "Phone Number" }
],
"optional_columns": [
{ "key": "profile_name", "label": "Name" },
{ "key": "whats_app_account", "label": "WhatsApp Account" },
{ "key": "tags", "label": "Tags" },
{ "key": "assigned_user_id", "label": "Assigned User ID" }
],
"unique_column": "phone_number"
}
}
  • Contacts API - Manage contacts individually
  • Roles - import/export permission actions