Sync and clean up contact lists
Merge, split and de-duplicate contact lists with an AI coding tool or the API, and keep invalid numbers and opted-out contacts out
Contacts often reach Kudosity from somewhere else, such as a Shopify store, Klaviyo or a CRM. Over time they end up spread across lists that overlap, mix countries, or hold numbers that can't receive an SMS.
You can tidy them in two ways: ask an AI coding tool to do it, or make the API requests yourself. Both follow the same steps: read a list, check each number, add each contact to the right list, and keep your opt-outs intact.
Ask an AI coding tool
Install the Kudosity Agent Skills in a coding tool such as Claude Code or Cursor, and set your API key and API secret as environment variables.
npx skills add kudosity/skills
export KUDOSITY_API_KEY="your_api_key"
export KUDOSITY_API_SECRET="your_api_secret"Then describe the job in your own words.
Merge lists that overlap:
Merge my "Shopify sign-ups" and "Klaviyo sign-ups" lists into a new Kudosity list called "Subscribers". Skip duplicates and anyone who has opted out
Split a mixed list by country:
Split my "All subscribers" list into one Kudosity list per country
Check a list without changing it:
Check every number on my "Newsletter" list and show me the ones that aren't valid mobiles. Don't change anything yet
Keep lists tidy as new contacts arrive:
Write a script I can run every few hours that moves new contacts from my "Sign-ups" list into my country lists. It must be safe to run twice
Your tool loads the kudosity-contacts-lists skill, which teaches it the steps in this guide, including the rejection codes in Step 4 and the country code rule in Things to watch. When it finishes, it reports four counts: added, already there, opted out and invalid.
The rest of this guide shows each request and its response, so you can check your tool's work or write the code yourself. The examples use placeholder values. Replace the list IDs and phone numbers with your own.
Before you start
List and contact requests use the V1 API at https://api.transmitsms.com.
- Authentication is HTTP Basic with your API key and API secret. You need both. Find them in the Kudosity app under Developers > API Settings.
- Send form fields, not JSON. The content type is
application/x-www-form-urlencoded. - Check
error.codein every response.SUCCESSmeans the request worked. A rejected add returns400, but some requests return200with an error code inside, such asNOT_FOUND.
How lists behave
Four rules explain most of what you see when you move contacts between lists.
- A number can be on a list once. Adding it again is rejected with
KEY_EXISTS. The contact isn't updated. - A contact has one of three statuses:
active,opt-outordeleted. - An opt-out isn't the same as a delete. A deleted contact can be added again. An opted-out contact can't, and the opt-out can stop the number being added to your other lists too.
- Every contact has a
country. Kudosity works it out from the number, so you don't need to.
Step 1: Read the source list
Use Get Information About A List to read a list's contacts one page at a time.
curl --request POST \
--url https://api.transmitsms.com/get-list.json \
--user "$KUDOSITY_API_KEY:$KUDOSITY_API_SECRET" \
--data "list_id=4213644&members=active&page=1&max=100"{
"page": { "count": 3, "number": 1 },
"members_total": 250,
"members_active": 241,
"id": 4213644,
"name": "Newsletter sign-ups",
"fields": { "field_1": "email" },
"members": [
{
"list_id": 4213644,
"msisdn": 61491570157,
"first_name": "Ann",
"last_name": "",
"created_at": "2026-11-30 00:26:21",
"status": "active",
"country": "AU",
"fields": { "email": "[email protected]" }
}
],
"error": { "code": "SUCCESS", "description": "OK" }
}page.countis the number of pages. Requestpage=1up topage=page.count.- A page past the end returns
SUCCESSwith nomembersfield, so don't loop until you get an empty list. membersfilters by status:active,inactive(opted-out and deleted contacts), ornoneto get the counts without any contacts. Leave it out to get every contact.
Step 2: Collect the opt-outs
Before you add anyone to a new list, read each source list again with members=inactive and keep the numbers whose status is opt-out. Don't add those numbers to any target list.
Skip the contacts whose status is deleted. A delete doesn't record that the person asked you to stop.
Step 3: Check each number
Format Number tells you whether a number is valid and whether it's a mobile. It needs the number and the country it should belong to.
curl --request POST \
--url https://api.transmitsms.com/format-number.json \
--user "$KUDOSITY_API_KEY:$KUDOSITY_API_SECRET" \
--data "msisdn=0491 570 156&countrycode=AU"{
"number": {
"countrycode": 61,
"nationalnumber": 491570156,
"international": 61491570156,
"type": 1,
"isValid": true
},
"error": { "code": "SUCCESS", "description": "OK" }
}type | What it means |
|---|---|
1 | Mobile |
0 | Landline. The number is valid, but it can't receive an SMS |
2 | Landline or mobile. Returned for US numbers, where the two can't be told apart |
10 | Invalid. isValid is false |
Keep the numbers with type 1, and type 2 for the US. Use the international value when you add the contact.
Format Number checks the number's format. It can't tell you whether a correctly formatted number is in service.
Step 4: Add each contact to its target list
Use Add Contact to List. Send the number in international format and leave countrycode out.
curl --request POST \
--url https://api.transmitsms.com/add-to-list.json \
--user "$KUDOSITY_API_KEY:$KUDOSITY_API_SECRET" \
--data "list_id=4213652&msisdn=61491570157&first_name=Ann&[email protected]"A successful request returns 200 with the contact as it was added.
{
"list_id": 4213652,
"msisdn": 61491570157,
"first_name": "Ann",
"last_name": "",
"created_at": "2026-11-30 00:26:21",
"status": "active",
"country": "AU",
"fields": { "email": "[email protected]" },
"error": { "code": "SUCCESS", "description": "OK" }
}A rejected request returns 400. When you're moving contacts, most rejections are expected.
error.code | What it means | What to do |
|---|---|---|
KEY_EXISTS | The number is already on this list, as an active or an opted-out contact | Count it as already there, or update it. See Step 5 |
OPTOUT | The number has opted out | Skip it |
BAD_MOBILE_COUNTRY | The country can't be worked out. The number is in local format with no countrycode, or its country code doesn't exist | Send the right countrycode, or leave the number out |
FIELD_INVALID | The value isn't a number. It has spaces, letters or punctuation, or it's too short | Remove everything except the digits and try again |
FIELD_EMPTY | msisdn is missing | Fix the request |
Step 5: Update a contact that's already there
There's no single request that adds a contact or updates it. If the add returns KEY_EXISTS and you want to change the contact's details, send the same fields to Update Contact.
curl --request POST \
--url https://api.transmitsms.com/edit-list-member.json \
--user "$KUDOSITY_API_KEY:$KUDOSITY_API_SECRET" \
--data "list_id=4213652&msisdn=61491570157&first_name=Anne&[email protected]"If the number isn't on that list, the request returns 200 with the error code NOT_FOUND.
Step 6: Remove the contact from the old list
If you're moving contacts and not copying them, remove each one from its source list with Remove Contact. Do this only after the add has returned SUCCESS or KEY_EXISTS.
curl --request POST \
--url https://api.transmitsms.com/delete-from-list.json \
--user "$KUDOSITY_API_KEY:$KUDOSITY_API_SECRET" \
--data "list_id=4213644&msisdn=61491570157"Always send the list_id of the source list. A list_id of 0 removes the contact from every list on your account.
Split a list by country
To sort a mixed list into one list per country, use each contact's country value from Step 1 to choose the target list. Create the lists first with Add List.
Move thousands of contacts at once
For a large move or merge, write the contacts to a CSV file and use Bulk Add Contacts from CSV File. One request replaces thousands of single adds.
- The file must be at a direct URL that Kudosity can fetch, and it needs a column headed
mobile. - A bulk import updates contacts that are already on the list. It doesn't reject them.
- A
200response means the request was received, not that the contacts were imported. Check the result with Check Progress Of Import, which counts the contacts that were imported, duplicated, skipped and opted out.
Things to watch
- A
countrycodethat doesn't match the number changes the number. If you sendmsisdn=61491570158withcountrycode=US, the contact is saved as161491570158and the request returnsSUCCESS. Sendcountrycodeonly with a number in local format. - Adding a contact doesn't check that the number is real. A correctly formatted landline or made-up number is accepted. Check numbers with Format Number first. Numbers that pass the check but aren't in service only show up later, as undelivered messages.
- Don't delete a contact who asked you to stop. Use Opt Out/Unsubscribe Contact. Only an opt-out stops the number being added again.
- Make your script safe to run twice. A second run should add nothing and report every contact as already there.
- Report four counts when you finish: added, already there, opted out and invalid.
Updated 5 minutes ago