Mailtrap API

Authentication


Emails

Emails

post

Send email

Webhooks

POST

WEBHOOK Receive events


SandBox

Accounts

Get

all accounts

Accout Users

Get List all users in account

DELETE REmove user form the account

Permissions

PUT Manage user or token Permissions

Get Get resources

Projects

GET

Get a list of projects
POST Create project
GET Get project by id DELETE Delete project
PATCH Update project

Inboxes

POST Create an inbox
Get inbox attributes
DELETE Delete an inbox
PATCH Update an inbox
PATCH Clean inbox
PATCH Mark as read
PATCH Reset credentials
PATCH Enable email address
PATCH Reset email address
GET Get a list of inboxes

Messages

Get Get Show email message
Get DELETE Delete message
Get PATCH Update message
messages
Get POST Forward message
Get message spam score
Get HTML message
Get message source
text message
Get raw message
message as .eml

Attchments

Get Get attachments
Get Get single attachment

Mailtrap API v2

Mailtrap API is based on the REST principles. The following documentation covers core resources that are used to manipulate the main entities. To start using the Mailtrap API, only a Mailtrap account is required. You have to be authenticated and call the simple HTTPS request on the URL specified below. Please read these basic instructions before you start working with the API.

Mailtrap API is based on the REST principles. The following documentation covers core resources that are used to manipulate the main entities. To start using the Mailtrap API, only a Mailtrap account is required. You have to be authenticated and call the simple HTTPS request on the URL specified below. Please read these basic instructions before you start working with the API.

There are several ways to send authenticated HTTP requests:

  • Send a HTTP header Api-Token: {api_token}, where {api_token} is your API token
  • Send a HTTP header Authorization: Bearer #{token}, where {api_token} is your API token (more info: Token Access Authentication)

You can manage your API token on the API Tokens page. API token does not have an expiration date, you may reset it manually.

Allowed requests and common responses

  • POST - to create a resource
  • PATCH - to update a resource
  • PUT - to replace a resource
  • PUT - to get a resource or a list of resources
  • DELETE - to delete a resource

Here is the description of common server responses

  • 200 OK - the request was successful (some API calls may return 201 instead).
  • 204 No Content - the request was successful but there is no representation to return (i.e. the response is empty).
  • 401 Unauthorized - authentication failed o r user doesn't have permissions for requested operation.
  • 403 Forbidden - access denied.
  • 404 Not Found - resource was not found
  • 422 Unprocessable Entity - requested data contain invalid values.

All requests must be sent over HTTPS protocol.

Authentication

No API Key applied

API Key (Api-Token)

Pass the API token in the Api-Token header. Read more about API tokens Send Api-Token in header

EMAIL API

Pordution email sending

API server: send api.Mailtrap.io

EMAILS


Send email

POST /api/send

REQUEST

REQUEST BODY application/json

"to": [
  {
    "email": "john_doe@example.com",
    "name": "John Doe"
  }
],
"cc": [
  {
    "email": "jane_doe@example.com",
    "name": "Jane Doe"
  }
],
"bcc": [
  {
    "email": "james_doe@example.com",
    "name": "Jim Doe"
  }
],
"from": {
  "email": "sales@example.com",
  "name": "Example Sales Team"
},
"subject": "Your Example Order Confirmation",
"html": "

Congratulations on your order no. 1234. "category": "cake", "custom_variables": { "variable1": "value1", "variable2": "value2" }, "headers": { "header1": "value1" }

API Server https://send.api.mailtrap.io

Authentication Required (None Applied)


Response

Success. Message has been delivered.

"to": [
  {
    "email": "john_doe@example.com",
    "name": "John Doe"
  }
],
"cc": [
  {
    "email": "jane_doe@example.com",
    "name": "Jane Doe"
  }
],
"bcc": [
  {
    "email": "james_doe@example.com",
    "name": "Jim Doe"
  }
],
"from": {
  "email": "sales@example.com",
  "name": "Example Sales Team"
},
"subject": "Your Example Order Confirmation",
"html": "

Congratulations on your order no. 1234. "category": "cake", "custom_variables": { "variable1": "value1", "variable2": "value2" }, "headers": { "header1": "value1" }

WEBHOOKS

Receive events

Read more about Webhooks in our Knowledge Base.

Request

REQUEST BODY application/json

Mail events that user is subscribed to

"to": [
  {
    "email": "john_doe@example.com",
    "name": "John Doe"
  }
],
"cc": [
  {
    "email": "jane_doe@example.com",
    "name": "Jane Doe"
  }
],
"bcc": [
  {
    "email": "james_doe@example.com",
    "name": "Jim Doe"
  }
],
"from": {
  "email": "sales@example.com",
  "name": "Example Sales Team"
},
"subject": "Your Example Order Confirmation",
"html": "

Congratulations on your order no. 1234. "category": "cake", "custom_variables": { "variable1": "value1", "variable2": "value2" }, "headers": { "header1": "value1" }

SandBOX

Test emails for staging.

API Server:mailtrap.io

ACCOUNTS

Get all accounts

"to": [
  {
    "email": "john_doe@example.com",
    "name": "John Doe"
  }
],
"cc": [
  {
    "email": "jane_doe@example.com",
    "name": "Jane Doe"
  }
],
"bcc": [
  {
    "email": "james_doe@example.com",
    "name": "Jim Doe"
  }
],
"from": {
  "email": "sales@example.com",
  "name": "Example Sales Team"
},
"subject": "Your Example Order Confirmation",
"html": "

Congratulations on your order no. 1234. "category": "cake", "custom_variables": { "variable1": "value1", "variable2": "value2" }, "headers": { "header1": "value1" }

What is Mailtest?

Mailtrap is a test mail server solution that allows testing email notifications without sending them to the real users of your application. Not only does Mailtrap work as a powerful email test tool, it also lets you view your dummy emails online, forward them to your regular mailbox, share with the team and more! Mailtrap is a mail server test tool built by Railsware Products, Inc., a premium software development consulting company.

© Masai School, Inc.