Activity

Get information about your domain activity, including your sent emails and whether they were received by the recipient. You can also see whether they opened or clicked on any of the email content.

Get a list of activities

With this endpoint, you can retrieve every single data point of the activity that happened for a specific domain.

Obtain a list of activities with the following GET request:

GET https://api.mailersend.com/v1/activity/{domain_id}

Request parameters

URL parameterTypeRequiredLimitationsDetails
domain_idstringyes
Query parameterTypeRequiredLimitationsDetails
pageintno
limitintnoMin: 10, Max: 100Default: 25
date_fromintnoTimestamp is assumed to be UTC. Must be lower than date_to.Format: 1443651141
date_tointnoTimestamp is assumed to be UTC. Must be higher than date_from.Format: 1443651141
event[]string[]noPossible types: processed,queued,sent,delivered,soft_bounced,
hard_bounced,junk,opened,clicked,unsubscribed,
spam_complaints
use MailerSend\MailerSend;
use MailerSend\Helpers\Builder\ActivityParams;

$mailersend = new MailerSend(['api_key' => 'key']);

$activityParams = (new ActivityParams())
                    ->setPage(3)
                    ->setLimit(15)
                    ->setDateFrom(1623073576)
                    ->setDateTo(1623074976)
                    ->setEvent(['processed', 'sent']);

$mailersend->activity->getAll('domainId', $activityParams);

More examplesopen in new window

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.activityList({
  domain_id: "xxx",
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

More examplesopen in new window

from mailersend import activity

api_key = "API key here"

mailer = activity.NewActivity(api_key)

mailer.get_domain_activity("domain-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()

	from := time.Now().Add(-24 * time.Hour).Unix()
	to := time.Now().Unix()
	domainID := "domain-id"

	options := &mailersend.ActivityOptions{
		DomainID: domainID,
		DateFrom: from, 
		DateTo: to,
	}
	
	_, _, err := ms.Activity.List(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}

More examplesopen in new window

import com.mailersend.sdk.ActivitiesList;
import com.mailersend.sdk.MailerSend;
import com.mailersend.sdk.MailerSendResponse;
import com.mailersend.sdk.exceptions.MailerSendException;

public void getActivities() {

    MailerSend ms = new MailerSend();

    ms.setToken("Your API token");

    try {
    
        ActivitiesList activities = ms.activities().getActivities("domain id");

        for (Activity activity : activities.activities) {

            System.out.println(activity.id);
            System.out.println(activity.createdAt.toString());

            System.out.println(activity.email.from);
            System.out.println(activity.email.subject);
            System.out.println(activitiy.email.recipient.email);
        }

        
    } catch (MailerSendException e) {

        e.printStackTrace();
    }
}

More examplesopen in new window

require "mailersend-ruby"

ms_activity = Mailersend::Activity.new
ms_activity.get(domain_id: "xxx2241ll", page: 3, limit: 5, date_from: 1620643567, date_to: 1623321967)

More examplesopen in new window

Responses

Valid

Response Code: 200 OK
Response Headers:
	Content-Type: application/json
{
	"data" : [
		{
      "id": "5ee0b166b251345e407c9207",
      "created_at": "2020-06-04 12:00:00",
      "updated_at": "2020-06-04 12:00:00",
      "type": "clicked",
      "email": {
        "id": "5ee0b166b251345e407c9201",
        "from": "colleen.wiza@example.net",
        "subject": "Magni aperiam sunt nam omnis.",
        "text": "Perferendis iure deleniti itaque occaecati mollitia quis aliquid.",
        "html": "<html></html>",
        "status": "sent",
        "tags": null,
        "created_at": "2020-06-04 12:00:00",
        "updated_at": "2020-06-04 12:00:00",
        "recipient": {
          "id": "5ee0b166b251345e407c9200",
          "email": "tyra.cummerata@example.org",
          "created_at": "2020-06-04 12:00:00",
          "updated_at": "2020-06-04 12:00:00",
          "deleted_at": ""
        }
      }
    },
	],
	"links": {
    "first": "https:\/\/api.mailersend.com\/v1\/activity\/8jk1o5?page=1",
    "last": "https:\/\/api.mailersend.com\/v1\/activity\/8jk1o5?page=1",
    "prev": null,
    "next": null
  },
  "meta": {
    "current_page": 1,
    "from": 1,
    "path": "https:\/\/api.mailersend.com\/api\/v1\/activity\/8jk1o5",
    "per_page": 25,
    "to": 1
  }
}

Error

Response Code: 422 Unprocessable Entity

See - Validations errors

Last Updated: