Activity
Retrieve a list of activities to easily view information about your domain activity including sent emails and their statuses. Learn more with our API documentation.
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 parameter | Type | Required | Limitations | Details |
|---|---|---|---|---|
domain_id | string | yes |
| Query parameter | Type | Required | Limitations | Details |
|---|---|---|---|---|
page | int | no | Min: 1 | |
limit | int | no | Min: 10, Max: 100 | Default: 25 |
date_from | int|string | yes | Timestamp is assumed to be UTC. Must be lower than date_to. | Unix timestamp: 1443651141 or datetime: 2015-10-01 00:00:00 |
date_to | int|string | yes | Timestamp is assumed to be UTC. Must be higher than date_from. The allowed timeframe depends on your plan's data retention limit (1–30 days). | Unix timestamp: 1443651141 or datetime: 2015-10-01 23:59:59 |
event[] | string[] | no | Possible types: queued,sent,delivered,soft_bounced,hard_bounced,deferred, opened,opened_unique,clicked,clicked_unique,unsubscribed,spam_complaints,survey_opened, survey_submitted |
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(['sent', 'delivered']);
$mailersend->activity->getAll('domainId', $activityParams);import 'dotenv/config';
import { MailerSend, ActivityEventType } from "mailersend";
const mailerSend = new MailerSend({
apiKey: process.env.API_KEY,
});
const queryParams = {
limit: 10, // Min: 10, Max: 100, Default: 25
page: 2,
date_from: 1443651141, // Unix timestamp
date_to: 1443651141, // Unix timestamp
event: [ActivityEventType.SENT, ActivityEventType.SOFT_BOUNCED]
}
mailerSend.email.activity.domain("domain_id", queryParams)
.then((response) => console.log(response.body))
.catch((error) => console.log(error));from mailersend import MailerSendClient, ActivityBuilder
from datetime import datetime, timedelta
ms = MailerSendClient()
# Get activities from last 7 days (maximum allowed timeframe)
date_from = int((datetime.now() - timedelta(days=7)).timestamp())
date_to = int(datetime.now().timestamp())
request = (ActivityBuilder()
.domain_id("domain-id")
.date_from(date_from)
.date_to(date_to)
.page(1)
.limit(25)
.build_list_request())
response = ms.activities.get(request)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)
}
}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();
}
}require "mailersend-ruby"
ms_activity = Mailersend::Activity.new
ms_activity.get(domain_id: "xxx2241ll", page: 3, limit: 5, date_from: 1620643567, date_to: 1623321967)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": "Lorem ipsum dolor sit amet, consectetuer adipiscin",
"html": "<html><body><a href='https://www.mailersend.com' t",
"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 EntitySee - Validations errors
Get a single activity
If you want to retrieve a single activity, use this GET request:
GET https://api.mailersend.com/v1/activities/{activity_id}Request parameters
| URL parameter | Type | Required | Limitations | Details |
|---|---|---|---|---|
activity_id | string | yes |
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": "Lorem ipsum dolor sit amet, consectetuer adipiscin",
"html": "<html><body><a href='https://www.mailersend.com' t",
"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": ""
}
}
}
}Error
Response Code: 404 Not FoundSMTP relay
Use Simple Mail Transfer Protocol when you want to quickly send emails using a reliable Internet standard. Our SMTP relay service takes care of your email delivery so you don’t have to manage an email server.
Analytics
Track the performance of your transactional emails with MailerSend's Analytics API endpoint. Discover opens by country, email activity and more.