Recurring campaigns
A recurring campaign sends a campaign on a rule, like every Monday at 09:00 London time. Each time it's due, it creates an ordinary scheduled campaign, which is priced and charged when it sends.
Create one
Send the rule and the campaign to POST /. The API key needs messages:send:
curl -X POST "https://api.sms.codelia.studio/v1/organizations/$CODELIA_ACCOUNT_ID/messages/recurring" \
-H "Authorization: Bearer $CODELIA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: weekly-offers-2026" \
-d '{
"rule": {
"frequency": "weekly",
"byWeekday": [
"mon"
],
"at": "09:00",
"timeZone": "Europe/London"
},
"send": {
"from": "InfoSMS",
"body": "Hi {{firstName}}, new offers are live this week.",
"listIds": [
"'"$LIST_ID"'"
]
}
}'const response = await fetch(
`https://api.sms.codelia.studio/v1/organizations/${process.env.CODELIA_ACCOUNT_ID}/messages/recurring`,
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.CODELIA_API_KEY}`,
"Content-Type": "application/json",
"Idempotency-Key": "weekly-offers-2026",
},
body: JSON.stringify({
"rule": {
"frequency": "weekly",
"byWeekday": [
"mon"
],
"at": "09:00",
"timeZone": "Europe/London"
},
"send": {
"from": "InfoSMS",
"body": "Hi {{firstName}}, new offers are live this week.",
"listIds": [
process.env.LIST_ID
]
}
}),
},
);
console.log(response.status);
console.log(JSON.stringify(await response.json(), null, 2));The answer is 201 with the recurring campaign: keep its id.
sendis the body a campaign takes, withoutscheduledAt: the rule decides when it sends. AsendwithscheduledAtis refused with400andinvalid_.recurrence - It sends marketing messages only. A
sendwithtype: "transactional"is refused withtransactional_.not_ repeatable - Creating one needs auto top-up, set up in the portal. Without it, the answer is
409withauto_.topup_ required - Nothing is charged when you create it.
startsAtis optional: the rule counts forward from it, and from now if you leave it out.endsAtandmaxOccurrencesare optional, and end it on its own: nothing is sent afterendsAt, and it stops once it has createdmaxOccurrencescampaigns (1 to 1,000; a skipped time doesn't count). Then itsstatusbecomesended. AnendsAtthat isn't afterstartsAt, or comes before the first time the rule names, is refused with400andinvalid_.recurrence
The rule
frequency | What else the rule needs |
|---|---|
weekly | byWeekday: one or more of mon, tue, wed, thu, fri, sat and sun, each once. All seven is every day: there's no daily rule. |
monthly | byMonthDay: a day from 1 to 31, or -1 for the last day of the month. A rule on the 29th, 30th or 31st skips months that don't have that day. |
yearly | byMonth, from 1 to 12, and byMonthDay, as for monthly. |
Every rule also has at, the time of day as 24-hour HH:MM, and timeZone, a time zone name like Europe/. The time stays the same local time when the clocks change.
What it creates
- About 45 minutes before each time, it creates a scheduled campaign. That campaign is priced and charged when it sends, at that day's prices, like any scheduled campaign, and a smart list reaches whoever matches then.
- A smart list whose filter has
birthdaythisMonthis read when each campaign sends, so a monthly campaign on the 1st reaches that month's birthdays. The month is the calendar month in UTC: a time early on the 1st that is still the month before in UTC reaches last month's birthdays.Europe/is two or three hours ahead of UTC, so there, send at 03:00 or later.Nicosia - A time that would go out more than 30 minutes late, after an outage, is skipped rather than sent late. The skip is recorded in your activity log.
- If three in a row fail, it stops, and its
statusbecomesstopped. - When it reaches its
endsAtormaxOccurrences, it ends, and itsstatusbecomesended. The end is recorded in your activity log.
Each campaign it creates has its recurringCampaignId. List them with GET /, which gives each one's status, counts and cost. Their webhook events carry recurringCampaignId too.
Find them
List your recurring campaigns, newest first, with messages:read. status narrows the list to active, paused, stopped or ended, and nextCursor gets the next page:
curl "https://api.sms.codelia.studio/v1/organizations/$CODELIA_ACCOUNT_ID/messages/recurring?status=active" \
-H "Authorization: Bearer $CODELIA_API_KEY"const response = await fetch(
`https://api.sms.codelia.studio/v1/organizations/${process.env.CODELIA_ACCOUNT_ID}/messages/recurring?status=active`,
{
headers: {
Authorization: `Bearer ${process.env.CODELIA_API_KEY}`,
},
},
);
console.log(response.status);
console.log(JSON.stringify(await response.json(), null, 2));GET / gets one: its rule, what it sends, nextRunAt, and how many campaigns it has created, in occurrenceCount.
status | What it means |
|---|---|
active | Running. nextRunAt is when it's next due. |
paused | You paused it. It creates nothing until you resume it. |
stopped | Three in a row failed, so it stopped. Fix the cause, then resume it. |
ended | It reached its endsAt or maxOccurrences. |
Change, pause, resume or delete
Each of these needs messages:send and takes an Idempotency-Key (see Retrying safely). Pause one, and it creates nothing more until you resume it:
curl -X POST "https://api.sms.codelia.studio/v1/organizations/$CODELIA_ACCOUNT_ID/messages/recurring/$RECURRING_CAMPAIGN_ID/pause" \
-H "Authorization: Bearer $CODELIA_API_KEY" \
-H "Idempotency-Key: weekly-offers-2026-pause"const response = await fetch(
`https://api.sms.codelia.studio/v1/organizations/${process.env.CODELIA_ACCOUNT_ID}/messages/recurring/${process.env.RECURRING_CAMPAIGN_ID}/pause`,
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.CODELIA_API_KEY}`,
"Idempotency-Key": "weekly-offers-2026-pause",
},
},
);
console.log(response.status);
console.log(JSON.stringify(await response.json(), null, 2));- Change it with
PATCH /and any oforganizations/ {accountId}/ messages/ recurring/ {id} rule,startsAt,endsAt,maxOccurrencesandsend;nullremovesendsAtormaxOccurrences. The change applies from the next campaign it hasn't created yet. Changing it doesn't need auto top-up. If the new end leaves no room for its next time, it ends at once. - Resume it with
POST /. It starts again from the next time the rule names, and times that passed while it was paused aren't sent. Resuming needs auto top-up, as creating does. Aorganizations/ {accountId}/ messages/ recurring/ {id}/ resume stoppedcampaign resumes this way too, and so does anendedone once you've moved itsendsAtor raised itsmaxOccurrences; before that, resuming it is refused with400andinvalid_.recurrence - Delete it with
DELETE /. It stops for good, and any campaign it created that hasn't sent yet is canceled. The answer counts those inorganizations/ {accountId}/ messages/ recurring/ {id} cancelledOccurrences. Campaigns that already went out are unchanged. Changing, pausing or resuming it afterwards answers409withnot_.editable
A campaign it already created is an ordinary scheduled campaign: changing or pausing the recurring campaign leaves it as it is. To stop that one, cancel it.
When it's refused
A refused request changes nothing.
| Status | error | What happened | What to do |
|---|---|---|---|
| 400 | invalid_ | The rule never gives a date to send on, the recurring campaign's send has scheduledAt, endsAt leaves no time to send on, or an ended campaign was resumed without room for another. | Fix the rule, take scheduledAt out of send, or move endsAt or raise maxOccurrences. |
| 400 | transactional_ | A recurring campaign's send has type set to transactional. | Schedule each transactional message on its own, or repeat it as a marketing message. |
| 409 | auto_ | Creating or resuming needs auto top-up, and yours isn't set up to pay for it. | Set up auto top-up in the portal, then try again. |
| 409 | not_ | The recurring campaign was deleted. | Create a new one. |
Every code is on Errors and limits.