{
  "openapi": "3.0.3",
  "info": {
    "title": "Mailbox Connector API",
    "version": "1.0.0",
    "description": "Send mail, create drafts and read and process mail in a Microsoft 365 or Google mailbox.\n\nThis document describes the calls. Read https://mailboxconnector.com/llms-full.txt as well: it explains what a schema cannot, and it has tested code in seven languages.\n\n**Logging in takes three steps.**\n1. `GET /api/login/{applicationId}` returns a challenge: a line number in your key file, counted from 0.\n2. Read that line from the key file (1,000,000 lines, about 10 MB) without loading the whole file: skip `challenge` lines and take the next one.\n3. `POST /api/login` with that line as `code`, your application id and your security key. You get a token that is valid for 10 minutes.\n\n**Rules a client must follow.**\n- Reuse the token until a minute before it expires. Never log in for every call.\n- Let only one login run at a time per process.\n- The challenge is a counter that every login attempt moves on. On a 401 while logging in, wait a random 0.2 to 1 second, fetch a new challenge and try again; three attempts at most.\n- More than five wrong codes lock the application for 5 minutes (403). Then stop and wait.\n- Operations answer HTTP 200 with a `status` field. Always check `status`.\n- Choices are numbers, not names. Field names are camelCase.\n- Never put the security key or the key file in source code.",
    "contact": {
      "name": "Mailbox Connector",
      "url": "https://mailboxconnector.com/en/sdk"
    }
  },
  "externalDocs": {
    "description": "Complete documentation as plain text, with tested samples",
    "url": "https://mailboxconnector.com/llms-full.txt"
  },
  "servers": [
    {
      "url": "https://mailboxconnector.com"
    }
  ],
  "tags": [
    {
      "name": "Login",
      "description": "Getting a token. These calls need no token themselves."
    },
    {
      "name": "Connecting",
      "description": "Connecting a mailbox to your application. The owner of the mailbox gives permission once, at Microsoft or Google."
    },
    {
      "name": "Operations",
      "description": "Working with mail in a connected mailbox."
    }
  ],
  "security": [
    {
      "bearer": []
    }
  ],
  "paths": {
    "/api/login/{applicationId}": {
      "get": {
        "operationId": "getChallenge",
        "tags": [
          "Login"
        ],
        "security": [],
        "summary": "Step 1 of logging in: fetch the challenge",
        "description": "Returns the current value of the challenge counter. Fetching it changes nothing. Free: does not count as an action.",
        "parameters": [
          {
            "name": "applicationId",
            "in": "path",
            "required": true,
            "description": "The id of your application.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The challenge.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChallengeResponse"
                },
                "example": {
                  "challenge": 418273
                }
              }
            }
          },
          "204": {
            "description": "No key file has been created for this application yet. Try again in a few minutes."
          },
          "401": {
            "description": "There is no application with this id."
          }
        }
      }
    },
    "/api/login": {
      "post": {
        "operationId": "login",
        "tags": [
          "Login"
        ],
        "security": [],
        "summary": "Step 3 of logging in: exchange the code for a token",
        "description": "Every call, right or wrong, moves the challenge counter one up. Free: does not count as an action.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LoginRequest"
              },
              "example": {
                "code": "mP4tY8sKx2",
                "applicationId": "3f2b8c1e-7a4d-4e9b-9c55-0d6a1b2e4f70",
                "securityKey": "your-security-key"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Logged in. Earlier failures are cleared.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LoginResponse"
                },
                "example": {
                  "validMinutes": 10,
                  "bearer": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
                }
              }
            }
          },
          "401": {
            "description": "The code or the security key is wrong, or the application does not exist. Counts as a failure. Fetch a new challenge before trying again."
          },
          "403": {
            "description": "Locked: more than five failures. Wait 5 minutes."
          }
        }
      }
    },
    "/api/connectionrequest/check": {
      "post": {
        "operationId": "checkConnection",
        "tags": [
          "Connecting"
        ],
        "summary": "Check whether a mailbox is connected",
        "description": "Tells whether the mailbox is connected to your application with the permissions you ask for. Free: does not count as an action.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConnectionRequest"
              },
              "example": {
                "desiredEmailAddress": "info@example.com",
                "needsSendMail": true,
                "needsCreateDraft": false,
                "needsReadMail": true,
                "needsMoveMail": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The state of the connection.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckConnectionResponse"
                },
                "example": {
                  "connectionStatus": 2
                }
              }
            }
          },
          "401": {
            "description": "The token is missing or has expired. Log in again."
          },
          "403": {
            "description": "No mailbox of your application has the permission for this operation. When a mailbox has just been connected, log in again: a token holds the permissions of the moment it was issued."
          }
        }
      }
    },
    "/api/connectionrequest/create": {
      "post": {
        "operationId": "createConnection",
        "tags": [
          "Connecting"
        ],
        "summary": "Create a connection request",
        "description": "Starts connecting a mailbox. Send the user to https://mailboxconnector.com/connect/{id} with the id from the response; there they sign in at Microsoft or Google as the mailbox itself. Afterwards they return to your returnUrl; then check the connection again. A connection request is valid for 30 minutes. Free: does not count as an action.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConnectionRequest"
              },
              "example": {
                "returnUrl": "https://www.example.com/settings/mailbox",
                "logoUrl": "https://www.example.com/logo.png",
                "desiredEmailAddress": "info@example.com",
                "needsSendMail": true,
                "needsCreateDraft": false,
                "needsReadMail": true,
                "needsMoveMail": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The request was processed. Check `status`: HTTP 200 does not mean the operation succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateConnectionResponse"
                },
                "example": {
                  "status": 0,
                  "error": null,
                  "id": "9d1c6f0a-52b7-4e1d-8a3f-6b2e0c4d7f19"
                }
              }
            }
          },
          "401": {
            "description": "The token is missing or has expired. Log in again."
          },
          "403": {
            "description": "No mailbox of your application has the permission for this operation. When a mailbox has just been connected, log in again: a token holds the permissions of the moment it was issued."
          }
        }
      }
    },
    "/api/operation/sendmail": {
      "post": {
        "operationId": "sendMail",
        "tags": [
          "Operations"
        ],
        "summary": "Send a mail",
        "description": "Sends a mail from a connected mailbox. The mail also ends up in the sent items of that mailbox, unless saveToSentItems is false. Counts as 1 action when it succeeds.\n\nLimits: per mailbox 20 a minute, 300 an hour and 1,500 in 24 hours (over all applications that send with it); per application 5,000 in 24 hours and 100 recipients per mail. New applications have half these limits for 7 days. Above a limit the mail is not sent: error RateLimited with retryAfterSeconds and the header Retry-After.\n\nEvery mail goes through a local spam check (no content is stored). A clearly suspicious mail is refused with SuspectedSpam; after 3 refusals in 24 hours sending is paused for the application (SendingPaused) until we lift it.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendMailRequest"
              },
              "example": {
                "sender": {
                  "email": "info@example.com",
                  "alias": "Example BV"
                },
                "to": [
                  {
                    "email": "jan@example.org",
                    "alias": "Jan Jansen"
                  }
                ],
                "cc": [],
                "bcc": [],
                "subject": "Factuur 2026-0042",
                "body": "<p>Beste Jan,</p><p>In de bijlage vind je de factuur.</p>",
                "attachments": [
                  {
                    "filename": "factuur-2026-0042.pdf",
                    "contentType": "application/pdf",
                    "data": "JVBERi0xLjcK"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The request was processed. Check `status`: HTTP 200 does not mean the operation succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SendMailResponse"
                },
                "example": {
                  "status": 0,
                  "error": null,
                  "messageId": null,
                  "retryAfterSeconds": null
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Only with the error RateLimited from the limits of Mailbox Connector: after how many seconds the mail can be sent. The same number as retryAfterSeconds.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "401": {
            "description": "The token is missing or has expired. Log in again."
          },
          "403": {
            "description": "No mailbox of your application has the permission for this operation. When a mailbox has just been connected, log in again: a token holds the permissions of the moment it was issued."
          }
        }
      }
    },
    "/api/operation/createdraft": {
      "post": {
        "operationId": "createDraft",
        "tags": [
          "Operations"
        ],
        "summary": "Create a draft",
        "description": "Prepares a mail in the drafts of a connected mailbox without sending it. Same request as sendmail; `messageId` in the response is the id of the draft. Counts as 1 action when it succeeds.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendMailRequest"
              },
              "example": {
                "sender": {
                  "email": "info@example.com",
                  "alias": "Example BV"
                },
                "to": [
                  {
                    "email": "jan@example.org",
                    "alias": "Jan Jansen"
                  }
                ],
                "cc": [],
                "bcc": [],
                "subject": "Offerte 2026-0107",
                "body": "<p>Beste Jan,</p><p>In de bijlage vind je de factuur.</p>",
                "attachments": []
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The request was processed. Check `status`: HTTP 200 does not mean the operation succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SendMailResponse"
                },
                "example": {
                  "status": 0,
                  "error": null,
                  "messageId": "AAMkAGI2NGVhZTVl..."
                }
              }
            }
          },
          "401": {
            "description": "The token is missing or has expired. Log in again."
          },
          "403": {
            "description": "No mailbox of your application has the permission for this operation. When a mailbox has just been connected, log in again: a token holds the permissions of the moment it was issued."
          }
        }
      }
    },
    "/api/operation/readmails": {
      "post": {
        "operationId": "readMails",
        "tags": [
          "Operations"
        ],
        "summary": "Read mails",
        "description": "Reads mails from the inbox or a folder: one mail by id, or up to 250 per call, with or without filters. A call that returns zero mails has succeeded and counts. Counts as 1 action when it succeeds.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReadMailsRequest"
              },
              "example": {
                "emailAddress": "info@example.com",
                "skip": 0,
                "take": 50,
                "mailSort": 1,
                "filterIsRead": false,
                "filterReceived": {
                  "filter": 3,
                  "value": "2026-09-30"
                },
                "filterSubject": {
                  "filter": 1,
                  "value": "Factuur"
                },
                "filterAttachmentFilenames": [
                  {
                    "filter": 2,
                    "value": ".pdf"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The request was processed. Check `status`: HTTP 200 does not mean the operation succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReadMailsResponse"
                }
              }
            }
          },
          "401": {
            "description": "The token is missing or has expired. Log in again."
          },
          "403": {
            "description": "No mailbox of your application has the permission for this operation. When a mailbox has just been connected, log in again: a token holds the permissions of the moment it was issued."
          }
        }
      }
    },
    "/api/operation/getattachment": {
      "post": {
        "operationId": "getAttachment",
        "tags": [
          "Operations"
        ],
        "summary": "Get the contents of an attachment",
        "description": "readmails only returns the name and type of an attachment; get the contents here. Get attachments BEFORE moving the mail, or use the uniqueId that movemail returns. Free: does not count as an action.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GetAttachmentRequest"
              },
              "example": {
                "emailAddress": "info@example.com",
                "emailId": "AAMkAGI2NGVhZTVl...",
                "attachmentId": "AAMkATT1..."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Not an object but one JSON string with the contents as base64.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string",
                  "format": "byte"
                },
                "example": "JVBERi0xLjcKJeLjz9MK..."
              }
            }
          },
          "204": {
            "description": "Empty: your application has no read permission on this mailbox."
          },
          "401": {
            "description": "The token is missing or has expired. Log in again."
          },
          "403": {
            "description": "No mailbox of your application has the permission for this operation. When a mailbox has just been connected, log in again: a token holds the permissions of the moment it was issued."
          },
          "500": {
            "description": "Fetching at the mail provider failed."
          }
        }
      }
    },
    "/api/operation/checkpath": {
      "post": {
        "operationId": "checkPath",
        "tags": [
          "Operations"
        ],
        "summary": "Check whether a folder exists",
        "description": "Checks whether a folder exists. Nothing is created. Counts as 1 action when it succeeds.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PathExistsRequest"
              },
              "example": {
                "emailAddress": "info@example.com",
                "path": [
                  "Facturen",
                  "2026"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The request was processed. Check `status`: HTTP 200 does not mean the operation succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PathExistsResponse"
                },
                "example": {
                  "status": 0,
                  "error": null,
                  "exists": true
                }
              }
            }
          },
          "401": {
            "description": "The token is missing or has expired. Log in again."
          },
          "403": {
            "description": "No mailbox of your application has the permission for this operation. When a mailbox has just been connected, log in again: a token holds the permissions of the moment it was issued."
          }
        }
      }
    },
    "/api/operation/movemail": {
      "post": {
        "operationId": "moveMail",
        "tags": [
          "Operations"
        ],
        "summary": "Move a mail to a folder",
        "description": "Moves a mail to a folder and can mark it as read in the same call. A folder that does not exist is created. With Google the mail leaves the inbox and its other labels and gets the label of the path. Counts as 1 action when it succeeds.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MoveMailRequest"
              },
              "example": {
                "emailAddress": "info@example.com",
                "messageId": "AAMkAGI2NGVhZTVl...",
                "path": [
                  "Verwerkt"
                ],
                "readStatus": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The request was processed. Check `status`: HTTP 200 does not mean the operation succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MoveMailResponse"
                },
                "example": {
                  "status": 0,
                  "error": null,
                  "uniqueId": "AAMkAGI2NGVhZTVlLWJh..."
                }
              }
            }
          },
          "401": {
            "description": "The token is missing or has expired. Log in again."
          },
          "403": {
            "description": "No mailbox of your application has the permission for this operation. When a mailbox has just been connected, log in again: a token holds the permissions of the moment it was issued."
          }
        }
      }
    },
    "/api/operation/setreadstatus": {
      "post": {
        "operationId": "setReadStatus",
        "tags": [
          "Operations"
        ],
        "summary": "Mark a mail as read or unread",
        "description": "Marks a mail as read or unread without moving it. To move and mark, use movemail with readStatus. Counts as 1 action when it succeeds.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetReadStatusRequest"
              },
              "example": {
                "emailAddress": "info@example.com",
                "emailId": "AAMkAGI2NGVhZTVl...",
                "readStatus": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The request was processed. Check `status`: HTTP 200 does not mean the operation succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SetReadStatusResponse"
                },
                "example": {
                  "status": 0,
                  "error": null
                }
              }
            }
          },
          "401": {
            "description": "The token is missing or has expired. Log in again."
          },
          "403": {
            "description": "No mailbox of your application has the permission for this operation. When a mailbox has just been connected, log in again: a token holds the permissions of the moment it was issued."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "The token from POST /api/login, valid for 10 minutes."
      }
    },
    "schemas": {
      "ResponseStatus": {
        "type": "integer",
        "description": "Result of the operation. 0 = Success. 1 = Failure: `error` holds the reason. 2 = Unauthorized: this mailbox is not connected to your application, or not with the permission this operation needs.",
        "enum": [
          0,
          1,
          2
        ],
        "x-enum-varnames": [
          "Success",
          "Failure",
          "Unauthorized"
        ]
      },
      "ErrorReason": {
        "type": "string",
        "description": "The reason when status is 1, otherwise null. InvalidRecipients: an address was refused, correct it. MessageTooLarge: shrink the attachments. QuotaExceeded: the mailbox reached its limit, try later. RateLimited: too many mails in a short time; wait retryAfterSeconds (or a minute when empty) and try again. TooManyRecipients: more than 100 recipients in one mail, split it. SuspectedSpam: the spam check refused the mail; do not send it again unchanged. SendingPaused: sending is paused for the application after repeated refusals; contact us. ProviderUnavailable: try later. ReauthRequired: the mailbox must be connected again. MailboxNotAvailable: the provider has no working mailbox for this address (licence removed, user deleted, not in the cloud); restore it or connect another. Both are unlinked automatically after 4 hours and at least 10 calls, and the administrators of the account are mailed. UnexpectedError: anything else, such as an unknown id or an empty path.",
        "nullable": true,
        "enum": [
          "InvalidRecipients",
          "MessageTooLarge",
          "QuotaExceeded",
          "RateLimited",
          "TooManyRecipients",
          "SuspectedSpam",
          "SendingPaused",
          "ProviderUnavailable",
          "ReauthRequired",
          "MailboxNotAvailable",
          "UnexpectedError",
          null
        ]
      },
      "ChallengeResponse": {
        "type": "object",
        "properties": {
          "challenge": {
            "type": "integer",
            "description": "Line number in the key file, counted from 0. It is a counter per application: every login attempt, right or wrong, moves it one up.",
            "minimum": 0,
            "maximum": 999999
          }
        },
        "required": [
          "challenge"
        ]
      },
      "LoginRequest": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The line of the key file that belongs to the challenge: skip `challenge` lines and take the next one."
          },
          "applicationId": {
            "type": "string",
            "description": "The id of your application.",
            "format": "uuid"
          },
          "securityKey": {
            "type": "string",
            "description": "The security key of your application."
          }
        },
        "required": [
          "code",
          "applicationId",
          "securityKey"
        ]
      },
      "LoginResponse": {
        "type": "object",
        "properties": {
          "validMinutes": {
            "type": "integer",
            "description": "How long the token is valid: 10 minutes."
          },
          "bearer": {
            "type": "string",
            "description": "The token (JWT) for all following calls."
          }
        },
        "required": [
          "validMinutes",
          "bearer"
        ]
      },
      "ConnectionRequest": {
        "type": "object",
        "properties": {
          "desiredEmailAddress": {
            "type": "string",
            "description": "Address of the mailbox."
          },
          "needsSendMail": {
            "type": "boolean",
            "description": "You want to send mail."
          },
          "needsCreateDraft": {
            "type": "boolean",
            "description": "You want to create drafts."
          },
          "needsReadMail": {
            "type": "boolean",
            "description": "You want to read mail, get attachments and check folders."
          },
          "needsMoveMail": {
            "type": "boolean",
            "description": "You want to move mails and set the read status."
          },
          "returnUrl": {
            "type": "string",
            "description": "Create only: the page in your application the user returns to after connecting.",
            "nullable": true
          },
          "logoUrl": {
            "type": "string",
            "description": "Create only: the logo of your application, for the connect page.",
            "nullable": true
          }
        },
        "required": [
          "desiredEmailAddress"
        ]
      },
      "CheckConnectionResponse": {
        "type": "object",
        "properties": {
          "connectionStatus": {
            "type": "integer",
            "description": "0 = NotConfigured: not connected, create a connection request. 1 = MissingPermissions: connected, but not for everything you ask; create a new connection request with the permissions you need. 2 = Connected.",
            "enum": [
              0,
              1,
              2
            ],
            "x-enum-varnames": [
              "NotConfigured",
              "MissingPermissions",
              "Connected"
            ]
          }
        },
        "required": [
          "connectionStatus"
        ]
      },
      "CreateConnectionResponse": {
        "type": "object",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/ResponseStatus"
          },
          "error": {
            "$ref": "#/components/schemas/ErrorReason"
          },
          "id": {
            "type": "string",
            "description": "Id of the connection request. Send the user to https://mailboxconnector.com/connect/{id}. Valid for 30 minutes.",
            "format": "uuid"
          }
        },
        "required": [
          "status",
          "id"
        ]
      },
      "EmailAddress": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "description": "The e-mail address."
          },
          "alias": {
            "type": "string",
            "description": "Display name. When left out, the part before the at sign is used.",
            "nullable": true
          }
        },
        "required": [
          "email"
        ]
      },
      "MailAttachment": {
        "type": "object",
        "properties": {
          "filename": {
            "type": "string",
            "description": "File name."
          },
          "contentType": {
            "type": "string",
            "description": "Media type, for example application/pdf."
          },
          "data": {
            "type": "string",
            "description": "Contents of the file as base64.",
            "format": "byte"
          },
          "contentId": {
            "type": "string",
            "description": "Leave out for a regular attachment. Fill it to show an image inside the text: choose an id such as \"logo\" and point to it in the body as <img src=\"cid:logo\">. An image the body does not point to is sent as a regular attachment.",
            "nullable": true
          }
        },
        "required": [
          "filename",
          "contentType",
          "data"
        ]
      },
      "SendMailRequest": {
        "type": "object",
        "properties": {
          "sender": {
            "allOf": [
              {
                "$ref": "#/components/schemas/EmailAddress"
              }
            ],
            "description": "The connected mailbox you send from."
          },
          "to": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailAddress"
            },
            "description": "Recipients."
          },
          "cc": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailAddress"
            },
            "description": "Recipients in copy."
          },
          "bcc": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailAddress"
            },
            "description": "Recipients in blind copy."
          },
          "subject": {
            "type": "string",
            "description": "Subject."
          },
          "body": {
            "type": "string",
            "description": "Content, as HTML."
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MailAttachment"
            },
            "description": "Attachments, and images that are shown inside the text (those have a contentId)."
          },
          "saveToSentItems": {
            "type": "boolean",
            "nullable": true,
            "description": "sendmail: whether a copy is kept in the sent items of the sending mailbox. Empty or true keeps it (the default); false for mails nobody needs to find back there, such as login codes. Ignored for createdraft."
          }
        },
        "required": [
          "sender",
          "to"
        ]
      },
      "SendMailResponse": {
        "type": "object",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/ResponseStatus"
          },
          "error": {
            "$ref": "#/components/schemas/ErrorReason"
          },
          "messageId": {
            "type": "string",
            "description": "createdraft: the id of the draft. sendmail: not filled.",
            "nullable": true
          },
          "retryAfterSeconds": {
            "type": "integer",
            "nullable": true,
            "description": "sendmail with the error RateLimited from the limits of Mailbox Connector: after how many seconds the mail can be sent. Also in the header Retry-After. Otherwise null."
          }
        },
        "required": [
          "status"
        ]
      },
      "StringFilter": {
        "type": "object",
        "properties": {
          "filter": {
            "type": "integer",
            "description": "0 = Equals, 1 = StartsWith, 2 = EndsWith.",
            "enum": [
              0,
              1,
              2
            ],
            "x-enum-varnames": [
              "Equals",
              "StartsWith",
              "EndsWith"
            ]
          },
          "value": {
            "type": "string",
            "description": "The text to compare with."
          }
        },
        "required": [
          "filter",
          "value"
        ]
      },
      "DateFilter": {
        "type": "object",
        "properties": {
          "filter": {
            "type": "integer",
            "description": "1 = EqualsDay (on that day), 2 = Before (before that day), 3 = After (after that day). With 2 and 3 the day itself is not included.",
            "enum": [
              1,
              2,
              3
            ],
            "x-enum-varnames": [
              "EqualsDay",
              "Before",
              "After"
            ]
          },
          "value": {
            "type": "string",
            "description": "The day, as 2026-10-01. Send no time and no time zone. It is the day as it appears in `received`.",
            "format": "date"
          }
        },
        "required": [
          "filter",
          "value"
        ]
      },
      "ReadMailsRequest": {
        "type": "object",
        "properties": {
          "emailAddress": {
            "type": "string",
            "description": "Address of the connected mailbox."
          },
          "path": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Folder to read. Leave out for the inbox. Folder as a list of names from top to bottom, for example [\"Facturen\", \"2026\"]. Microsoft 365: starts in the inbox, with the names as the user sees them; a first name that is the inbox itself is skipped. Google: the names joined with \"/\" are a label.",
            "nullable": true
          },
          "skip": {
            "type": "integer",
            "description": "How many mails to skip.",
            "minimum": 0,
            "default": 0
          },
          "take": {
            "type": "integer",
            "description": "How many mails you want, 1 to 250. More becomes 250. Always send it: without it you get 1 mail.",
            "minimum": 1,
            "maximum": 250
          },
          "mailSort": {
            "type": "integer",
            "description": "1 = NewToOld (newest first; use this). 0 = OldToNew: with Google the whole folder is read for it, so only use it with filters that keep the number small. Always send it: without it you get OldToNew.",
            "enum": [
              0,
              1
            ],
            "x-enum-varnames": [
              "OldToNew",
              "NewToOld"
            ]
          },
          "filterUniqueId": {
            "type": "string",
            "description": "uniqueId of one mail. You get exactly that mail; the path and all other filters are ignored.",
            "nullable": true
          },
          "filterIsRead": {
            "type": "boolean",
            "description": "false = unread mails only, true = read mails only.",
            "nullable": true
          },
          "filterReceived": {
            "allOf": [
              {
                "$ref": "#/components/schemas/DateFilter"
              }
            ],
            "description": "On the day of receipt."
          },
          "filterSender": {
            "allOf": [
              {
                "$ref": "#/components/schemas/StringFilter"
              }
            ],
            "description": "On the e-mail address of the sender. Text is compared without distinguishing upper and lower case."
          },
          "filterTo": {
            "allOf": [
              {
                "$ref": "#/components/schemas/StringFilter"
              }
            ],
            "description": "On the address of a recipient; one matching recipient is enough."
          },
          "filterCc": {
            "allOf": [
              {
                "$ref": "#/components/schemas/StringFilter"
              }
            ],
            "description": "Like filterTo, for the recipients in copy."
          },
          "filterBcc": {
            "allOf": [
              {
                "$ref": "#/components/schemas/StringFilter"
              }
            ],
            "description": "Like filterTo, for the recipients in blind copy."
          },
          "filterSubject": {
            "allOf": [
              {
                "$ref": "#/components/schemas/StringFilter"
              }
            ],
            "description": "On the subject."
          },
          "filterBody": {
            "allOf": [
              {
                "$ref": "#/components/schemas/StringFilter"
              }
            ],
            "description": "On the content; the comparison is made with the raw HTML."
          },
          "filterAttachmentFilenames": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StringFilter"
            },
            "description": "On file names of attachments. For every filter in the list the mail must have a matching attachment."
          },
          "conversationId": {
            "allOf": [
              {
                "$ref": "#/components/schemas/StringFilter"
              }
            ],
            "description": "On the conversation the mail belongs to. With filter 0 you get all mails of one conversation."
          }
        },
        "required": [
          "emailAddress",
          "take",
          "mailSort"
        ],
        "description": "All filters you send must match."
      },
      "Attachment": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Id of the attachment; use it as attachmentId in getattachment."
          },
          "filename": {
            "type": "string",
            "description": "File name."
          },
          "contentType": {
            "type": "string",
            "description": "Media type."
          },
          "contentId": {
            "type": "string",
            "description": "Content id of an image that is part of the text, otherwise null.",
            "nullable": true
          }
        },
        "required": [
          "id"
        ]
      },
      "Message": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "description": "When this message was sent, as wall-clock time of the sender without a time zone. Can be null for older messages.",
            "format": "date-time",
            "nullable": true,
            "example": "2026-09-29T10:15:00"
          },
          "sender": {
            "allOf": [
              {
                "$ref": "#/components/schemas/EmailAddress"
              }
            ],
            "description": "Who wrote this message. Can be null when the header above a quoted message names no sender.",
            "nullable": true
          },
          "text": {
            "type": "string",
            "description": "The text of this message only. Bold is **text**, italic is _text_, underlined is __text__. An image is <img src='cid:ID'> at the place where it is in the message; ID is the id of an attachment in inlineImages. Empty lines are where the mail program shows space between paragraphs."
          },
          "inlineImages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Attachment"
            },
            "description": "The images that are part of the text of this message."
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Attachment"
            },
            "description": "The regular attachments of the mail; they are always with the first message."
          }
        },
        "description": "One message of the thread inside a mail. Splitting a thread is best effort: it works for the common forms in Dutch, English, German and French."
      },
      "Email": {
        "type": "object",
        "properties": {
          "uniqueId": {
            "type": "string",
            "description": "Id of the mail. Use it as emailId or messageId in the other operations."
          },
          "conversationId": {
            "type": "string",
            "description": "The conversation the mail belongs to."
          },
          "path": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true,
            "description": "Where the mail is, in the same terms as the paths you read from and move to: null for the inbox, [\"Facturen\", \"2026\"] for a folder in the inbox (with Google: the label Facturen/2026), and an empty array when no path points to it, such as the sent items or the archive."
          },
          "received": {
            "type": "string",
            "description": "Moment of receipt as wall-clock time of the sender, WITHOUT a time zone (not UTC).",
            "format": "date-time",
            "example": "2026-09-30T16:56:22"
          },
          "sender": {
            "$ref": "#/components/schemas/EmailAddress"
          },
          "to": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailAddress"
            },
            "description": "Recipients."
          },
          "cc": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailAddress"
            },
            "description": "Recipients in copy."
          },
          "bcc": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailAddress"
            },
            "description": "Recipients in blind copy."
          },
          "subject": {
            "type": "string",
            "description": "Subject."
          },
          "body": {
            "type": "string",
            "description": "The full content, as raw HTML."
          },
          "isRead": {
            "type": "boolean",
            "description": "Whether the mail has been read."
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Attachment"
            },
            "description": "All attachments, including images that are part of the text. Get the contents with getattachment."
          },
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Message"
            },
            "description": "The mail split into separate messages, newest first: what the sender wrote, then the messages quoted below it."
          }
        }
      },
      "ReadMailsResponse": {
        "type": "object",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/ResponseStatus"
          },
          "error": {
            "$ref": "#/components/schemas/ErrorReason"
          },
          "emails": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Email"
            },
            "description": "The mails."
          }
        },
        "required": [
          "status"
        ]
      },
      "GetAttachmentRequest": {
        "type": "object",
        "properties": {
          "emailAddress": {
            "type": "string",
            "description": "Address of the connected mailbox."
          },
          "emailId": {
            "type": "string",
            "description": "uniqueId of the mail."
          },
          "attachmentId": {
            "type": "string",
            "description": "id of the attachment, from attachments or inlineImages."
          }
        },
        "required": [
          "emailAddress",
          "emailId",
          "attachmentId"
        ]
      },
      "PathExistsRequest": {
        "type": "object",
        "properties": {
          "emailAddress": {
            "type": "string",
            "description": "Address of the connected mailbox."
          },
          "path": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Folder as a list of names from top to bottom, for example [\"Facturen\", \"2026\"]. Microsoft 365: starts in the inbox, with the names as the user sees them; a first name that is the inbox itself is skipped. Google: the names joined with \"/\" are a label."
          }
        },
        "required": [
          "emailAddress",
          "path"
        ]
      },
      "PathExistsResponse": {
        "type": "object",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/ResponseStatus"
          },
          "error": {
            "$ref": "#/components/schemas/ErrorReason"
          },
          "exists": {
            "type": "boolean",
            "description": "Whether the folder exists."
          }
        },
        "required": [
          "status"
        ]
      },
      "MoveMailRequest": {
        "type": "object",
        "properties": {
          "emailAddress": {
            "type": "string",
            "description": "Address of the connected mailbox."
          },
          "messageId": {
            "type": "string",
            "description": "uniqueId of the mail."
          },
          "path": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Folder the mail goes to, at least one name. A folder that does not exist is created. Folder as a list of names from top to bottom, for example [\"Facturen\", \"2026\"]. Microsoft 365: starts in the inbox, with the names as the user sees them; a first name that is the inbox itself is skipped. Google: the names joined with \"/\" are a label."
          },
          "readStatus": {
            "type": "boolean",
            "description": "true also marks the mail as read, false as unread. Leave out to keep the read status as it is.",
            "nullable": true
          }
        },
        "required": [
          "emailAddress",
          "messageId",
          "path"
        ]
      },
      "MoveMailResponse": {
        "type": "object",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/ResponseStatus"
          },
          "error": {
            "$ref": "#/components/schemas/ErrorReason"
          },
          "uniqueId": {
            "type": "string",
            "description": "Id of the mail after the move. With Microsoft 365 a moved mail gets a new id and the old one stops working: use this one from now on.",
            "nullable": true
          }
        },
        "required": [
          "status"
        ]
      },
      "SetReadStatusRequest": {
        "type": "object",
        "properties": {
          "emailAddress": {
            "type": "string",
            "description": "Address of the connected mailbox."
          },
          "emailId": {
            "type": "string",
            "description": "uniqueId of the mail."
          },
          "readStatus": {
            "type": "boolean",
            "description": "true = read, false = unread."
          }
        },
        "required": [
          "emailAddress",
          "emailId",
          "readStatus"
        ]
      },
      "SetReadStatusResponse": {
        "type": "object",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/ResponseStatus"
          },
          "error": {
            "$ref": "#/components/schemas/ErrorReason"
          }
        },
        "required": [
          "status"
        ]
      }
    }
  }
}
