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 parameter | Type | Required | Limitations | Details |
---|---|---|---|---|
domain_id | string | yes |
Query parameter | Type | Required | Limitations | Details |
---|---|---|---|---|
page | int | no | ||
limit | int | no | Min: 10 , Max: 100 | Default: 25 |
date_from | int | yes | Timestamp is assumed to be UTC . Must be lower than date_from . | Format: 1443651141 |
date_to | int | yes | Timestamp is assumed to be UTC . Must be higher than date_to . The timeframe between date_from and date_to should be at max 7 days. | Format: 1443651141 |
event[] | string[] | no | Possible types: queued ,sent ,delivered ,soft_bounced ,hard_bounced ,opened ,clicked ,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 activity
api_key = "API key here"
mailer = activity.NewActivity(api_key)
mailer.get_domain_activity("domain-id")
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 Entity
See - 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 Found