Skip to content
Codelia SMSDocs
Guides: Transactional messages

Transactional messages

Every message you send is either a marketing message or a transactional message. Marketing is the default: it ends with the unsubscribe line, and it's never sent to a number that opted out. A transactional message is for something people need from you. Once your organization is approved, it goes without the unsubscribe line, even to numbers that opted out of your marketing messages, and you can send it to anyone a marketing message can reach: one number, several, or your lists.

When to use one

Send a transactional message when the person is waiting for it, or would want it whatever their marketing choice:

  • a sign-in code;
  • an order update, like "Your order 1042 has shipped";
  • an appointment change or reminder.

Don't use it for promotions, offers or news. Those are marketing messages: they end with the unsubscribe line, and they skip everyone who opted out.

Get access

Transactional messages need approval for your organization, once. Until then, a request with type: "transactional" is refused with 403 and feature_not_enabled, and nothing is sent, scheduled or charged.

  1. Request access under Features on the Organization page in the portal. Tell us what you'll send, with two example messages, how people give you their number, how many messages you send a month, the countries you send to and your website. You need permission to manage the organization; if you don't have it, ask someone who does. Requests are made in the portal only: the features endpoints take a sign-in session, and an API key is refused with 403 and api_key_not_allowed.
  2. We review the request and email the decision to you and your organization's owners. The Organization page shows where it stands, and the reason if it isn't approved. You can change your answers and request again.
  3. Once approved, any API key with messages:send can send transactional messages.

The refusal is stored under its Idempotency-Key, like any answer, and the same key returns it again for 24 hours. After approval, send with a new Idempotency-Key.

Send one

Add type: "transactional" to POST /organizations/{accountId}/messages. to takes one number or several, as it does for a marketing message:

curl -X POST "https://api.sms.codelia.studio/v1/organizations/$CODELIA_ACCOUNT_ID/messages" \
  -H "Authorization: Bearer $CODELIA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: appointment-5521-moved" \
  -d '{
  "to": [
    "+442079460123",
    "+442079460124"
  ],
  "from": "InfoSMS",
  "body": "The clinic is closed on October 14. Call us on 020 7946 0000 to move your appointment.",
  "type": "transactional"
}'

The answer has the same shape as for any message you send: one message for each number, each with type set to transactional. The API key needs messages:send, as for any message; there's no separate permission. Your organization needs to be approved first: see Get access.

To price it first, send the same body, type included, to POST /organizations/{accountId}/messages/quote. The price then leaves out the unsubscribe line, as sending it will.

Schedule one

To send a transactional message to your lists, or to schedule one, use the campaign endpoint, POST /organizations/{accountId}/messages/campaigns, with recipients, listIds or both, as for any campaign. This one is scheduled with scheduledAt, and {listId} is read from $LIST_ID. Put your own time in scheduledAt:

curl -X POST "https://api.sms.codelia.studio/v1/organizations/$CODELIA_ACCOUNT_ID/messages/campaigns" \
  -H "Authorization: Bearer $CODELIA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: appointment-2041-reminder" \
  -d '{
  "recipients": [
    {
      "to": "+442079460123"
    }
  ],
  "listIds": [
    "'"$LIST_ID"'"
  ],
  "from": "InfoSMS",
  "body": "From Monday the clinic opens at 10:00, not 9:00. Your appointment time is unchanged.",
  "type": "transactional",
  "scheduledAt": "2027-01-25T09:00:00.000Z"
}'

The answer is 202 with the campaign. It works like any scheduled campaign:

  • scheduledAt must be between 5 minutes and 90 days ahead. Outside that, the answer is 400 with invalid_schedule.
  • Scheduling needs auto top-up. Without it, the answer is 409 with auto_topup_required.
  • Nothing is charged when you schedule it. It's priced and charged when it sends, at that day's price.
  • Approval is checked again when it's due. If your organization isn't approved by then, for example because its access was turned off, it becomes failed, with failureReason: "feature_not_enabled", and nothing is charged. Once your organization is approved, you can send it again.

Leave out scheduledAt to send it now. Everyone on the list gets it, including anyone who opted out of your marketing messages. A recurring campaign can't be transactional: schedule each transactional campaign on its own.

If access is turned off while it's sending

A transactional campaign stops if your organization's access to transactional messages is turned off while it's sending. Messages already handed to the network stay sent. The rest aren't sent and are refunded: each has status failed and errorCode campaign_cancelled. The campaign finishes partial_failure, or failed if nothing had gone yet, with failureReason: "feature_not_enabled", and the campaign.partial_failure or campaign.failed webhook says so.

Once your organization is approved again, send to them with Send to the same people again and "onlyFailed": true. That sends to every message that failed, so it includes any that failed for another reason. A scheduled campaign that stopped before anything went can be sent again instead.

What's different, and what isn't

RuleTransactional messageMarketing message
NumbersThe same as marketingUp to 500 in to, or a campaign's lists
Unsubscribe lineNoneAdded at the end
Counted and pricedWithout itWith the unsubscribe line
Number opted outSentNot sent, and not charged
Can be recurringNoYes

A transactional message is counted and priced on your text alone, so it can take fewer parts than the same text sent as marketing.

Everything else is the same for both: your sender name must be approved, and allowed for the destination country; the countries you can send to are the same; and each part costs the same.

When it's refused

A transactional request that would repeat, or comes before your organization is approved, is refused, never sent as a marketing message instead. Nothing is sent, scheduled or charged.

StatuserrorWhat happenedWhat to do
400transactional_not_repeatableA recurring campaign's send has type set to transactional.Schedule each transactional message on its own, or leave out type to repeat a marketing message.
403feature_not_enabledYour organization isn't approved to send transactional messages. The body's feature is transactional_messages.Request access, or leave out type to send a marketing message.

Find transactional messages

  • On a message. Every message you send has a type: marketing or transactional. Campaigns have one too.
  • In the list. GET /organizations/{accountId}/messages?type=transactional lists only transactional messages; ?type=marketing only marketing ones.
  • In webhooks. The data of message.delivered and message.failed events has a type field, and so does the data of campaign.completed, campaign.partial_failure and campaign.failed. Fields are added to event data over time, as type was, so ignore any field you don't recognize.
  • Sending again. Sending a message or a campaign again keeps its type. A transactional message goes again as a transactional message, without the unsubscribe line.
  • Opt-outs: who your marketing messages skip, and why a transactional message doesn't.
  • Schedule it: how scheduled campaigns are priced, charged and canceled.
  • Webhooks: be told when a transactional message is delivered or fails.