SMS API
Activity
Track your messages with the SMS Activity API endpoint. Get a list of activities or view the activity of a single message. Upgrade your communication strategy with MailerSend.
Get information about your SMS activity, including your sent SMS messages, and whether they were received by the recipient.
Get a list of activities
With this endpoint, you can retrieve every single data point of the activity that happened for a specific phone number.
Get a list of activities with the following GET request:
GET https://api.mailersend.com/v1/sms-activityRequest parameters
| Query parameter | Type | Required | Limitations | Details |
|---|---|---|---|---|
sms_number_id | string | no | ||
date_from | int|string | no | Timestamp is assumed to be UTC. Must be lower than date_to | Unix timestamp (1443651141), ISO 8601 (2015-09-30T22:12:21Z) or Y-m-d H:i:s (2015-09-30 22:12:21) |
date_to | int|string | no | Timestamp is assumed to be UTC. Must be higher than date_from | Unix timestamp (1443651141), ISO 8601 (2015-09-30T22:12:21Z) or Y-m-d H:i:s (2015-09-30 22:12:21) |
status[] | string[] | no | Possible types: processed,queued,sent,delivered, failed | |
page | int | no | Min: 1, Max: 1000 | To reach older activity beyond the last page, narrow date_from and date_to |
limit | int | no | Min: 10, Max: 100 | Default: 25 |
use MailerSend\MailerSend;
use MailerSend\Helpers\Builder\SmsActivityParams;
$mailersend = new MailerSend(['api_key' => 'key']);
$smsActivityParams = (new SmsActivityParams())
->setSmsNumberId('sms_number_id')
->setDateFrom(1623073576)
->setDateTo(1623074976)
->setStatus(['queued', 'delivered'])
->setPage(3)
->setLimit(15);
$smsActivity = $mailersend->smsActivity->getAll($smsActivityParams);Responses
Valid
Response Code: 200 OK
Response Headers:
content-type: application/json{
"data": [
{
"from": "+18332647501",
"to": "+16203221059",
"created_at": "2022-02-21T08:15:46.627000Z",
"status": "delivered",
"sms_message_id": "62134a2d7de3253bf10d6642"
},
{
"from": "+18332647501",
"to": "+16203221059",
"created_at": "2022-02-21T08:15:42.508000Z",
"status": "processed",
"sms_message_id": "62134a2d7de3253bf10d6642"
},
{
"from": "+18332647501",
"to": "+16203221059",
"created_at": "2022-02-21T08:15:42.579000Z",
"status": "queued",
"sms_message_id": "62134a2d7de3253bf10d6642"
},
{
"from": "+18332647501",
"to": "+16203221059",
"created_at": "2022-02-21T08:15:43.624000Z",
"status": "sent",
"sms_message_id": "62134a2d7de3253bf10d6642"
}
],
"links": {
"first": "https:\/\/api.mailersend.com\/v1\/sms-activity?page=1",
"last": null,
"prev": null,
"next": "https:\/\/api.mailersend.com\/v1\/sms-activity?page=2"
},
"meta": {
"current_page": 1,
"current_page_url": "https:\/\/api.mailersend.com\/v1\/sms-activity?page=1",
"from": 1,
"path": "https:\/\/api.mailersend.com\/v1\/sms-activity",
"per_page": 25,
"to": 1
}
}Error
Response Code: 422 Unprocessable EntitySee - Validations errors
Get activity of a single message
With this endpoint, you can get every single activity data point that happened to a specific SMS message.
Get a list of activities for the SMS message specified with this GET request:
GET https://api.mailersend.com/v1/sms-messages/{sms_message_id}Request parameters
| URL parameter | Type | Required | Limitations | Details |
|---|---|---|---|---|
sms_message_id | string | yes |
import 'dotenv/config';
import { MailerSend } from "mailersend";
const mailerSend = new MailerSend({
apiKey: process.env.API_KEY,
});
mailerSend.sms.message.single("sms_message_id")
.then((response) => console.log(response.body))
.catch((error) => console.log(error.body));Responses
Valid
Response Code: 200 OK
Response Headers:
content-type: application/json{
"data": {
"id": "62134a2d7de3253bf10d6642",
"from": "+18332647501",
"to": ["+16203221059", "+18044064234"],
"text": "Lorem Ipsum is simply dummy text",
"paused": false,
"created_at": "2022-02-21T08:15:41.339000Z",
"sms": [
{
"id": "62134a2e4709ec689f72ea62",
"from": "+18332647501",
"to": "+16203221059",
"text": "Lorem Ipsum is simply dummy text",
"compiled_text": "Lorem Ipsum is simply dummy text",
"status": "delivered",
"segment_count": 1,
"error_type": null,
"error_code": null,
"error_description": null,
"created_at": "2022-01-01T12:00:00.000000Z"
}
],
"sms_activity": [
{
"from": "+18332647501",
"to": "+16203221059",
"created_at": "2022-02-21T08:15:46.627000Z",
"status": "delivered",
"sms_message_id": "62134a2d7de3253bf10d6642"
},
{
"from": "+18332647501",
"to": "+16203221059",
"created_at": "2022-02-21T08:15:42.508000Z",
"status": "processed",
"sms_message_id": "62134a2d7de3253bf10d6642"
},
{
"from": "+18332647501",
"to": "+16203221059",
"created_at": "2022-02-21T08:15:42.579000Z",
"status": "queued",
"sms_message_id": "62134a2d7de3253bf10d6642"
},
{
"from": "+18332647501",
"to": "+16203221059",
"created_at": "2022-02-21T08:15:43.624000Z",
"status": "sent",
"sms_message_id": "62134a2d7de3253bf10d6642"
}
]
}
}Error
Response Code: 404 Not Found