Mektup Messages API

The Messages API from Mektup, for messages.

GitHub OpenAPI
Pull this API's OpenAPI, operations, scores and pricing into your own code or AI agent with a free APIs.io key — sign in with GitHub, Google or LinkedIn. No form to fill in; signing in shares your email address with us (Privacy).

Operations 8

GET /v1/unread-counts Unread Inbox count per domain/mailbox, in one grouped query #
GET /v1/messages List messages (one row per thread) for a mailbox #
GET /v1/emails/delivery-stats Aggregate delivery outcomes for a mailbox's outbound mail #
GET /v1/threads/{threadKey} List every individual message in one thread, oldest first #
GET /v1/messages/{id} Get one message's full content #
PATCH /v1/messages/{id} Update message state (read/unread, restore, flag, move to folder) #
DELETE /v1/messages/{id} Delete a message (two-stage - trash, then permanent) #
GET /v1/messages/{id}/attachments/{index} Download one attachment's raw bytes #

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/usemektup-com:usemektup-com-messages-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

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. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.

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

OpenAPI Specification

usemektup-com-messages-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Mektup Messages API
  version: 1.0.0
  description: Fully-managed, multi-domain email platform (Mektup runs all the mail infrastructure - nothing for you to host or operate). Register a domain, provision mailboxes, send and receive real email, all account-scoped and enforced server-side (including at the database layer via Postgres Row-Level Security). See docs/API.md for prose documentation and worked examples, and docs/MCP.md for using this API through an MCP server as an AI agent.
  contact:
    email: contact@usemektup.com
servers:
- url: https://api.usemektup.com
  description: Production
security:
- ApiKeyAuth: []
tags:
- name: Messages
paths:
  /v1/unread-counts:
    get:
      summary: Unread Inbox count per domain/mailbox, in one grouped query
      operationId: getUnreadCounts
      tags:
      - Messages
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  counts:
                    type: array
                    items:
                      $ref: '#/components/schemas/UnreadCount'
  /v1/messages:
    get:
      summary: List messages (one row per thread) for a mailbox
      operationId: listMessages
      tags:
      - Messages
      parameters:
      - name: mailbox
        in: query
        required: true
        schema:
          type: string
        description: local@domain, must be owned by this account
      - name: limit
        in: query
        schema:
          type: integer
          minimum: 1
          maximum: 200
          default: 50
      - name: direction
        in: query
        schema:
          type: string
          enum:
          - inbound
          - outbound
      - name: trash
        in: query
        schema:
          type: string
          enum:
          - '1'
        description: Pass 1 to view Trash instead of the active mailbox
      - name: folder
        in: query
        schema:
          type: string
          format: uuid
        description: View a custom folder instead - ignores direction
      - name: q
        in: query
        schema:
          type: string
        description: Full-text search over subject, from/to, and body
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  messages:
                    type: array
                    items:
                      $ref: '#/components/schemas/MessageSummary'
        '400':
          $ref: '#/components/responses/BadRequest'
  /v1/emails/delivery-stats:
    get:
      summary: Aggregate delivery outcomes for a mailbox's outbound mail
      description: Counts of sent/deferred/bounced/unknown over a time window, sourced from Mektup's own Postfix delivery log rather than a third-party tracking service.
      operationId: getDeliveryStats
      tags:
      - Messages
      parameters:
      - name: mailbox
        in: query
        required: true
        schema:
          type: string
        description: local@domain, must be owned by this account
      - name: days
        in: query
        schema:
          type: integer
          minimum: 1
          maximum: 365
          default: 30
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  mailbox:
                    type: string
                  days:
                    type: integer
                  total:
                    type: integer
                  sent:
                    type: integer
                  deferred:
                    type: integer
                  bounced:
                    type: integer
                  unknown:
                    type: integer
        '400':
          $ref: '#/components/responses/BadRequest'
  /v1/threads/{threadKey}:
    get:
      summary: List every individual message in one thread, oldest first
      operationId: getThread
      tags:
      - Messages
      parameters:
      - name: threadKey
        in: path
        required: true
        schema:
          type: string
      - name: mailbox
        in: query
        required: true
        schema:
          type: string
      - name: direction
        in: query
        schema:
          type: string
          enum:
          - inbound
          - outbound
      - name: trash
        in: query
        schema:
          type: string
          enum:
          - '1'
      - name: folder
        in: query
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  messages:
                    type: array
                    items:
                      $ref: '#/components/schemas/MessageBase'
        '400':
          $ref: '#/components/responses/BadRequest'
  /v1/messages/{id}:
    get:
      summary: Get one message's full content
      description: Marks it read as a side effect if it wasn't already.
      operationId: getMessage
      tags:
      - Messages
      parameters:
      - $ref: '#/components/parameters/IdParam'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MessageDetail'
        '404':
          $ref: '#/components/responses/NotFound'
    patch:
      summary: Update message state (read/unread, restore, flag, move to folder)
      description: Any combination in one call. At least one field required.
      operationId: updateMessage
      tags:
      - Messages
      parameters:
      - $ref: '#/components/parameters/IdParam'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                read:
                  type: boolean
                deleted:
                  type: boolean
                  enum:
                  - false
                  description: Only false is accepted here (restore from trash) - use DELETE to delete
                flagged:
                  type: boolean
                folderId:
                  type:
                  - string
                  - 'null'
                  format: uuid
                  description: Must belong to the same mailbox as the message, or null
      responses:
        '204':
          description: Updated
        '400':
          $ref: '#/components/responses/BadRequest'
        '404':
          $ref: '#/components/responses/NotFound'
    delete:
      summary: Delete a message (two-stage - trash, then permanent)
      description: First call soft-deletes (moves to Trash). A second call on an already-trashed message permanently deletes it.
      operationId: deleteMessage
      tags:
      - Messages
      parameters:
      - $ref: '#/components/parameters/IdParam'
      responses:
        '204':
          description: Deleted
        '404':
          $ref: '#/components/responses/NotFound'
  /v1/messages/{id}/attachments/{index}:
    get:
      summary: Download one attachment's raw bytes
      operationId: getAttachment
      tags:
      - Messages
      parameters:
      - $ref: '#/components/parameters/IdParam'
      - name: index
        in: path
        required: true
        schema:
          type: integer
          minimum: 0
        description: Position in the attachments array from GET /v1/messages/{id}
      responses:
        '200':
          description: Binary attachment content
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
        '404':
          $ref: '#/components/responses/NotFound'
