The request part with file is required. It has to be uploaded as file part in form-data. filename parameter must be specified (request part header example: Content-Disposition: form-data; name="file"; filename="contacts.csv"). File must have .csv or .txt extension and has to have a valid CSV format with size smaller than 32MB.
Every contact in the file must be in a separate line. The simplest file has just phone numbers in every line.
A valid phone number:
- is 6-15 characters long
- contains only digits (no letters nor special characters like " + - ( ) " are allowed)
Example:
The uploaded file can be extended by additional columns (in CSV format). Columns are separated with , character. If so, it must have headers as a first line and one of the columns must be whatsapp and it contains phone numbers described above. The word whatsapp is case insensitive, so e.g. WhatsApp can be also used.
If the file has headers, it may be extended by labels column (also case insensitive). If column labels exists, every value contains initial labels for the given phone number. The labels must be separated with ; (e.g. label-1;label-2).
If the file has headers, any column name other than labels or whatsapp is treaed as a generic attribute (case sensitive). There are 3 special attributes: phone, email, name. If they are specified, they will be set also in contact information.
As a separate form-data part, the additional payload can be defined in payload part (request part header must be: Content-Disposition: form-data; name="payload"). It has to contain a string with valid json in format defined in payload field in scheme section.
If the additional data contains field labels, those labels will be added to every imported contact. It means, that every contact will have default labels, labels from labels column from file (if provided) and labels from additional data payload.
Note: duplicated labels are ignored, and added just once to the contact.
Sending a file:
WhatsApp,labels,phone,email,Attr1,attr2
123456789,label1;label2,123456789,[email protected],val1,val2
223456789,label1;duplicated;duplicated,,,val1,
323456789,,,,,
Together with payload:
{
"labels": ["label-1", "label-2", "label-1"]
}
Will create contacts like:
[
{
"number": "123456789",
"phone": "123456789",
"email": "[email protected]",
"labels": [
"Opt-in Campaign", // default label
"label1",
"label2",
"label-1",
"label-2"
],
"attributes": {
"Attr1": "val1",
"attr2": "val2"
}
},
{
"number": "223456789",
"labels": [
"Opt-in Campaign", // default label
"label1",
"duplicated",
"label-1",
"label-2"
],
"attributes": {
"Attr1": "val1"
}
},
{
"number": "323456789",
"labels": [
"Opt-in Campaign", // default label
"label-1",
"label-2"
],
"attributes": {}
}
]
if we add the name column to the csv file, we will set this name for the new contact.