Skip to content

SmsSendFromTemplate

POST sms/message/fromTemplate

Queues a message whose text comes from a template and the data object. Everything else — checks, routing, queue — is the same as in SmsSendMessage.

The message class defaults to the class of the template, so a template marked TRANSACTIONAL keeps working for customers who opted out of marketing.

Access Control

Allowed roles: admin, leader, manager.

Request

POST https://{broker_domain}/sms/message/fromTemplate
{
  "templateId": 4,
  "sendToParentType": "CUSTOMER",
  "sendToParentId": 140,
  "phone": "+380951234567",
  "data": {
    "name": "John",
    "amount": "250 EUR"
  }
}
{
  "command": "SmsSendFromTemplate",
  "extID": "1",
  "data": {
    "templateId": 4,
    "sendToParentType": "CUSTOMER",
    "sendToParentId": 140,
    "phone": "+380951234567",
    "data": {
      "name": "John",
      "amount": "250 EUR"
    }
  }
}
const res = await platform.SmsSendFromTemplate({
  templateId: 4,
  sendToParentType: "CUSTOMER",
  sendToParentId: 140,
  phone: "+380951234567",
  data: {
    name: "John",
    amount: "250 EUR"
  }
});

Request Data

Field Type Required Description
templateId int Yes Template to render
sendToParentType enum Yes CUSTOMER, MANAGER, or LEAD
sendToParentId int Yes Id of the recipient record
phone string Yes Destination number
data object No Placeholder values for the template
profileId int No Explicit provider profile
agentId int No Explicit agent link for INDIVIDUAL profiles
kind enum No TRANSACTIONAL ignores send windows and marketing opt-outs; MARKETING is the default
sendAt string No Defer sending: ISO 8601 or YYYY-MM-DD HH:mm:ss, not further than [sms] maxScheduleDays
idempotencyKey string No Repeating a request with the same key returns the same message instead of sending a second one
truncate bool No Truncate the text to [sms] maxParts instead of rejecting it with MESSAGE_TOO_LONG

Behavior

  • Unresolved placeholders do not block the send: they come back in missingPlaceholders, and the text keeps the raw placeholder. A silent empty string would ship a message reading "Dear , your deposit of is confirmed".
  • Use SmsPreviewMessage to see the rendered text and its segment count before sending.

Response Data

{
  "smsId": 813,
  "status": "PENDING",
  "message": "John, your deposit of 250 EUR is confirmed",
  "kind": "TRANSACTIONAL",
  "encoding": "GSM7",
  "parts": 1,
  "missingPlaceholders": [],
  "scheduledFor": null,
  "scheduleReason": "IMMEDIATE",
  "idempotent": false
}

Errors

Code Error Description
404 TEMPLATE_NOT_FOUND Template not found in the brand, or disabled
400 INVALID_PHONE Number cannot be parsed
400 IMPOSSIBLE_PHONE Number length does not match the numbering plan of its country
400 INVALID_SEND_AT sendAt is unparsable, in the past, or beyond maxScheduleDays
403 PHONE_BLACKLISTED Destination is blacklisted or opted out; the message says which, and an opt-out blocks only MARKETING
404 NOT_FOUND Profile, provider, template, or agent not found
409 MESSAGE_TOO_LONG Text exceeds [sms] maxParts segments and truncate was not set
409 DUPLICATE_MESSAGE The same text to the same number inside the duplicate window
409 COUNTRY_NOT_ALLOWED Destination is not allowed for the profile
409 NO_ROUTE_AVAILABLE No profile of the brand can send to this destination
500 MISSING_CREDENTIALS Profile credentials are incomplete for this adapter