Email API Documentation

All requests require an API key for authorization. The API key must be included in the x-api-key header for each request.

Authorization

API Key: The x-api-key header must be included with every request to authenticate the client. Requests without this header will return a 401 Unauthorized error.

Example:

x-api-key: YOUR_API_KEY

1. Send Email

POST /email

Sends an email message. The message can be directly specified or templated.

Headers
  • x-api-key (required): API key for authorization.
Request Body
Field Type Required Description Default
messageTypestringNoType of message, should be "email"."email"
tostringYesRecipient email address.-
fromstringYesSender email address.-
subjectstringYesSubject of the email.-
messagestringConditionally requiredText message body, up to 25,000 characters.-
templateIdstringConditionally requiredTemplate ID for the email content.-
variablesobjectNoKey-value pairs for templating variables.-
notBeforestringNoUTC date-time to schedule the email.-
notAfterstringNoUTC date-time for email expiration.-
callbackUrlstringNoCallback URL for email delivery notifications.-
clientIdstringNoClient identifier, max length 100 characters.""
Sample Request (Non Templated)
{
  "to": "recipient@example.com",
  "from": "sender@example.com",
  "subject": "Test Email",
  "message": "Hello, this is a test email message."
}
Sample Request (Templated)
{
    "to": "recipient@example.com",
    "from": "sender@example.com",
    "templateId": "gPVTbWpwQHXgg8KSZ6sX",
    "clientId": "23948729438slkdfjwkfjhsdfsdf",
    "variables": {
      "name": "Jane Doe",
      "time": "10:49pm"
    }
}
Sample Response

200 OK

{
  "message": "Email received successfully",
  "trackingId": "1234567890abcdef"
}
Response Fields
Field Type Description
message string A confirmation message indicating the email has been successfully received by the API.
trackingId string A unique identifier for tracking the email. This ID can be used in subsequent API calls to retrieve the email status and any associated events.
Rate Limiting

To ensure fair usage of resources, the Send Email API endpoint is rate-limited based on each client’s API key. If the rate limit is exceeded, subsequent requests will be temporarily blocked until the rate limit resets.

Current Rate Limit

The current rate limit may vary based on your subscription plan and usage agreement. Please refer to the API’s response headers to monitor your rate limit status, or contact us for your specific rate limit settings.

Rate Limit Headers

On each response, the following headers provide rate limit details:

Header Description
X-RateLimit-Limit The maximum number of requests allowed per minute for the API key.
X-RateLimit-Remaining The number of requests remaining in the current time window.
X-RateLimit-Reset The time (in seconds) until the rate limit resets and the full quota is available again.
Exceeded Rate Limit Response

If the rate limit is exceeded, the following response will be returned:

{
  "error": "Rate limit exceeded"
}
Increasing Rate Limit

If your application requires a higher rate limit, please reach out to the eMsgNow support team to discuss rate limit adjustments that suit your requirements. We are happy to accommodate higher traffic where possible. Contact us via email at support@emsgnow.com or through your eMsgNow representative.


2. Get Email Details

GET /email/:messageId

Retrieves the full details of an email message, including events related to the email.

Headers
  • x-api-key (required): API key for authorization.
Sample Request
GET /email/1234567890abcdef
Sample Response
{
  "to": "recipient@example.com",
  "from": "sender@example.com",
  "subject": "Test Email",
  "message": "Hello, this is a test email message.",
  "clientId": "23948729438slkdfjwkfjhsdfsdf",
  "messageType": "email",
  "trackingId": "1234567890abcdef",
  "notBefore": "2024-11-10T02:48:08.004Z",
  "notAfter": "2024-11-10T08:48:08.004Z",
  "created": "2024-11-10T18:18:31.050Z",
  "updated": "2024-11-10T18:18:31.050Z",
  "events": [
    {
      "id": "5mogLKKETFjg7c3eNNvH",
      "message": {
        "channel": "email",
        "trackingId": "1234567890abcdef",
        "clientId": "23948729438slkdfjwkfjhsdfsdf",
        "status": "processing",
        "statusAt": "2024-11-10T02:48:08.019Z",
        "additionalInfo": {}
      },
      "timestamp": "2024-11-10T18:18:31.050Z"
    },
    {
      "id": "C98OWsv63rVLJoE5QAns",
      "message": {
        "channel": "email",
        "trackingId": "1234567890abcdef",
        "clientId": "23948729438slkdfjwkfjhsdfsdf",
        "status": "sent",
        "statusAt": "2024-11-10T02:48:08.019Z",
        "additionalInfo": {}
      },
      "timestamp": "2024-11-10T18:18:31.050Z"
    }
  ]
}
Response Fields
Field Type Description
to string Recipient's email address.
from string Sender's email address.
subject string The subject of the email message.
message string The body of the email message.
clientId string Client identifier for the email message.
messageType string Type of message, typically email.
trackingId string Unique identifier for tracking the email.
notBefore string (UTC Date-Time) Date-time after which the email is eligible to be sent.
notAfter string (UTC Date-Time) Date-time after which the email should not be sent.
created string (UTC Date-Time) Timestamp when the email was created.
updated string (UTC Date-Time) Timestamp when the email was last updated.