components:
  schemas:
    MessageSummary:
      allOf:
      - $ref: '#/components/schemas/MessageBase'
      - type: object
        properties:
          thread_key:
            type: string
          thread_count:
            type: integer
          thread_has_unread:
            type: boolean
    Error:
      type: object
      properties:
        error:
          type: string
    MessageDetail:
      allOf:
      - $ref: '#/components/schemas/MessageBase'
      - type: object
        properties:
          thread_key:
            type: string
          text:
            type:
            - string
            - 'null'
          html:
            type:
            - string
            - 'null'
            description: Attacker-controlled content - sanitize and isolate before rendering, never render directly
          attachments:
            type: array
            items:
              type: object
              properties:
                filename:
                  type:
                  - string
                  - 'null'
                contentType:
                  type: string
                size:
                  type: integer
    UnreadCount:
      type: object
      properties:
        domain:
          type: string
        local_part:
          type: string
        unread:
          type: integer
    MessageBase:
      type: object
      properties:
        id:
          type: string
          format: uuid
        direction:
          type: string
          enum:
          - inbound
          - outbound
        from_address:
          type:
          - string
          - 'null'
        to_address:
          type:
          - string
          - 'null'
        subject:
          type:
          - string
          - 'null'
        size_bytes:
          type: integer
        received_at:
          type: string
          format: date-time
        read_at:
          type:
          - string
          - 'null'
          format: date-time
        deleted_at:
          type:
          - string
          - 'null'
          format: date-time
        flagged_at:
          type:
          - string
          - 'null'
          format: date-time
        folder_id:
          type:
          - string
          - 'null'
          format: uuid
        delivery_status:
          type:
          - string
          - 'null'
          enum:
          - sent
          - deferred
          - bounced
          - null
          description: Only ever populated for direction=outbound. null means either too recent to have a result yet, or delivered locally to another Mektup mailbox rather than over external SMTP.
        delivery_detail:
          type:
          - string
          - 'null'
          description: The real SMTP response text from the recipient's mail server (Mektup has no relayhost, so its own MTA does the delivery attempt directly) - not a synthesized summary.
        delivery_checked_at:
          type:
          - string
          - 'null'
          format: date-time
  parameters:
    IdParam:
      name: id
      in: path
      required: true
      schema:
        type: string
        format: uuid
  responses:
    NotFound:
      description: Not found on this account (tenant-isolated - never reveals another account's data)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    BadRequest:
      description: Invalid request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: mek_live_...
      description: 'Bearer token API key, minted per-account. Shown once at creation, only a SHA-256 hash is stored server-side. Dashboard requests may alternatively authenticate via a Clerk session, not relevant for programmatic/agent integration.

        '