Mailtrap Messages API

Inspect captured messages

Operations 12

GET /api/accounts/{account_id}/inboxes/{inbox_id}/messages List captured messages in an inbox #
GET /api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id} Get a captured message #
PATCH /api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id} Update message attributes (e.g. mark read) #
DELETE /api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id} Delete a captured message #
POST /api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id}/forward Forward a captured message to a confirmed recipient #
GET /api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id}/spam_report Get spam analysis for a message #
GET /api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id}/analyze Get HTML validation and compatibility report #
GET /api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id}/body.txt Get plain text body of a message #
GET /api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id}/body.html Get HTML body of a message #
GET /api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id}/body.raw Get raw message body #
GET /api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id}/body.eml Download message in standard .eml format #
GET /api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id}/mail_headers Get email headers for a message #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/mailtrap-messages-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

mailtrap-messages-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Mailtrap Email Sandbox Messages API
  description: The Mailtrap Email Sandbox API provides a safe email testing environment to inspect and debug emails before sending to real recipients. The API supports sending test emails into virtual inboxes, then retrieving, analyzing, and managing those captured messages. Sandbox endpoints cover messages, inboxes, projects, spam reports, HTML analysis, and raw or formatted message bodies.
  version: '1.0'
  contact:
    name: Mailtrap Support
    url: https://help.mailtrap.io/
  termsOfService: https://mailtrap.io/terms-of-use/
servers:
- url: https://sandbox.api.mailtrap.io
  description: Sandbox API
- url: https://mailtrap.io
  description: Mailtrap management API
security:
- ApiTokenAuth: []
tags:
- name: Messages
  description: Inspect captured messages
paths:
  /api/accounts/{account_id}/inboxes/{inbox_id}/messages:
    get:
      operationId: listMessages
      summary: List captured messages in an inbox
      tags:
      - Messages
      parameters:
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/InboxId'
      - name: page
        in: query
        schema:
          type: integer
      responses:
        '200':
          description: Paginated messages
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Message'
  /api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id}:
    get:
      operationId: getMessage
      summary: Get a captured message
      tags:
      - Messages
      parameters:
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/InboxId'
      - $ref: '#/components/parameters/MessageId'
      responses:
        '200':
          description: Message details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Message'
    patch:
      operationId: updateMessage
      summary: Update message attributes (e.g. mark read)
      tags:
      - Messages
      parameters:
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/InboxId'
      - $ref: '#/components/parameters/MessageId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          description: Message updated
    delete:
      operationId: deleteMessage
      summary: Delete a captured message
      tags:
      - Messages
      parameters:
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/InboxId'
      - $ref: '#/components/parameters/MessageId'
      responses:
        '204':
          description: Message deleted
  /api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id}/forward:
    post:
      operationId: forwardMessage
      summary: Forward a captured message to a confirmed recipient
      tags:
      - Messages
      parameters:
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/InboxId'
      - $ref: '#/components/parameters/MessageId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
                  format: email
      responses:
        '200':
          description: Message forwarded
  /api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id}/spam_report:
    get:
      operationId: getSpamReport
      summary: Get spam analysis for a message
      tags:
      - Messages
      parameters:
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/InboxId'
      - $ref: '#/components/parameters/MessageId'
      responses:
        '200':
          description: Spam analysis report
  /api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id}/analyze:
    get:
      operationId: getHtmlAnalyze
      summary: Get HTML validation and compatibility report
      tags:
      - Messages
      parameters:
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/InboxId'
      - $ref: '#/components/parameters/MessageId'
      responses:
        '200':
          description: HTML analysis report
  /api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id}/body.txt:
    get:
      operationId: getMessageBodyText
      summary: Get plain text body of a message
      tags:
      - Messages
      parameters:
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/InboxId'
      - $ref: '#/components/parameters/MessageId'
      responses:
        '200':
          description: Plain text body
          content:
            text/plain:
              schema:
                type: string
  /api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id}/body.html:
    get:
      operationId: getMessageBodyHtml
      summary: Get HTML body of a message
      tags:
      - Messages
      parameters:
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/InboxId'
      - $ref: '#/components/parameters/MessageId'
      responses:
        '200':
          description: HTML body
          content:
            text/html:
              schema:
                type: string
  /api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id}/body.raw:
    get:
      operationId: getMessageBodyRaw
      summary: Get raw message body
      tags:
      - Messages
      parameters:
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/InboxId'
      - $ref: '#/components/parameters/MessageId'
      responses:
        '200':
          description: Raw message
  /api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id}/body.eml:
    get:
      operationId: getMessageEml
      summary: Download message in standard .eml format
      tags:
      - Messages
      parameters:
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/InboxId'
      - $ref: '#/components/parameters/MessageId'
      responses:
        '200':
          description: EML file
  /api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id}/mail_headers:
    get:
      operationId: getMessageHeaders
      summary: Get email headers for a message
      tags:
      - Messages
      parameters:
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/InboxId'
      - $ref: '#/components/parameters/MessageId'
      responses:
        '200':
          description: Header collection
components:
  parameters:
    AccountId:
      name: account_id
      in: path
      required: true
      schema:
        type: integer
    MessageId:
      name: message_id
      in: path
      required: true
      schema:
        type: integer
    InboxId:
      name: inbox_id
      in: path
      required: true
      schema:
        type: integer
  schemas:
    Message:
      type: object
      properties:
        id:
          type: integer
        inbox_id:
          type: integer
        subject:
          type: string
        sent_at:
          type: string
          format: date-time
        from_email:
          type: string
        from_name:
          type: string
        to_email:
          type: string
        to_name:
          type: string
        is_read:
          type: boolean
        html_body_size:
          type: integer
        text_body_size:
          type: integer
  securitySchemes:
    ApiTokenAuth:
      type: apiKey
      in: header
      name: Api-Token
externalDocs:
  description: Mailtrap Email Sandbox Documentation
  url: https://docs.mailtrap.io/