UC-011 — Manage Contacts and Lists for Campaigns
- Goal
- Import contacts, create segmented lists, and prepare them for use in campaigns
- Channel
- All
- Estimated time
- 20 minutes
- APIs involved
- POST/api
/partner-gateway /contacts - GET/api
/partner-gateway /contacts - DELETE/api
/partner-gateway /contacts - PUT/api
/partner-gateway /contacts /{id} - POST/api
/partner-gateway /contacts /list - GET/api
/partner-gateway /contacts /list - POST/api
/partner-gateway /contacts /list /contacts - POST/api
/partner-gateway /contacts /upload - POST/api
/partner-gateway /contacts /upload /vcard
- POST/api
Real-world scenarios
- ShopItalia — Customer address book import: Import the export from the company CRM (CSV with 5,000 customers) into the platform to prepare the Black Friday campaign.
- TurismoVeneto — Regional segmentation: Create separate lists for customers in Lombardia, Veneto, and Emilia-Romagna to send geo-targeted promotions on summer stays.
- Studio Legale Ferrara — Phone address book: Import the corporate address book in VCard format to send institutional communications via SMS.
Prerequisites
Before you begin, make sure you have:
- Active API Key → How to get one
- CSV or VCard file ready for import
Contact and list calls use no credit, but they have no simulation mode either: every call in this guide creates or changes real contacts and lists, and unknown body fields such as "simulation" are ignored. Try the import with a small sample file first.
Contact management flow
The diagram shows the three import paths: manual addition, CSV/Excel upload, or VCard import. With the list ID in listId, an upload saves the contacts in the address book and adds them to the list in the same call. All paths converge into verification and campaign use.
Step 1 — Create a contact list
Create an empty list that will serve as a container for the contacts.
curl -X POST https://api.qlara.ai/api/partner-gateway/contacts/list \
-H "Content-Type: application/json" \
-H "X-Api-Key: YOUR_API_KEY" \
-d '{
"name": "Clienti Nord Italia",
"description": "Clienti delle regioni Lombardia, Piemonte, Veneto, Emilia-Romagna"
}'
Response — List created
{
"id": 87,
"name": "Clienti Nord Italia",
"description": "Clienti delle regioni Lombardia, Piemonte, Veneto, Emilia-Romagna",
"companyId": 4618,
"numContact": 0,
"isTest": false,
"isDeleted": false,
"lastCampaignDate": null,
"lastCampaignType": null,
"createdAt": "2026-04-09 09:00:04.512+0000",
"updatedAt": "2026-04-09 09:00:04.512+0000"
}
The id field is the identifier you will use to add contacts and associate the list with campaigns.
Step 2a — Add contacts individually
Create a new contact in the address book and associate it with the list.
curl -X POST https://api.qlara.ai/api/partner-gateway/contacts \
-H "Content-Type: application/json" \
-H "X-Api-Key: YOUR_API_KEY" \
-d '{
"firstName": "Giulia",
"lastName": "Rossi",
"phoneNumbers": ["+393401234567"],
"emailAddresses": ["giulia.rossi@example.it"],
"gender": "F",
"city": "Milano"
}'
Response — Contact created
{
"contacts": [
{
"id": 24501,
"fullName": "Giulia Rossi",
"firstName": "Giulia",
"lastName": "Rossi",
"gender": "F",
"phoneNumbers": ["+393401234567"],
"emailAddresses": ["giulia.rossi@example.it"],
"city": "Milano",
"isValidMobilePhoneNumber": true,
"isValidEmail": true,
"mobilePhoneNumber": "+393401234567",
"isTest": false,
"createdAt": "2026-04-09 09:01:12.284+0000"
}
],
"errors": []
}
Associate the contact with the list:
curl -X POST https://api.qlara.ai/api/partner-gateway/contacts/list/contacts \
-H "Content-Type: application/json" \
-H "X-Api-Key: YOUR_API_KEY" \
-d '{
"contactIds": [24501],
"listIds": [87]
}'
The response lists the IDs of the contacts added to the list, one per new membership (a contact that was already in the list is left out):
[24501]
You can pass multiple contactIds and multiple listIds in a single request to associate N contacts with M lists at once.
Step 2b — Bulk import from CSV
For mass imports, upload a CSV or Excel file with the list ID in the listId query parameter: a single call maps the columns, imports the contacts and adds them to the list.
Expected CSV format
The columns are mapped automatically from the header names, so use the names of the contact fields (such as firstName, lastName, phoneNumber, email):
firstName,lastName,phoneNumber,email
Marco,Bianchi,+393489876543,m.bianchi@example.it
Anna,Verdi,+393331122334,anna.verdi@example.it
Luca,Neri,+393201234567,l.neri@example.it
Upload and import into the list
Send the file and its name; removeHead=true keeps the header row from being imported as a contact, and listId=87 adds the imported contacts to the list:
curl -X POST "https://api.qlara.ai/api/partner-gateway/contacts/upload?removeHead=true&listId=87" \
-H "X-Api-Key: YOUR_API_KEY" \
-F "file=@clienti_nord_italia.csv" \
-F "fileName=clienti_nord_italia.csv"
Response — Import completed
{
"numContact": 5230,
"addedContact": 5104,
"updatedContact": 98,
"listId": 87,
"listName": "Clienti Nord Italia",
"numError": 28
}
addedContact counts the new contacts, updatedContact the existing ones (matched by mobile phone number or by email) updated with the file data, and numError the rows that could not be imported. Both the new and the updated contacts are added to the list named by listId and listName; contacts already in it stay as they are. Without listId both fields are null and the contacts land only in your address book: you can then add them to a list with POST /contacts/list/contacts, as in Step 2a, finding their IDs with GET /contacts (for example notListIds=87 returns the contacts not yet in the list).
From 50,000 rows (fewer in test environments) the import continues in the background: the call answers at once with numContact, addedContact, updatedContact and numError set to -1 and listId and listName set to null. The final counts arrive only in the import-completed email sent to the user the API key belongs to, and the contacts appear in the address book and in the list only when the import has ended: wait for that email before Step 3. Do not upload the file again: that would run the import a second time.
Behind the scenes — CSV import process
- Upload and parsing: The file is uploaded and parsed, and its columns are mapped to contact fields from their header names. With
removeHead=truethe header row is not imported as a contact. - Import: In the same call the contacts are saved in the address book (created, or updated as in point 4) and, with
listId, added to the list. For large files this step continues in the background (see above). - Number normalization: Numbers are stripped of spaces and symbols and converted to the E.164 format; a number without an international prefix is read as an Italian number. A number that is not valid is still saved, in that cleaned-up form, but never becomes the contact's
mobilePhoneNumber. - Deduplication: A row whose mobile phone number or email (compared after normalization) matches an existing contact updates that contact instead of creating a new one, and is counted in
updatedContact. If the number and the email match two different contacts, the one matched by email is updated.
Since the mapping is automatic and the upload imports the file straight away, check the header names and try a small sample file before importing thousands of records.
Step 2c — Import from VCard
To import contacts from a phone address book in .vcf format straight into the list:
curl -X POST "https://api.qlara.ai/api/partner-gateway/contacts/upload/vcard?listId=87" \
-H "X-Api-Key: YOUR_API_KEY" \
-F "file=@rubrica_aziendale.vcf" \
-F "fileName=rubrica_aziendale.vcf"
Response — VCard imported
{
"numContact": 342,
"addedContact": 335,
"updatedContact": 4,
"listId": 87,
"listName": "Clienti Nord Italia",
"numError": 3
}
As with the CSV, listId adds the new and updated contacts to the list in this same call, and from 50,000 entries the import continues in the background.
Where the CSV relies on its header names, VCard contacts use standard fields (FN, TEL, EMAIL, ADR) that are mapped automatically, with no configuration.
Step 3 — Verify the contacts in the list
View the contacts present in the list with pagination.
curl -X GET "https://api.qlara.ai/api/partner-gateway/contacts/list/87/contacts?page=0&limit=10" \
-H "X-Api-Key: YOUR_API_KEY"
Response — Contact listing
{
"data": [
{
"id": 24501,
"fullName": "Giulia Rossi",
"firstName": "Giulia",
"lastName": "Rossi",
"phoneNumbers": ["+393401234567"],
"emailAddresses": ["giulia.rossi@example.it"],
"mobilePhoneNumber": "+393401234567",
"isValidMobilePhoneNumber": true,
"listIds": [87]
},
{
"id": 24502,
"fullName": "Marco Bianchi",
"firstName": "Marco",
"lastName": "Bianchi",
"phoneNumbers": ["+393489876543"],
"emailAddresses": ["m.bianchi@example.it"],
"mobilePhoneNumber": "+393489876543",
"isValidMobilePhoneNumber": true,
"listIds": [87]
}
],
"page": 0,
"limit": 10,
"totalCount": 5542,
"totalPages": 555
}
Step 4 — Use the list in a campaign
Pass the list id in the campaign's contactListIds:
curl -X PUT https://api.qlara.ai/api/partner-gateway/campaigns/1542 \
-H "Content-Type: application/json" \
-H "X-Api-Key: YOUR_API_KEY" \
-d '{
"sendingMode": "SMS",
"destinationType": 0,
"smsSender": "ShopItalia",
"smsBody": "Offerta esclusiva per i clienti del Nord Italia! -30% su tutto con codice NORD30.",
"contactListIds": [87]
}'
Every update must carry sendingMode and destinationType, the latter with the value set at creation (0, recipients from contact lists). An update without readyToSend: true leaves the campaign a draft that is not ready to send: add it once the configuration is final. smsSender must be an approved sender of your account, or the update is refused with 403. See UC-001 — Bulk SMS Campaign for the complete campaign sending flow.
Additional operations
Remove contacts from a list
curl -X DELETE https://api.qlara.ai/api/partner-gateway/contacts/list/contacts \
-H "Content-Type: application/json" \
-H "X-Api-Key: YOUR_API_KEY" \
-d '{
"contactIds": [24501],
"listIds": [87]
}'
true
Search contacts by filter
curl -X GET "https://api.qlara.ai/api/partner-gateway/contacts?search=Rossi&isValid=true&page=0&limit=20" \
-H "X-Api-Key: YOUR_API_KEY"
Quick endpoint reference
| Action | Method | Endpoint |
|---|---|---|
| List contacts | GET | /contacts |
| Create contact | POST | /contacts |
| Update contact | PUT | /contacts/{id} |
| Delete contacts | DELETE | /contacts |
| List of lists | GET | /contacts/list |
| Create list | POST | /contacts/list |
| Add to list | POST | /contacts/list/contacts |
| Remove from list | DELETE | /contacts/list/contacts |
| Contacts in list | GET | /contacts/list/{id}/contacts |
| Upload CSV | POST | /contacts/upload |
| Upload VCard | POST | /contacts/upload/vcard |
Common errors
| Problem | Probable cause | Solution |
|---|---|---|
HTTP 401 | Missing or invalid API Key | Check X-Api-Key header |
HTTP 400 on an upload | file or fileName missing, an empty file (The file is empty), or a fileName extension the endpoint does not take (csv, txt, xls, xlsx for /contacts/upload, vcf for /contacts/upload/vcard) | Send both multipart fields, with a file that is not empty and its real name |
HTTP 404 | A listId or listIds entry that is not a list of your account, or a contactIds entry that is not a contact of your account or is a test contact (when removing, also a contact that is not in the list) | Check the IDs with GET /contacts/list and GET /contacts |
Counts at -1 after an upload | The file has 50,000 or more rows or entries: the import continues in the background | Wait for the import-completed email; do not upload the file again |
| Same number created twice | POST /contacts never rejects duplicates: it creates a second contact | Search first with GET /contacts?phoneNumber= (E.164, + sent as %2B), or import through POST /contacts/upload, which updates the contact matched by mobile number or email |
| VCard imports 0 contacts | The file has no entries between lines BEGIN:VCARD and END:VCARD | Check the file: only the entries between those lines are read (see UC-012) |
Expected result
| Step | Action | Result |
|---|---|---|
| 1 | POST /contacts/list | List created with id |
| 2a | POST /contacts + POST /contacts/list/contacts | Contact created and associated with list |
| 2b | POST /contacts/upload?listId={id} | 5,202 contacts imported from CSV (5,104 new, 98 updated) and added to the list |
| 2c | POST /contacts/upload/vcard?listId={id} | 339 contacts imported from VCard and added to the list |
| 3 | GET /contacts/list/{id}/contacts | Paginated listing of contacts in the list |
| 4 | PUT /campaigns/{id} with contactListIds | List associated with campaign |
Next steps
- UC-001 — Bulk SMS Campaign: Use the newly created lists to launch campaigns
- Contacts and Lists Guide: Deep dive into filters, pagination, and advanced management
- Export Guide: Export contacts for external analysis