Contacts and lists
A contact is a person you message, and their phone number is what identifies them in your organization. A list groups contacts, so a campaign can send to all of them by the list's ID in listIds.
Add a contact
Send the contact to POST /. The API key needs contacts:write:
curl -X POST "https://api.sms.codelia.studio/v1/organizations/$CODELIA_ACCOUNT_ID/contacts" \
-H "Authorization: Bearer $CODELIA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"phone": "+442079460130",
"firstName": "Ada",
"lastName": "Lovelace",
"email": "ada@example.com",
"preferredLanguage": "en",
"birthday": {
"day": 14,
"month": 3
},
"metadata": {
"loyaltyTier": "gold"
}
}'const response = await fetch(
`https://api.sms.codelia.studio/v1/organizations/${process.env.CODELIA_ACCOUNT_ID}/contacts`,
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.CODELIA_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"phone": "+442079460130",
"firstName": "Ada",
"lastName": "Lovelace",
"email": "ada@example.com",
"preferredLanguage": "en",
"birthday": {
"day": 14,
"month": 3
},
"metadata": {
"loyaltyTier": "gold"
}
}),
},
);
console.log(response.status);
console.log(JSON.stringify(await response.json(), null, 2));| Field | What to send |
|---|---|
phone | Required. The number in international format, like +442079460123. |
firstName, lastName | Up to 120 characters each. |
email | An email address, up to 320 characters. |
preferredLanguage | A lowercase two-letter language code, like el, from GET /. A message sent in several languages gives this person theirs. See Send in each person's language. |
birthday | An object, like { "day": 14, "month": 3, "year": 1990 }. day is 1 to 31 and month is 1 to 12. year is optional, from 1900 to this year. 29 February is accepted with no year or with a leap year. Send null to remove it. |
metadata | Your own keys and text values, up to 32 keys, each value up to 200 characters. A campaign's placeholders can use them. |
Every contact you read has birthday: null when it isn't set, and with year set to null when no year was given.
The answer is 201 with the contact: keep its id. A number that's already one of your contacts is refused with 409 and contact_: update that contact instead.
Find contacts
List them, newest first, with contacts:read:
curl "https://api.sms.codelia.studio/v1/organizations/$CODELIA_ACCOUNT_ID/contacts?q=Ada&limit=50" \
-H "Authorization: Bearer $CODELIA_API_KEY"const response = await fetch(
`https://api.sms.codelia.studio/v1/organizations/${process.env.CODELIA_ACCOUNT_ID}/contacts?q=Ada&limit=50`,
{
headers: {
Authorization: `Bearer ${process.env.CODELIA_API_KEY}`,
},
},
);
console.log(response.status);
console.log(JSON.stringify(await response.json(), null, 2));qis split into words, and each word must match the first name, last name, email or number, soAda Lovfinds Ada Lovelace.filternarrows the list with a rule, sent as URL-encoded JSON in the same shape as a smart list'sdefinition. It applies together withq.limitis up to 200, and 50 if you leave it out. The answer'snextCursorgets the next page: see Paging through results.- Each contact has an
optOutfield only when the API key holdsopt-outs:read:{ "scope": "organization" }when their number opted out,nullwhen it didn't.
Get one contact with GET /. GET / lists the languages and countries your contacts have, each with how many have it, most common first.
Change or delete a contact
These need contacts:write:
PATCH /changes the fields you send and leaves the rest. The number can't be changed: delete the contact and add it again. Aorganizations/ {accountId}/ contacts/ {contactId} birthdayyou send replaces the whole birthday, so one withoutyearremoves a stored year.DELETE /removes the contact and takes it off every list. Messages already sent to the number are unaffected, and so is the number's opt-out.organizations/ {accountId}/ contacts/ {contactId} POST /with up to 1,000organizations/ {accountId}/ contacts/ delete contactIdsdeletes several at once. IDs that aren't your contacts are counted inskipped.
Import contacts
POST / takes up to 10,000 rows and matches each on its phone number. The API key needs contacts:write:
curl -X POST "https://api.sms.codelia.studio/v1/organizations/$CODELIA_ACCOUNT_ID/contacts/import" \
-H "Authorization: Bearer $CODELIA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: import-newsletter-2026-10" \
-d '{
"rows": [
{
"phone": "+442079460131",
"firstName": "Grace",
"lastName": "Hopper",
"language": "en",
"birthday": "14/03/1990",
"loyaltyTier": "silver"
},
{
"phone": "+442079460132",
"firstName": "Alan",
"email": "alan@example.com"
}
],
"listName": "Newsletter"
}'const response = await fetch(
`https://api.sms.codelia.studio/v1/organizations/${process.env.CODELIA_ACCOUNT_ID}/contacts/import`,
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.CODELIA_API_KEY}`,
"Content-Type": "application/json",
"Idempotency-Key": "import-newsletter-2026-10",
},
body: JSON.stringify({
"rows": [
{
"phone": "+442079460131",
"firstName": "Grace",
"lastName": "Hopper",
"language": "en",
"birthday": "14/03/1990",
"loyaltyTier": "silver"
},
{
"phone": "+442079460132",
"firstName": "Alan",
"email": "alan@example.com"
}
],
"listName": "Newsletter"
}),
},
);
console.log(response.status);
console.log(JSON.stringify(await response.json(), null, 2));- A row for a number you already have updates that contact. A row that changes nothing is counted in
skipped. phone,firstName,lastName,email,languageandbirthdayare read by name. Any other key is kept in the contact'smetadata, ready for placeholders: up to 32, with each value cut to 200 characters.languagesets the contact's preferred language: a two-letter code, in any case, soELis Greek. An empty value leaves an existing preference as it is.birthdaysets the contact's birthday, as text: DD/MM, DD/MM/YYYY or YYYY-MM-DD. It's read day first, so05/is 5 March, and03 03/isn't a date. A spreadsheet's date number isn't read, so send the date as text. An empty value leaves an existing birthday as it is.14 - A row that can't be imported is listed in
failed, with itsrownumber (the first row is 1) and acode:invalid_,phone invalid_,language invalid_orbirthday duplicate_. The other rows are still imported.in_ file - Add
listNameto put everyone in the file on that list, creating the list if you don't have one by that name, orlistIdfor a list you have. Send one or the other, not both. - The answer counts
imported,updatedandskipped, listsfailed, and gives the list'slistId.
An import takes an Idempotency-Key, so a retry after a timeout gets the first answer back, with the same counts. See Retrying safely.
Lists
A list is one of two kinds, in its kind field:
static: the contacts you put in it.smart: a saved filter. Its members are whoever matches the filter when it's read or sent to, so it fills itself as your contacts change.
GET / lists every list, newest first, each with its memberCount. These calls need contact-lists:read, and changes need contact-lists:write.
Create a list
A list name is unique in your organization. A list with no definition is static:
curl -X POST "https://api.sms.codelia.studio/v1/organizations/$CODELIA_ACCOUNT_ID/contact-lists" \
-H "Authorization: Bearer $CODELIA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Spring sale",
"description": "Customers who asked to hear about sales."
}'const response = await fetch(
`https://api.sms.codelia.studio/v1/organizations/${process.env.CODELIA_ACCOUNT_ID}/contact-lists`,
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.CODELIA_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"name": "Spring sale",
"description": "Customers who asked to hear about sales."
}),
},
);
console.log(response.status);
console.log(JSON.stringify(await response.json(), null, 2));The answer is 201 with the list: keep its id. A name you already use is refused with 409 and contact_.
Smart lists
Send a definition and the list is smart. Supplying a filter also needs contacts:read, because the answer counts who it matches:
curl -X POST "https://api.sms.codelia.studio/v1/organizations/$CODELIA_ACCOUNT_ID/contact-lists" \
-H "Authorization: Bearer $CODELIA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Greek speakers",
"definition": {
"version": 1,
"match": "all",
"conditions": [
{
"field": "preferredLanguage",
"operator": "in",
"value": [
"el"
]
}
]
}
}'const response = await fetch(
`https://api.sms.codelia.studio/v1/organizations/${process.env.CODELIA_ACCOUNT_ID}/contact-lists`,
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.CODELIA_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"name": "Greek speakers",
"definition": {
"version": 1,
"match": "all",
"conditions": [
{
"field": "preferredLanguage",
"operator": "in",
"value": [
"el"
]
}
]
}
}),
},
);
console.log(response.status);
console.log(JSON.stringify(await response.json(), null, 2));versionis1.matchisall(the default) orany, and there can be up to 20conditions.- Your organization can have up to 25 smart lists. Past that, creating one is refused with
409andsmart_.list_ limit_ reached - A condition on
optedOutalso needsopt-outs:read, and one onlistneedscontact-lists:read.
The conditions a filter can use:
field | operator |
|---|---|
preferredLanguage, countryCode | in or notIn, with value as a list of codes; isSet; isEmpty |
firstName, lastName, email | is, contains or startsWith, with value; isSet; isEmpty |
phone | is, contains or startsWith, with value |
createdAt | inLast or notInLast, with days; before or after, with value; between, with from and to |
list | in or notIn, with value as up to 10 list IDs |
optedOut | is, with value true or false |
birthday | thisMonth; inMonth, with value as up to 12 month numbers from 1 to 12; isSet; isEmpty |
Three things to know before you rely on a count:
notInalso matches contacts with no value at all. Add anisSetcondition on the same field for only those who have one.inLastandnotInLastcount back from when the list is read or sent to, not from when you saved it.thisMonthis the month when the list is read or sent to, not when you saved it, so on 1 April it holds April's birthdays. The month is the calendar month in UTC.
A list condition can name only static lists: a smart list there is refused with 400 and smart_.
To try a filter before you save it, send it as definition to POST /. It answers with how many contacts match, in count, and up to 25 of them, in sample, and saves nothing. It needs contact-lists:read and contacts:read.
Change or delete a list
PATCH /renames a list, or changes a smart list'sorganizations/ {accountId}/ contact-lists/ {listId} definition. A list can't change kind: that's refused with409andlist_.kind_ immutable DELETE /removes the list. Its contacts stay. A list that a smart list's filter uses can't be deleted:organizations/ {accountId}/ contact-lists/ {listId} 409andlist_.referenced_ by_ filter
Every organization has a built-in list of all its contacts. It has a reservedKey, and it can't be renamed, changed or deleted.
Who's on a list
Add contacts to a static list by their IDs, up to 1,000 per request:
curl -X POST "https://api.sms.codelia.studio/v1/organizations/$CODELIA_ACCOUNT_ID/contact-lists/$LIST_ID/members" \
-H "Authorization: Bearer $CODELIA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contactIds": [
"'"$CONTACT_ID"'"
]
}'const response = await fetch(
`https://api.sms.codelia.studio/v1/organizations/${process.env.CODELIA_ACCOUNT_ID}/contact-lists/${process.env.LIST_ID}/members`,
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.CODELIA_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"contactIds": [
process.env.CONTACT_ID
]
}),
},
);
console.log(response.status);
console.log(JSON.stringify(await response.json(), null, 2));- Adding a contact who's already on the list changes nothing. IDs that aren't your contacts are counted in
skipped. DELETE /takes one contact off the list. They stay in your contacts.organizations/ {accountId}/ contact-lists/ {listId}/ members/ {contactId} - A smart list has no members to add or remove: that's refused with
409andsmart_. Change its filter instead.list_ not_ editable
See who's on a list:
curl "https://api.sms.codelia.studio/v1/organizations/$CODELIA_ACCOUNT_ID/contact-lists/$LIST_ID/members?limit=200&offset=0" \
-H "Authorization: Bearer $CODELIA_API_KEY"const response = await fetch(
`https://api.sms.codelia.studio/v1/organizations/${process.env.CODELIA_ACCOUNT_ID}/contact-lists/${process.env.LIST_ID}/members?limit=200&offset=0`,
{
headers: {
Authorization: `Bearer ${process.env.CODELIA_API_KEY}`,
},
},
);
console.log(response.status);
console.log(JSON.stringify(await response.json(), null, 2));The answer is the contacts themselves: the most recently added first on a static list, and the newest contact first on a smart list. It pages by limit (up to 500, and 200 if you leave it out) and offset. See Paging through results.
People who opted out stay on your lists, and your marketing messages skip them. See Opt-outs.
When it's refused
When a request is refused, nothing changes.
| Status | error | What happened | What to do |
|---|---|---|---|
| 400 | invalid_ | The phone number couldn't be read as an international number. | Include the country code, like +442079460123. |
| 400 | smart_ | A filter uses a smart list, and a filter can use only static lists. | Filter on static lists only. |
| 400 | unknown_ | A filter uses a list that doesn't exist in your organization. | Check the list IDs in the filter. |
| 400 | validation_ | A birthday isn't a date: a day the month doesn't have, 29 February in a year that isn't a leap year, a year before 1900 or after this one, or a day without a month. errors.birthday says which. | Send a real date, or null for no birthday. |
| 404 | contact_ | An import's listId isn't a list in your organization. | Check the list ID, or send listName instead. |
| 409 | contact_ | A contact with this phone number already exists in your organization. | Update that contact instead. |
| 409 | contact_ | A list with this name already exists. | Choose another name. |
| 409 | list_ | A change would turn a static list into a smart list, or the other way. | Create a new list of the kind you need. |
| 409 | list_ | A smart list's filter uses this list, so it can't be deleted. | Change that smart list's filter, or delete it first. |
| 409 | reserved_ | The built-in list of all your contacts can't be changed. | Create a list of your own. |
| 409 | reserved_ | The built-in list of all your contacts can't be deleted. | Nothing to do. |
| 409 | smart_ | Your organization already has 25 smart lists. | Delete one before you create another. |
| 409 | smart_ | People can't be added to or removed from a smart list by hand. | Change its filter instead. |
| 409 | smart_ | An import can't add people to a smart list. | Import into a static list. |
Every code, including the ones any request can get, is on Errors and limits.