Mailprotector

Mailprotector API

The Mailprotector API offers a RESTful interface mirroring most console functions, requiring Bearer token authentication via API keys tied to manager roles accessible through the web console, and supports filtering list requests by entity fields through query parameters.

Public

Documentation Settings

ENVIRONMENT

Production

LAYOUT

Double Column

LANGUAGE

cURL - cURL

Mailprotector API

Introduction

Authentication

List Request Parameters

Filtering Logs

Resellers

Customers

Domains

User Groups

Users

Managers

Results

Mailprotector API

The Mailprotector API is structured in a way to provide most console functionality through a RESTful interface. Access to some endpoints may be restricted for API keys belonging to managers with certain permissions. For any questions or suggestions, please create a new ticket with our support team: https://support.mailprotector.com/hc/en-us/requests/new.

Authentication

Authentication for all requests is granted via a Bearer token in the header of a request. Each manager account is provisioned with an API key for each active role which can be accessed via the web console.

To find the key of the current manager account, first log in to your manager account in the web console, then click on "Edit my profile" under the dropdown at the upper right corner of the page (logged in users can also go to https://emailservice.io/profile ). Once there, click the "..." button on the role that you would like to utilize in the API, and click the "View API Key" option.

The token will provide the same permissions as the role whose key is being used. The request's header should have the following field provided for every request.

Plain Text

"Authorization": "Bearer {{your_api_key_here}}"

List Request Parameters

All GET request routes which provide a list of entities (i.e. GET users) can be optionally filtered using query parameters which map to a field on the entity being requested. For example, when requesting a list of users, the first_name field can be filtered on by using the following URL:

Plain Text

"emailservice.io/api/v1/domains/{{domain_id}}/users?first_name={{first_name}}"

Results can also be filtered down based on the date or datetime the objects were created or updated. Five comparisons for dates/datetimes can be made:

AbbreviationFunction
GeGreater than
GeqGreater than or equal
LeLess than
LeqLess than or equal
EqExactly equals

As an example, to find a list of users created on or after a certain date, you could use the following URL:

Plain Text

"emailservice.io/api/v1/domains/{{domain_id}}/users?created_at[geq]=2018-01-01"

All returned lists will include information about the current status of the paging through the response headers. Below is an example of what is returned under the "X-Pagination" key in the response headers.

Plain Text

{
   "total":41,
   "total_pages":2,
   "per_page":25,
   "first_page":true,
   "last_page":false,
   "previous_page":null,
   "current_page":1,
   "next_page":2,
   "out_of_range":false
}

The returned pages can be manipulated through the combination of the page and per_page keys. By default, these values are 1 and 25 respectively.

Filtering Logs

The logs endpoints for each entity can be filtered using the same criteria as the web console.

View More

OptionsPossible Values
sort_direction"desc" (default), "asc"
sort_field"@timestamp" (default) <br>"prime.direction" - Sort by inbound/outbound messages <br>"prime.from_header_raw" - Sort by from address <br>"prime.recipient" - Sort by to address <br>"prime.subject" - Sort by subject line <br>"prime.decision" - Sort by decision on messages (i.e "deliver" vs "quarantine_spam", etc) <br>"prime.score" - Sort by the score of each message
pageint (default of 1)
page_sizeint (default of 25)
senderstring (optional)
recipientstring (optional)
subjectstring (optional)
decision"all" (default),"deliver", "quarantine_spam", "quarantine_virus", <br>"quarantine_policy", "bounce", "encrypt", "delete"
direction"inbound", "outbound" (leave blank to retrieve both)
date_range_type"relative" - Relative to the date_range_minutes provided <br>"custom" - Absolute time provided as start_datetime and end_datetime parameters
date_range_minutesint (defaults to 15). Only used if date_range_type is "relative".
start_datetimeiso8601 formatted datetime. Defaults to 15 minutes prior to the request being made.
end_datetimeiso8601 formatted datetime. Defaults to the time of the request if not provided.

An example request may look like the following:

View More

Plain Text

emailservice.io/domains/{{domain_id}}/logs?sort_direction=desc&sort_field=@timestamp&page=1&sender=address&recipient=address&subject=subject&decision=deliver&direction=inbound&date_range_type=relative&date_range_minutes=30&start_datetime=2020-01-21T22:01:09Z&end_datetime=2020-01-21T22:16:09Z

AUTHORIZATIONBearer Token

Token

{{your_api_key_here}}