Skip to main content

Interaction Example

Request batch of messages from the queue

GET /queue?take=10

Response:

[
{
"id":6637960,
"settingsId":2441,
"to":{
"id":34521212
},
"variables":{
"tid":"XF5K",
"var1": 10
}
},
{
"id":6637961,
"settingsId":2442,
"to":{
"id":546564534
},
"variables":{
"tid":"XF5L"
}
},
{
"id":6637962,
"settingsId":2442,
"to":{
"id":234345635
},
"variables":{
"tid":"XF5M"
}
}
]

Report dequeued status

POST /events

Request:

[
{
"timestamp": "2021-11-03T19:00:00Z",
"messageId": 6637960,
"status": "dequeued"
},
{
"timestamp": "2021-11-03T19:00:00Z",
"messageId": 6637961,
"status": "dequeued"
},
{
"timestamp": "2021-11-03T19:00:00Z",
"messageId": 6637962,
"status": "dequeued"
}
]

Get settings for messages
It is recommended to cache settings in local database and request settings from API only if there is no local copy

GET /settings/2441

{
"content":{
"en":{
"generalGreeting": "Happy new year!",
"personalGreeting": "Happy new year, {customer.name}!",
"sms":{
"text":"{greeting} Personal variable {var1}! Details: https://t.s1mpl.com/c/{tid}/CX"
}
}
}
}

GET /settings/2442

{
"content":{
"en":{
"generalGreeting": "Dear customer!",
"personalGreeting": "Hello, {customer.name}!",
"sms":{
"text":"{greeting} Text #2! Details: https://t.s1mpl.com/c/{tid}/CY"
}
}
}
}

Customer 34521212 has customer.name value John
Customer 546564534 has customer.name value Mr. Edwards
Customer 234345635 has not customer.name value defined

SMS text for customer 34521212:

Happy new year, John! Personal variable 10! Details: https://t.s1mpl.com/c/XF5K/CX

SMS text for customer 546564534 :

Hello, Mr. Edwards! Text #2! Details: https://t.s1mpl.com/c/XF5L/CY

SMS text for customer 234345635 :

Dear customer! Text #2! Details: https://t.s1mpl.com/c/XF5M/CY

Report sent status
Intermediate statuses also could be reported e. g. sending, accepted

POST /events

Request:

[
{
"timestamp": "2021-11-03T19:10:00Z",
"messageId": 6637960,
"status": "sent"
},
{
"timestamp": "2021-11-03T19:10:03Z",
"messageId": 6637961,
"status": "sent"
},
{
"timestamp": "2021-11-03T19:10:11Z",
"messageId": 6637962,
"status": "sent"
}
]

Report delivery status on update from provider

POST /events

Request:

[
{
"timestamp": "2021-11-03T20:03:10Z",
"messageId": 6637960,
"status": "delivered",
"channel": "sms",
"reportedAt": "2021-11-03T21:00:00Z"
},
{
"timestamp": "2021-11-03T20:15:47Z",
"messageId": 6637961,
"status": "delivered",
"channel": "sms",
"reportedAt": "2021-11-03T21:00:00Z"
},
{
"timestamp": "2021-11-03T20:16:12Z",
"messageId": 6637962,
"status": "delivered",
"channel": "sms",
"reportedAt": "2021-11-03T21:00:00Z"
}
]