3. Get Email Events

GET /email/:messageId/events

Retrieves a list of events associated with a specific email message.

Headers
  • x-api-key (required): API key for authorization.
Sample Request
GET /email/1234567890abcdef/events
Sample Response
{
  "messageId": "1234567890abcdef",
  "events": [
    {
      "id": "5mogLKKETFjg7c3eNNvH",
      "message": {
        "channel": "email",
        "trackingId": "1234567890abcdef",
        "clientId": "23948729438slkdfjwkfjhsdfsdf",
        "status": "processing",
        "statusAt": "2024-11-10T02:48:08.019Z",
        "additionalInfo": {}
      },
      "timestamp": "2024-11-10T18:18:31.050Z"
    },
    {
      "id": "C98OWsv63rVLJoE5QAns",
      "message": {
        "channel": "email",
        "trackingId": "1234567890abcdef",
        "clientId": "23948729438slkdfjwkfjhsdfsdf",
        "status": "sent",
        "statusAt": "2024-11-10T02:48:08.019Z",
        "additionalInfo": {}
      },
      "timestamp": "2024-11-10T18:18:31.050Z"
    }
  ]
}
Response Fields
Field Type Description
messageId string Unique identifier for the email message being tracked.
Events Array

Each event object within the events array provides details about the status of the email message at different stages.

Field Type Description
id string Unique identifier for the event.
message.channel string Channel used for the message, typically email.
message.trackingId string Tracking ID of the original email message.
message.clientId string Client identifier associated with the email.
message.status string Status of the email at the time of the event (e.g., processing, sent).
message.statusAt string (UTC Date-Time) Date-time when the status was recorded.
message.additionalInfo object Additional information related to the event, if available.
timestamp string (UTC Date-Time) Date-time when the event was created.

4. Get Single Email Event

GET /email/:messageId/events/:eventId

Retrieves a specific event associated with an email message.

Headers
  • x-api-key (required): API key for authorization.
Sample Request
GET /email/1234567890abcdef/events/5mogLKKETFjg7c3eNNvH
Sample Response
{
  "messageId": "1234567890abcdef",
  "id": "5mogLKKETFjg7c3eNNvH",
  "message": {
    "channel": "email",
    "trackingId": "1234567890abcdef",
    "clientId": "1",
    "status": "processing",
    "statusAt": "2024-11-10T02:48:08.019Z",
    "additionalInfo": {}
  },
  "timestamp": "2024-11-10T18:18:31.050Z"
}
Get Single Email Event Response Data
Field Type Description
messageId string Unique identifier for the email message associated with this event.
id string Unique identifier for this specific event.
timestamp string (UTC Date-Time) Date-time when this event was created.
Message Object

The message object within the event provides additional details about the email status at the time of the event.

Field Type Description
channel string Channel used for the message, typically email.
trackingId string Tracking ID of the original email message.
clientId string Client identifier associated with the email.
status string Status of the email at the time of the event (e.g., processing, sent).
statusAt string (UTC Date-Time) Date-time when the status was recorded.
additionalInfo object Additional information related to the event, if available.

Error Responses

401 Unauthorized
{
  "error": "API key is required"
}
403 Forbidden
{
  "error": "Invalid API key"
}
500 Internal Server Error
{
  "error": "Failed to retrieve email status"
}
429 Too Many Requests
{
  "error": "Rate limit exceeded"
}