Skip to content
Codelia SMSDocs
Guides: Recurring campaigns

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 /organizations/{accountId}/messages/recurring. 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"'"
    ]
  }
}'

The answer is 201 with the recurring campaign: keep its id.

  • send is the body a campaign takes, without scheduledAt: the rule decides when it sends. A send with scheduledAt is refused with 400 and invalid_recurrence.
  • It sends marketing messages only. A send with type: "transactional" is refused with transactional_not_repeatable.
  • Creating one needs auto top-up, set up in the portal. Without it, the answer is 409 with auto_topup_required.
  • Nothing is charged when you create it.
  • startsAt is optional: the rule counts forward from it, and from now if you leave it out.
  • endsAt and maxOccurrences are optional, and end it on its own: nothing is sent after endsAt, and it stops once it has created maxOccurrences campaigns (1 to 1,000; a skipped time doesn't count). Then its status becomes ended. An endsAt that isn't after startsAt, or comes before the first time the rule names, is refused with 400 and invalid_recurrence.

The rule

frequencyWhat else the rule needs
weeklybyWeekday: one or more of mon, tue, wed, thu, fri, sat and sun, each once. All seven is every day: there's no daily rule.
monthlybyMonthDay: 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.
yearlybyMonth, 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/London. 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 birthday thisMonth is 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/Nicosia is two or three hours ahead of UTC, so there, send at 03:00 or later.
  • 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 status becomes stopped.
  • When it reaches its endsAt or maxOccurrences, it ends, and its status becomes ended. The end is recorded in your activity log.

Each campaign it creates has its recurringCampaignId. List them with GET /organizations/{accountId}/messages/campaigns?recurringCampaignId=…, 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"

GET /organizations/{accountId}/messages/recurring/{id} gets one: its rule, what it sends, nextRunAt, and how many campaigns it has created, in occurrenceCount.

statusWhat it means
activeRunning. nextRunAt is when it's next due.
pausedYou paused it. It creates nothing until you resume it.
stoppedThree in a row failed, so it stopped. Fix the cause, then resume it.
endedIt 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"
  • Change it with PATCH /organizations/{accountId}/messages/recurring/{id} and any of rule, startsAt, endsAt, maxOccurrences and send; null removes endsAt or maxOccurrences. 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 /organizations/{accountId}/messages/recurring/{id}/resume. 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. A stopped campaign resumes this way too, and so does an ended one once you've moved its endsAt or raised its maxOccurrences; before that, resuming it is refused with 400 and invalid_recurrence.
  • Delete it with DELETE /organizations/{accountId}/messages/recurring/{id}. It stops for good, and any campaign it created that hasn't sent yet is canceled. The answer counts those in cancelledOccurrences. Campaigns that already went out are unchanged. Changing, pausing or resuming it afterwards answers 409 with not_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.

StatuserrorWhat happenedWhat to do
400invalid_recurrenceThe 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.
400transactional_not_repeatableA recurring campaign's send has type set to transactional.Schedule each transactional message on its own, or repeat it as a marketing message.
409auto_topup_requiredCreating 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.
409not_editableThe recurring campaign was deleted.Create a new one.

Every code is on Errors and limits.