Guide — Post-Delivery Quarantine
Overview¶
This guide explains how to use the Email Post-delivery Quarantine API. After reading this guide, you should be able to get details of messages in Email Post-delivery Quarantine and perform actions such as releasing a message, deleting a message.
Pre-requisites¶
You must have a set of API credentials (service principal) to be able to call the Email Post-delivery Quarantine API. For more information refer to the appropriate quick start guide:
- Sophos Partners: Read the Partner Getting Started guide first.
- Enterprise customers: If you use Sophos Enterprise to manage multiple tenants, read the Organization Getting Started guide first.
- Other customers: Read the Tenant Getting Started guide first.
Terminology¶
Before you use the Email Post-delivery Quarantine API, here are a few terms you should know:
- Quarantined Message: A message for an email address, which was quarantined post delivery to mailbox.
- ID: The value of ‘x-sophos-email-id’ MIME header.
Making API requests¶
You can make the API calls in the next few sections using cURL. Follow the instructions on cURL's website to install this tool.
When using curl, a request to the Email Post-delivery Quarantine API has the following general form:
curl -X <method> -H "Authorization: Bearer <jwt>" -H "X-Tenant-ID: <tenant-id>" <data-region>/<path>
The command includes the following placeholders:
<method>: The request method. For the Endpoint API, this is eitherGETorPOST.<tenant-id>: The ID of the tenant you want to query.<jwt>: The JWT access token returned when the IDP authenticates the service principal.<data-region>: The regional API host in the data geography where the tenant data is located.<path>: The request path for the API operation, for example/email/v1/post-delivery-quarantine/messages/search.
The API descriptions in this guide only specify the request method and path. For example:
POST /email/v1/post-delivery-quarantine/messages/search
To make an actual API request, you must expand this to the full form shown above.
All API requests return HTTP status codes 200 or 201 when successful.
Email Post-delivery Quarantine operations¶
List messages¶
To list messages, call:
POST /email/v1/post-delivery-quarantine/messages/search
Request:
{
"beginDate": "2012-06-26T11:55:36.100Z", //Messages quarantined on or after this date will be included in the response. Used along with 'endDate' parameter.
"endDate": "2012-06-26T11:55:36.100Z", //Messages quarantined on or before this date will be included in the response. Used along with 'beginDate' parameter.
"page": 1, //The 1-based index of the page to fetch.
"pageSize": 50, //The size of the page to fetch.
"sort": [
"forRecipient:DESC" //Defines how to sort the data.
],
"filter": { //Filtering conditions.
"id": "15a7f8ea-691c-4f03-862e-3cefb102818e", //ID from 'X-Sophos-Email-ID' header.
"fromContains": "some text", //Return all rows which contains the provided text in from field.
"toContains": "some text", //Return all rows which contains the provided text in to field.
"subjectContains": "some text", //Return all rows which contains the provided text in subject field.
"attachmentNameContains": "some text", //Return all rows which contains the provided text in attachment names.
"sizeInMBGreaterThan": 1, //Return all rows where the message size in MB is greater than the provided value.
"sizeInMBLowerThan": 2, //Return all rows where the message size in MB is less than the provided value.
"productType": "mailflow", //Type of email product.
"reason": ["malware"], //Return all rows where the reason matched the reason for quarantined
"hasAnyAttachment": false //Return all rows where email has at least one attachment
}
}
Response: This contains a list of post-delivery quarantined messages.
{
"items": [
{
"id": "90323e39-c4fe-457a-819d-642c48c03e1f", // The value of ‘x-sophos-email-id’ MIME header.
"mimeMessageId": "<1089064268.5.1660605924821@ip-10-104-116-115>", // The value of 'message-id' MIME header.
"o365MessageId": "AAkALgAAAAAAHYQDEapmEc2byACqAC-EWg0A2KWOwYCMcEKsJk-m9FRZ8QAAfOd_2wAA", // The value of '0365-message-id'.
"envelopeSender": { //Email address using in 'MAIL FROM' command.
"localAddress": "user1",
"domainAddress": "test.com"
},
"to": [ // Names and email addresses in the 'To' MIME header.
{
"name": "user name",
"localAddress": "user_2",
"domainAddress": "dev.euw.emailblr1.com"
}
],
"cc": [ // Names and email addresses in the 'Cc' MIME header.
{
"name": "user name",
"localAddress": "admin",
"domainAddress": "dev.euw.emailblr1.com"
}
],
"subject": "user name", //Subject of the message.
"sizeInBytes": 70, // Size of the message in bytes.
"clientIp": "64.86.143.204", //IP address from which the message was sent.
"sentAt": "2022-12-18T10:36:32.664Z", //Timestamp from the 'Date' MIME header.
"quarantinedAt": "2022-12-18T10:36:37.422Z", //Timestamp the message was quarantined post delivery.
"productType": "gateway", // Email product type. Either 'gateway' or 'mailflow'
"attachments": { // Information about the attachments in the message
"total": 0,
"size": 0
},
"forRecipient": "neo_dl@dev.euw.emailblr1.com", //Recipient for whom the message was quarantined.
"reason": "maliciousUrl" //Reason for quarantining the message.
}
],
"pages": {
"current": 1, //The 1-based page number being returned.
"size": 1, // The page size. You can change this by passing
// pageSize=<number> as a query param.
"total": 3, // Total number of pages.
"items": 3, // The total number of items on all the pages.
"maxSize": 100 // Maximum page size allowed
}
}
Preview message¶
To get MIME headers, html and text body of the message, call:
GET /email/v1/post-delivery-quarantine/messages/{id}/preview
Response:
{
//Array listing each MIME header
"headers": [
"To: =?UTF-8?B?dXNlciBuYW1l?= user_bob@example.com<user_bob@gmail.com>",
"From: =?UTF-8?B?RmxpcGthcnQ=?= <no-reply@ncp.example.com>",
"Cc: =?UTF-8?B?dXNlciBuYW1l?= cc@recipient.com",
"Subject: =?UTF-8?B?8J+HrvCfh7NJbmRpYSwgd2UgaGF2ZSB6YWJhcmRhc3QgbmV3cyE=?=",
"Message-Id: <cdakca16596378617636312@ncp.example.com>",
"MIME-Version: 1.0",
"Content-Type: multipart/alternative;"
],
//The HTML body part of the message
"htmlBody": "\n\n \n \n \n <table class=\"body-wrapper\" align=\"center\"><tbody><tr></tbody></table> \n \n \n <p> <br /></p>\n\n",
//The Text body part of the message
"textBody": "We hope you enjoy emails from Example Inc. If you wish to\nunsubscribe, please click here . "
}
Get attachments¶
To get attachments in a message, call:
GET /email/v1/post-delivery-quarantine/messages/{id}/attachments
Response:
{
//Array of attachment object.
"items": [
{
"name": "empty-file", //Name of the attached file.
"sizeInBytes": 1699, //Size of the attachment in bytes.
"stripped": false //Whether the attachment is stripped from the message.
}
],
"pages": {
"current": 1, //The current page number.
"size": 1, // The page size. You can change this by passing
// pageSize=<number> as a query param.
"total": 1, // Total number of pages.
"items": 1, // The total number of items on all the pages.
"maxSize": 500 // Maximum page size allowed
}
}
Release messages¶
To release one or more messages from post-delivery quarantine, call:
POST /email/v1/post-delivery-quarantine/messages/release
Request:
{
//Array of items to release.
"items": [{
//The ID of the message to release.
//The message will be released for all recipients.
"id": "6761806c-9a7d-4689-a63f-03f5da54d1e8"
},
{
//The ID of the message to release.
"id": "7ea38ef5-6608-4c92-a7f5-21f9eb3e698b",
//Specific recipients for whom the message should be released.
"forRecipients": ["user_1@dev.euw.emailblr1.com"]
}]
}
Response:
{
//Messages which were released successfully.
"items": [
{
//The ID of the message released.
"id": "6761806c-9a7d-4689-a63f-03f5da54d1e8",
//The recipient address for which the mail was released.
"recipient": "user_2@dev.euw.emailblr1.com"
},
{
"id": "7ea38ef5-6608-4c92-a7f5-21f9eb3e698b",
"recipient": "user_1@dev.euw.emailblr1.com"
}
],
//Messages which were not released due to an error.
"errors": [
{
//The ID of the message.
"id": "6761806c-9a7d-4689-a63f-03f5da54d1e8",
//The recipient address for which the release failed.
"recipient": "user_@@dev.euw.emailblr1.com",
//Error code indicating the reason for failure.
"error": "alreadyReleased"
}
]
}
Delete messages¶
To delete one or more messages from post-delivery quarantine, call:
POST /email/v1/post-delivery-quarantine/messages/delete
Request:
{
//Array of items to delete.
"items": [{
//The ID of the message to delete.
//The message will be deleted for all recipients.
"id": "6761806c-9a7d-4689-a63f-03f5da54d1e8"
},
{
//The ID of the message to delete.
"id": "7ea38ef5-6608-4c92-a7f5-21f9eb3e698b",
//Optional. Specific recipients for whom the message should be deleted.
"forRecipients": ["user_1@dev.euw.emailblr1.com"]
}]
}
Response:
{
//Messages which were deleted successfully.
"items": [
{
//The ID of the message deleted.
"id": "6761806c-9a7d-4689-a63f-03f5da54d1e8",
//The recipient address for which the mail was deleted.
"recipient": "user_2@dev.euw.emailblr1.com"
},
{
"id": "7ea38ef5-6608-4c92-a7f5-21f9eb3e698b",
"recipient": "user_1@dev.euw.emailblr1.com"
}
],
//Messages which were not deleted due to an error.
"errors": [
{
//The ID of the message.
"id": "6761806c-9a7d-4689-a63f-03f5da54d1e8",
//The recipient address for which the delete failed.
"recipient": "user_@@dev.euw.emailblr1.com",
//Error code indicating the reason for failure.
"error": "alreadyReleased"
}
]
}
Request to download attachments from a message¶
To download attachments from a message, call:
POST /email/v1/post-delivery-quarantine/messages/{id}/attachments/download
Request:
{
//Optional array of attachment names. If not specified, all attachments will be downloaded
"attachments": [
"sandbox_virus_3.zip"
]
}
Response:
{
// Id of the download job.
"id": "0fa3ce67-02cf-4261-8940-04b57fd4d8d5",
"status": "processing"
}
Get status of download request¶
To get status of download request, call:
GET /email/v1/post-delivery-quarantine/downloads/{downloadId}/status
Response:
{
//Id of the job.
"id": "0fa3ce67-02cf-4261-8940-04b57fd4d8d5",
//Status of the job
"status": "completed",
//Names of attachments included in the zip file.
"attachments": [
"sandbox_virus_3.zip"
],
//URL from where the zip file can be downloaded.
"url": "https://<bucket>.s3.<region>.amazonaws.com/downloads/attachments/<id>/<uuid>/<file-hash>.zip?X-Amz-Security-Token=<security-token>&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=<date>&X-Amz-SignedHeaders=host&X-Amz-Expires=300&X-Amz-Credential=<access-key-id>%2F<date>%2F<region>%2Fs3%2Faws4_request&X-Amz-Signature=<signature>",
//Password to open the zip file. Present only if any of the attachment was identified as virus.
"password": "<zip-password>"
}
Conclusion¶
See the Email Management API reference for a comprehensive description of this API.