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.code in every response. SUCCESS means the request worked. A rejected add returns 400, but some requests return 200 with an error code inside, such as NOT_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-out or deleted.
  • 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.count is the number of pages. Request page=1 up to page=page.count.
  • A page past the end returns SUCCESS with no members field, so don't loop until you get an empty list.
  • members filters by status: active, inactive (opted-out and deleted contacts), or none to 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" }
}
typeWhat it means
1Mobile
0Landline. The number is valid, but it can't receive an SMS
2Landline or mobile. Returned for US numbers, where the two can't be told apart
10Invalid. 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.codeWhat it meansWhat to do
KEY_EXISTSThe number is already on this list, as an active or an opted-out contactCount it as already there, or update it. See Step 5
OPTOUTThe number has opted outSkip it
BAD_MOBILE_COUNTRYThe country can't be worked out. The number is in local format with no countrycode, or its country code doesn't existSend the right countrycode, or leave the number out
FIELD_INVALIDThe value isn't a number. It has spaces, letters or punctuation, or it's too shortRemove everything except the digits and try again
FIELD_EMPTYmsisdn is missingFix 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 200 response 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 countrycode that doesn't match the number changes the number. If you send msisdn=61491570158 with countrycode=US, the contact is saved as 161491570158 and the request returns SUCCESS. Send countrycode only 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.

Did this page help you?