Activity

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-activity

Request parameters

Query parameterTypeRequiredLimitationsDetails
sms_number_idstringno
date_fromintnoTimestamp is assumed to be UTC. Must be lower than date_toFormat: 1443651141
date_tointnoTimestamp is assumed to be UTC. Must be higher than date_fromFormat: 1443651141
status[]string[]noPossible types: processed,queued,sent,delivered, failed
pageintno
limitintnoMin: 10, Max: 100Default: 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);

More examplesopen in new window

import 'dotenv/config';
import { MailerSend, SmsActivityStatusType } from "mailersend";

const mailerSend = new MailerSend({
  apiKey: process.env.API_KEY,
});

mailerSend.sms.activity.list({
  sms_number_id: "number_id",
  status: [SmsActivityStatusType.SENT, SmsActivityStatusType.DELIVERED],
  limit: 10,
  page: 1
})
  .then((response) => console.log(response.body))
  .catch((error) => console.log(error.body));

More examplesopen in new window

from mailersend import sms_activity

api_key = "API key here"

mailer = sms_activity.NewSmsActivity(api_key)

#Request parameters
sms_number_id = 1365743
date_from = 1655157601
date_to = 1655158601
status = ["queued", "failed"]
page = 1
limit = 200

print(mailer.get_activities(sms_number_id=sms_number_id, date_from=date_from, date_to=date_to, status=status, page=page, limit=limit))

More examplesopen in new window

package main

import (
	"context"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

var APIKey = "Api Key Here"

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(APIKey)

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	options := &mailersend.SmsActivityOptions{}
	
	_, _, err := ms.SmsActivityService.List(context.TODO(), options)
	if err != nil {
		log.Fatal(err)
	}
}

More examplesopen in new window

import com.mailersend.sdk.MailerSend;
import com.mailersend.sdk.exceptions.MailerSendException;
import com.mailsend.sdk.sms.activities.SmsActivityList;
import com.mailsend.sdk.sms.activities.SmsActivity;

public void getActivities() {
    
    MailerSend ms = new MailerSend();
    ms.setToken("mailersend token");
    
    try {
        
        SmsActivityList list = ms.sms().activities().getActivities();
            
        for (SmsActivity activity : lists.smsActivities) {
            System.out.println(activity.id);
            System.out.println(activity.content);
        }
        
    } catch (MailerSendException e) {
        
        e.printStackTrace();
    }
}

More examplesopen in new window

require "mailersend-ruby"

# Intialize the SMS Recipient class
ms_sms_activity = Mailersend::SMSActivity.new

# Add parameters
ms_sms_activity.list(page: 1, limit: 10)

More examplesopen in new window

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",
			"content": "Lorem Ipsum is simply dummy text",
			"status": "delivered",
            "sms_message_id": "62134a2d7de3253bf10d6642"
		},
        {
          "from": "+18332647501",
          "to": "+16203221059",
          "created_at": "2022-02-21T08:15:42.508000Z",
          "content": "Lorem Ipsum is simply dummy text",
          "status": "processed",
          "sms_message_id": "62134a2d7de3253bf10d6642"
        },
        {
          "from": "+18332647501",
          "to": "+16203221059",
          "created_at": "2022-02-21T08:15:42.579000Z",
          "content": "Lorem Ipsum is simply dummy text",
          "status": "queued",
          "sms_message_id": "62134a2d7de3253bf10d6642"
        },
        {
          "from": "+18332647501",
          "to": "+16203221059",
          "created_at": "2022-02-21T08:15:43.624000Z",
          "content": "Lorem Ipsum is simply dummy text",
          "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,
		"from": 1,
		"path": "https:\/\/api.mailersend.com\/v1\/sms-activity",
		"per_page": 25,
		"to": 1
	}
}

Error

Response Code: 422 Unprocessable Entity

See - 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 parameterTypeRequiredLimitationsDetails
sms_message_idstringyes
import 'dotenv/config';
import { MailerSend } from "mailersend";

const mailerSend = new MailerSend({
  apiKey: process.env.API_KEY,
});

mailerSend.sms.activity.single("sms_message_id")
  .then((response) => console.log(response.body))
  .catch((error) => console.log(error.body));

More examplesopen in new window

from mailersend import sms_activity

api_key = "API key here"

mailer = sms_activity.NewSmsActivity(api_key)

#Request parameters
sms_message_id = "62a9d12b07852eaf2207b417"

print(mailer.get_activity(sms_message_id))

More examplesopen in new window

package main

import (
	"context"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

var APIKey = "Api Key Here"

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(APIKey)

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	_, _, err := ms.SmsActivityService.Get(context.TODO(), "message-id")
	if err != nil {
		log.Fatal(err)
	}
}

More examplesopen in new window

import com.mailersend.sdk.MailerSend;
import com.mailersend.sdk.exceptions.MailerSendException;
import com.mailsend.sdk.sms.activities.SmsActivity;

public void getActivity() {
    
    MailerSend ms = new MailerSend();
    ms.setToken("mailersend token");
    
    try {
        
        SmsActivity activity = ms.sms().activities().getMessageActivity("message id");
            
        System.out.println(activity.id);
        System.out.println(activity.content);
        
    } catch (MailerSendException e) {
        
        e.printStackTrace();
    }
}

More examplesopen in new window

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",
        "status": "delivered",
        "segment_count": 1,
        "error_type": null,
        "error_description": null
      }
    ],
    "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: 422 Unprocessable Entity

See - Validations errors

Last Updated: