UC-012 — Import Contacts from VCard
- Goal
- Import contacts from VCard files and verify the import
- Channel
- All
- Estimated time
- 10 minutes
Real-world scenarios
- Migrate from CRM: SalesForce-Pro exports contacts from the old CRM in VCard format and imports them into the Qlara platform to launch SMS campaigns.
- Import from phone: The sales representative exports the company phone's address book to .vcf and uploads it to create a business contact list.
- Sync Outlook: The marketing team periodically syncs Outlook contacts exported in VCard to keep mailing lists up to date.
Import flow
The diagram shows the complete flow: file upload with the destination list, parsing, saving together with the addition to the list, and verification.
Prerequisites
- Active API Key with contact management permissions
- VCard file (.vcf) in vCard 3.0 or 4.0 format
- Destination list already created (or create a new one with
POST /contacts/list, see Variants)
Step 1 — Upload the VCard file into the list
Send the .vcf file via multipart form-data, with the file name in fileName and the ID of the destination list in the listId query parameter.
curl -X POST "https://api.qlara.ai/api/partner-gateway/contacts/upload/vcard?listId=4821" \
-H "X-Api-Key: YOUR_API_KEY" \
-F "file=@/path/to/contacts-export.vcf" \
-F "fileName=contacts-export.vcf"
Response — Import completed
{
"numContact": 250,
"addedContact": 230,
"updatedContact": 15,
"listId": 4821,
"listName": "Migrazione CRM",
"numError": 5
}
The import runs in CREATE_UPDATE mode: new contacts are created (addedContact), while contacts that already exist, matched by mobile phone number or by email, are updated with the VCard data (updatedContact). Both are added to the list named by listId and listName; contacts already in it stay as they are. numError counts the entries that could not be imported. Without listId the contacts land only in the address book, and listId and listName are null; a listId that is not a list of your account answers 404.
From 50,000 entries (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 list only when the import has ended. Do not upload the file again: that would run the import a second time.
Behind the scenes — VCard file parsing
- Reading the entries: The file is read line by line. An entry starts at a line that is exactly
BEGIN:VCARDand is imported when a line that is exactlyEND:VCARDcloses it; an entry withoutEND:VCARDis skipped. Nothing else is validated: a file without such entries is not rejected, it imports nothing and answers200withnumContactat 0. - Field extraction: The fields read are
FN,N,NICKNAME,GENDER,TEL,EMAIL,ADR,ORG,TITLE,URL,BDAYandNOTE; other properties are ignored. No field is mandatory,TELincluded; an entry that has none of them, apart fromGENDER, is counted innumError. - Number normalization: Phone numbers are stripped of spaces and symbols and converted to E.164 (e.g.
347 123 4567becomes+393471234567). A number without an international prefix is read as an Italian number. A number that is not valid is kept in that cleaned-up form, without being converted, and never becomes the contact'smobilePhoneNumber. - Deduplication: Contacts are compared by mobile phone number and by email, after normalization: an existing contact is updated, otherwise a new one is created. If the number and the email match two different contacts, the one matched by email is updated.
- List assignment: With
listId, the created and updated contacts are added to the list in the same import.
Step 2 — Verify imported contacts
Retrieve the contacts of the list to verify that the import was successful; after a background import, wait for the import-completed email first.
curl -X GET "https://api.qlara.ai/api/partner-gateway/contacts/list/4821/contacts?limit=10" \
-H "X-Api-Key: YOUR_API_KEY"
Response — Contacts in the list
{
"data": [
{
"id": 72045,
"fullName": "Marco Rossi",
"firstName": "Marco",
"lastName": "Rossi",
"phoneNumbers": ["+393471234567"],
"emailAddresses": ["marco.rossi@email.com"],
"mobilePhoneNumber": "+393471234567",
"isValidMobilePhoneNumber": true,
"createdAt": "2026-04-09 09:00:10.215+0000",
"listIds": [4821]
},
{
"id": 72046,
"fullName": "Giulia Bianchi",
"firstName": "Giulia",
"lastName": "Bianchi",
"phoneNumbers": ["+393489876543"],
"emailAddresses": ["g.bianchi@company.it"],
"mobilePhoneNumber": "+393489876543",
"isValidMobilePhoneNumber": true,
"createdAt": "2026-04-09 09:00:10.231+0000",
"listIds": [4821]
}
],
"page": 0,
"limit": 10,
"totalCount": 245,
"totalPages": 25
}
Behind the scenes — Indexing and search
- Indexing: After import, contacts are indexed by name, phone and email to enable fast searches.
- Segmentation: To group the imported contacts further, select them with the
GET /contactsfilters, or client-side on fields such ascityortags, and add them to another list withPOST /contacts/list/contacts(see UC-013).
Expected result
| Step | Action | Result |
|---|---|---|
| 1 | POST /contacts/upload/vcard?listId={listId} | File imported into the list, summary with counts |
| 2 | GET /contacts/list/{listId}/contacts | Contacts visible in the list |
Complete end-to-end example
Scenario SalesForce-Pro: contact migration from the old CRM.
# 1. Import the VCard file into the migration list
LIST_ID=4821
echo "=== VCard Import ==="
IMPORT_RESULT=$(curl -s -X POST "https://api.qlara.ai/api/partner-gateway/contacts/upload/vcard?listId=${LIST_ID}" \
-H "X-Api-Key: YOUR_API_KEY" \
-F "file=@./crm-export-2026-04.vcf" \
-F "fileName=crm-export-2026-04.vcf")
echo "$IMPORT_RESULT" | jq '{numContact, addedContact, updatedContact, numError, listName}'
# Large file: the import continues in the background and the counts arrive by email
if [[ "$(echo "$IMPORT_RESULT" | jq -r '.numContact')" == "-1" ]]; then
echo "Import running in the background: wait for the import-completed email."
exit 0
fi
# 2. Verify imported contacts
echo "=== First 5 imported contacts ==="
curl -s -X GET "https://api.qlara.ai/api/partner-gateway/contacts/list/${LIST_ID}/contacts?limit=5" \
-H "X-Api-Key: YOUR_API_KEY" | jq '.data[] | {fullName, mobilePhoneNumber, listIds}'
Variants
Import with existing contact update
If you want to update the data of already existing contacts (e.g. new email address), upload the updated file: the import always runs in CREATE_UPDATE mode, so contacts matched by mobile phone number or by email are updated. Without listId their list memberships do not change.
curl -X POST https://api.qlara.ai/api/partner-gateway/contacts/upload/vcard \
-H "X-Api-Key: YOUR_API_KEY" \
-F "file=@./contacts-updated.vcf" \
-F "fileName=contacts-updated.vcf"
Import into a new list
The upload does not create lists: create the new list first, then import the file with the id returned by the first call in listId:
LIST_ID=$(curl -s -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": "Outlook Sync Aprile 2026"
}' | jq -r '.id')
curl -X POST "https://api.qlara.ai/api/partner-gateway/contacts/upload/vcard?listId=${LIST_ID}" \
-H "X-Api-Key: YOUR_API_KEY" \
-F "file=@./outlook-contacts.vcf" \
-F "fileName=outlook-contacts.vcf"
Add contacts already in the address book to a list
Contacts imported without listId, or created one by one, are added to a list with POST /contacts/list/contacts. Find their IDs with GET /contacts: notListIds=4822 returns the contacts that are not in list 4822 yet, up to 1,000 per page. Keep the ones you need (for example by phone number) and add them:
curl -X GET "https://api.qlara.ai/api/partner-gateway/contacts?notListIds=4822&page=0&limit=1000" \
-H "X-Api-Key: YOUR_API_KEY"
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 '{
"listIds": [4822],
"contactIds": [72045, 72046, 72047]
}'
[72045, 72046, 72047]
The response lists the IDs of the contacts added, one per new membership; contacts that were already in the list are left out.
When the list must contain your entire address book, send "allContacts": true instead of contactIds: every contact is added, except those listed in excludeIdsAllContacts. In this mode the response is always an empty array, [].
Common errors
400 Bad Request — Missing or empty file, or not a .vcf file
{
"status": "fail",
"data": "Unsupported file type in 'fileName': 'contacts-export.csv'. Allowed extensions: vcf; send csv, txt, xls and xlsx files to POST /contacts/upload"
}
Solution: Send the file in the file part and its name, ending in .vcf, in fileName; without one of the two parts the message is Required multipart fields: 'file' and 'fileName', and an empty file gets The file is empty. The content of the file is not validated otherwise: a file without BEGIN:VCARD … END:VCARD entries is not rejected, it answers 200 with numContact at 0, so check the counts after the upload.
413 Payload Too Large — File too large
A request larger than 10 MB (10,240 KiB for the whole multipart body) is rejected with HTTP 413 before it reaches the API, so the response is not a JSend status/data body.
Solution: Split the VCard file into smaller files and import them separately.
Next steps
- UC-011 — Manage Contacts and Lists: Manage and segment imported contacts
- UC-001 — Bulk SMS Campaign: Send a campaign to the newly imported list
- UC-022 — Monitor Credit and Subscription: Check your credit before sending