# Messages

Interactions with messages

## Show email message

> Get email message by ID.

```json
{"openapi":"3.1.0","info":{"title":"Email Sandbox","version":"2.0.0"},"tags":[{"name":"Messages","description":"Interactions with messages"}],"servers":[{"description":"Mailtrap API","url":"https://mailtrap.io"}],"security":[{"HeaderAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"HeaderAuth":{"type":"apiKey","description":"Pass the API token in the Api-Token","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"InboxMessageWithoutBlacklistsReportInfo":{"title":"Message without blacklists report","type":"object","properties":{"id":{"type":"integer"},"inbox_id":{"type":"integer"},"subject":{"type":"string"},"sent_at":{"type":"string"},"from_email":{"type":"string"},"from_name":{"type":"string"},"to_email":{"type":"string"},"to_name":{"type":"string"},"email_size":{"type":"integer"},"is_read":{"type":"boolean"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"html_body_size":{"type":"integer"},"text_body_size":{"type":"integer"},"human_size":{"type":"string"},"html_path":{"type":"string"},"txt_path":{"type":"string"},"raw_path":{"type":"string"},"download_path":{"type":"string"},"html_source_path":{"type":"string"},"blacklists_report_info":{"type":"boolean"},"smtp_information":{"type":"object","properties":{"ok":{"type":"boolean"},"data":{"type":"object","properties":{"mail_from_addr":{"type":"string"},"client_ip":{"type":"string"}}}}}}},"InboxMessageWithBlacklistsReportInfo":{"title":"Message with blacklists report","type":"object","properties":{"id":{"type":"integer"},"inbox_id":{"type":"integer"},"subject":{"type":"string"},"sent_at":{"type":"string"},"from_email":{"type":"string"},"from_name":{"type":"string"},"to_email":{"type":"string"},"to_name":{"type":"string"},"email_size":{"type":"integer"},"is_read":{"type":"boolean"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"html_body_size":{"type":"integer"},"text_body_size":{"type":"integer"},"human_size":{"type":"string"},"html_path":{"type":"string"},"txt_path":{"type":"string"},"raw_path":{"type":"string"},"download_path":{"type":"string"},"html_source_path":{"type":"string"},"blacklists_report_info":{"type":"object","properties":{"result":{"type":"string","enum":["success","pending","error"]},"domain":{"type":"string"},"ip":{"type":"string"},"report":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"url":{"type":"string"},"in_black_list":{"type":"boolean"}}}}}},"smtp_information":{"type":"object","properties":{"ok":{"type":"boolean"},"data":{"type":"object","properties":{"mail_from_addr":{"type":"string"},"client_ip":{"type":"string"}}}}}}},"UnauthenticatedResponse":{"title":"UnauthenticatedResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}},"NotFoundResponse":{"title":"NotFoundResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}}},"responses":{"UNAUTHENTICATED":{"description":"Returns unauthorized error message. Check your credentials.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthenticatedResponse"}}}},"NOT_FOUND":{"description":"Returns not found error message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFoundResponse"}}}}}},"paths":{"/api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id}":{"get":{"summary":"Show email message","description":"Get email message by ID.","tags":["Messages"],"responses":{"200":{"description":"Returns email message with its attributes.","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InboxMessageWithoutBlacklistsReportInfo"},{"$ref":"#/components/schemas/InboxMessageWithBlacklistsReportInfo"}]}}}},"401":{"$ref":"#/components/responses/UNAUTHENTICATED"},"403":{"description":"Returns forbidden error message. Check your permissions.","content":{"application/json":{"schema":{"type":"object","properties":{"errors":{"type":"string"}}}}}},"404":{"$ref":"#/components/responses/NOT_FOUND"}},"operationId":"showInboxEmailMessage"}}}}
```

## Delete message

> Delete message from inbox.

```json
{"openapi":"3.1.0","info":{"title":"Email Sandbox","version":"2.0.0"},"tags":[{"name":"Messages","description":"Interactions with messages"}],"servers":[{"description":"Mailtrap API","url":"https://mailtrap.io"}],"security":[{"HeaderAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"HeaderAuth":{"type":"apiKey","description":"Pass the API token in the Api-Token","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"responses":{"UNAUTHENTICATED":{"description":"Returns unauthorized error message. Check your credentials.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthenticatedResponse"}}}},"PERMISSION_DENIED":{"description":"Returns forbidden error message. Check your permissions.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PermissionsDeniedResponse"}}}},"NOT_FOUND":{"description":"Returns not found error message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFoundResponse"}}}}},"schemas":{"UnauthenticatedResponse":{"title":"UnauthenticatedResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}},"PermissionsDeniedResponse":{"title":"PermissionsDeniedResponse","type":"object","properties":{"errors":{"type":"string","description":"Error message"}}},"NotFoundResponse":{"title":"NotFoundResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}}}},"paths":{"/api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id}":{"delete":{"summary":"Delete message","description":"Delete message from inbox.","tags":["Messages"],"responses":{"200":{"description":"Returns attributes of the deleted message.","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"integer"},"inbox_id":{"type":"integer"},"subject":{"type":"string"},"sent_at":{"type":"string"},"from_email":{"type":"string"},"from_name":{"type":"string"},"to_email":{"type":"string"},"to_name":{"type":"string"},"email_size":{"type":"integer"},"is_read":{"type":"boolean"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"html_body_size":{"type":"integer"},"text_body_size":{"type":"integer"},"human_size":{"type":"string"},"html_path":{"type":"string"},"txt_path":{"type":"string"},"raw_path":{"type":"string"},"download_path":{"type":"string"},"html_source_path":{"type":"string"},"blacklists_report_info":{"type":"boolean"},"smtp_information":{"type":"object","properties":{"ok":{"type":"boolean"},"data":{"type":"object","properties":{"mail_from_addr":{"type":"string"},"client_ip":{"type":"string"}}}}}}}}}},"401":{"$ref":"#/components/responses/UNAUTHENTICATED"},"403":{"$ref":"#/components/responses/PERMISSION_DENIED"},"404":{"$ref":"#/components/responses/NOT_FOUND"}},"operationId":"deleteInboxEmailMessage"}}}}
```

## Update message

> Update message attributes (right now only the \*\*is\_read\*\* attribute is available for modification).

```json
{"openapi":"3.1.0","info":{"title":"Email Sandbox","version":"2.0.0"},"tags":[{"name":"Messages","description":"Interactions with messages"}],"servers":[{"description":"Mailtrap API","url":"https://mailtrap.io"}],"security":[{"HeaderAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"HeaderAuth":{"type":"apiKey","description":"Pass the API token in the Api-Token","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"responses":{"UNAUTHENTICATED":{"description":"Returns unauthorized error message. Check your credentials.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthenticatedResponse"}}}},"NOT_FOUND":{"description":"Returns not found error message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFoundResponse"}}}}},"schemas":{"UnauthenticatedResponse":{"title":"UnauthenticatedResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}},"NotFoundResponse":{"title":"NotFoundResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}}}},"paths":{"/api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id}":{"patch":{"summary":"Update message","description":"Update message attributes (right now only the **is_read** attribute is available for modification).","tags":["Messages"],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"object","properties":{"is_read":{"type":"string"}}}}}}}},"responses":{"200":{"description":"Returns attributes of the updated message.","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"integer"},"inbox_id":{"type":"integer"},"subject":{"type":"string"},"sent_at":{"type":"string"},"from_email":{"type":"string"},"from_name":{"type":"string"},"to_email":{"type":"string"},"to_name":{"type":"string"},"email_size":{"type":"integer"},"is_read":{"type":"boolean"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"html_body_size":{"type":"integer"},"text_body_size":{"type":"integer"},"human_size":{"type":"string"},"html_path":{"type":"string"},"txt_path":{"type":"string"},"raw_path":{"type":"string"},"download_path":{"type":"string"},"html_source_path":{"type":"string"},"blacklists_report_info":{"type":"boolean"},"smtp_information":{"type":"object","properties":{"ok":{"type":"boolean"},"data":{"type":"object","properties":{"mail_from_addr":{"type":"string"},"client_ip":{"type":"string"}}}}}}}}}},"401":{"$ref":"#/components/responses/UNAUTHENTICATED"},"403":{"description":"Returns forbidden error message. Check your permissions.","content":{"application/json":{"schema":{"type":"object","properties":{"errors":{"type":"string"}}}}}},"404":{"$ref":"#/components/responses/NOT_FOUND"}},"operationId":"updateInboxEmailMessage"}}}}
```

## Get messages

> Get all messages in the inbox. The response contains up to 30 messages. Use \`last\_id\` or \`page\` to retrieve more.

```json
{"openapi":"3.1.0","info":{"title":"Email Sandbox","version":"2.0.0"},"tags":[{"name":"Messages","description":"Interactions with messages"}],"servers":[{"description":"Mailtrap API","url":"https://mailtrap.io"}],"security":[{"HeaderAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"HeaderAuth":{"type":"apiKey","description":"Pass the API token in the Api-Token","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"responses":{"UNAUTHENTICATED":{"description":"Returns unauthorized error message. Check your credentials.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthenticatedResponse"}}}}},"schemas":{"UnauthenticatedResponse":{"title":"UnauthenticatedResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}}}},"paths":{"/api/accounts/{account_id}/inboxes/{inbox_id}/messages":{"get":{"summary":"Get messages","description":"Get all messages in the inbox. The response contains up to 30 messages. Use `last_id` or `page` to retrieve more.","tags":["Messages"],"responses":{"200":{"description":"lists messages","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"integer"},"inbox_id":{"type":"integer"},"subject":{"type":"string"},"sent_at":{"type":"string"},"from_email":{"type":"string"},"from_name":{"type":"string"},"to_email":{"type":"string"},"to_name":{"type":"string"},"email_size":{"type":"integer"},"is_read":{"type":"boolean"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"html_body_size":{"type":"integer"},"text_body_size":{"type":"integer"},"human_size":{"type":"string"},"html_path":{"type":"string"},"txt_path":{"type":"string"},"raw_path":{"type":"string"},"download_path":{"type":"string"},"html_source_path":{"type":"string"},"blacklists_report_info":{"type":"boolean"},"smtp_information":{"type":"object","properties":{"ok":{"type":"boolean"},"data":{"type":"object","properties":{"mail_from_addr":{"type":"string"},"client_ip":{"type":"string"}}}}}}}}}}},"401":{"$ref":"#/components/responses/UNAUTHENTICATED"},"403":{"description":"Returns forbidden error message. Check your permissions.","content":{"application/json":{"schema":{"type":"object","properties":{"errors":{"type":"string"}}}}}}},"operationId":"getInboxEmailMessage","parameters":[{"schema":{"type":"string"},"in":"query","name":"search","description":"Search query string. Matches `subject`, `to_email`,  and `to_name`."},{"schema":{"type":"number","minimum":1},"in":"query","name":"last_id","description":"If specified, a page of records before `last_id` is  returned. Overrides `page` if both are given."},{"schema":{"type":"number","minimum":1},"in":"query","name":"page","description":"Page number for paginated results."}]}}}}
```

## Forward message

> Forward message to an email address. The email address must be confirmed by the recipient in advance.

```json
{"openapi":"3.1.0","info":{"title":"Email Sandbox","version":"2.0.0"},"tags":[{"name":"Messages","description":"Interactions with messages"}],"servers":[{"description":"Mailtrap API","url":"https://mailtrap.io"}],"security":[{"HeaderAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"HeaderAuth":{"type":"apiKey","description":"Pass the API token in the Api-Token","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"responses":{"UNAUTHENTICATED":{"description":"Returns unauthorized error message. Check your credentials.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthenticatedResponse"}}}},"NOT_FOUND":{"description":"Returns not found error message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFoundResponse"}}}}},"schemas":{"UnauthenticatedResponse":{"title":"UnauthenticatedResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}},"NotFoundResponse":{"title":"NotFoundResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}}}},"paths":{"/api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id}/forward":{"post":{"summary":"Forward message","description":"Forward message to an email address. The email address must be confirmed by the recipient in advance.","tags":["Messages"],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string"}}}}}},"responses":{"200":{"description":"Returns confirmation about forwarding.","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"401":{"$ref":"#/components/responses/UNAUTHENTICATED"},"403":{"description":"Returns forbidden error message. Check your permissions.","content":{"application/json":{"schema":{"type":"object","properties":{"errors":{"type":"string"}}}}}},"404":{"$ref":"#/components/responses/NOT_FOUND"}},"operationId":"forwardInboxEmailMessage"}}}}
```

## Get message spam score

> Get a brief spam report by message ID.

```json
{"openapi":"3.1.0","info":{"title":"Email Sandbox","version":"2.0.0"},"tags":[{"name":"Messages","description":"Interactions with messages"}],"servers":[{"description":"Mailtrap API","url":"https://mailtrap.io"}],"security":[{"HeaderAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"HeaderAuth":{"type":"apiKey","description":"Pass the API token in the Api-Token","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"responses":{"UNAUTHENTICATED":{"description":"Returns unauthorized error message. Check your credentials.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthenticatedResponse"}}}},"NOT_FOUND":{"description":"Returns not found error message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFoundResponse"}}}}},"schemas":{"UnauthenticatedResponse":{"title":"UnauthenticatedResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}},"NotFoundResponse":{"title":"NotFoundResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}}}},"paths":{"/api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id}/spam_report":{"get":{"summary":"Get message spam score","description":"Get a brief spam report by message ID.","tags":["Messages"],"responses":{"200":{"description":"Returns message spam analysis report.","content":{"application/json":{"schema":{"type":"object","properties":{"report":{"type":"object","properties":{"ResponseCode":{"type":"integer"},"ResponseMessage":{"type":"string"},"ResponseVersion":{"type":"string"},"Score":{"type":"number","format":"float"},"Spam":{"type":"boolean"},"Threshold":{"type":"number","format":"float"},"Details":{"type":"array","items":{"type":"object","nullable":true,"properties":{"Pts":{"type":"number","format":"float"},"RuleName":{"type":"string"},"Description":{"type":"string"}}}}}}}}}}},"401":{"$ref":"#/components/responses/UNAUTHENTICATED"},"403":{"description":"Returns forbidden error message. Check your permissions.","content":{"application/json":{"schema":{"type":"object","properties":{"errors":{"type":"string"}}}}}},"404":{"$ref":"#/components/responses/NOT_FOUND"}},"operationId":"getInboxEmailMessageSpamReport"}}}}
```

## Get message HTML analysis

> Get a brief HTML report by message ID.

```json
{"openapi":"3.1.0","info":{"title":"Email Sandbox","version":"2.0.0"},"tags":[{"name":"Messages","description":"Interactions with messages"}],"servers":[{"description":"Mailtrap API","url":"https://mailtrap.io"}],"security":[{"HeaderAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"HeaderAuth":{"type":"apiKey","description":"Pass the API token in the Api-Token","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"responses":{"UNAUTHENTICATED":{"description":"Returns unauthorized error message. Check your credentials.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthenticatedResponse"}}}},"NOT_FOUND":{"description":"Returns not found error message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFoundResponse"}}}}},"schemas":{"UnauthenticatedResponse":{"title":"UnauthenticatedResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}},"NotFoundResponse":{"title":"NotFoundResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}}}},"paths":{"/api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id}/analyze":{"get":{"summary":"Get message HTML analysis","description":"Get a brief HTML report by message ID.","tags":["Messages"],"responses":{"200":{"description":"Returns message HTML analysis report.","content":{"application/json":{"schema":{"type":"object","properties":{"report":{"type":"object","properties":{"success":{"type":"string"},"errors":{"type":"array","items":{"type":"object","nullable":true,"properties":{"error_line":{"type":"number"},"rule_name":{"type":"string"},"email_clients":{"type":"object","properties":{"desktop":{"type":"array","items":{"type":"string"}},"mobile":{"type":"array","items":{"type":"string"}},"web":{"type":"array","items":{"type":"string"}}}}}}}}}}}}}},"401":{"$ref":"#/components/responses/UNAUTHENTICATED"},"403":{"description":"Returns forbidden error message. Check your permissions.","content":{"application/json":{"schema":{"type":"object","properties":{"errors":{"type":"string"}}}}}},"404":{"$ref":"#/components/responses/NOT_FOUND"}},"operationId":"getInboxEmailMessageHTMLAnalysis"}}}}
```

## Get text message

> Get text email body, if it exists.

```json
{"openapi":"3.1.0","info":{"title":"Email Sandbox","version":"2.0.0"},"tags":[{"name":"Messages","description":"Interactions with messages"}],"servers":[{"description":"Mailtrap API","url":"https://mailtrap.io"}],"security":[{"HeaderAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"HeaderAuth":{"type":"apiKey","description":"Pass the API token in the Api-Token","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"responses":{"NOT_FOUND":{"description":"Returns not found error message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFoundResponse"}}}}},"schemas":{"NotFoundResponse":{"title":"NotFoundResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}}}},"paths":{"/api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id}/body.txt":{"get":{"summary":"Get text message","description":"Get text email body, if it exists.","tags":["Messages"],"responses":{"200":{"description":"Returns message body in txt format.","content":{"text/plain":{"schema":{"type":"string"}}}},"401":{"description":"Returns unauthorized error message. Check your credentials.","content":{"text/plain":{"schema":{"type":"string"}}}},"403":{"description":"Returns forbidden error message. Check your permissions.","content":{"text/plain":{"schema":{"type":"string"}}}},"404":{"$ref":"#/components/responses/NOT_FOUND"},"409":{"description":"Returns conflict error message. Text body does not exist.","content":{"text/plain":{"schema":{"type":"string"}}}}},"operationId":"getInboxEmailMessageBodyAsTxt"}}}}
```

## Get raw message

> Get raw email body.

```json
{"openapi":"3.1.0","info":{"title":"Email Sandbox","version":"2.0.0"},"tags":[{"name":"Messages","description":"Interactions with messages"}],"servers":[{"description":"Mailtrap API","url":"https://mailtrap.io"}],"security":[{"HeaderAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"HeaderAuth":{"type":"apiKey","description":"Pass the API token in the Api-Token","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"responses":{"NOT_FOUND":{"description":"Returns not found error message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFoundResponse"}}}}},"schemas":{"NotFoundResponse":{"title":"NotFoundResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}}}},"paths":{"/api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id}/body.raw":{"get":{"summary":"Get raw message","description":"Get raw email body.","tags":["Messages"],"responses":{"200":{"description":"Returns raw message body.","content":{"text/plain":{"schema":{"type":"string"}}}},"401":{"description":"Returns unauthorized error message. Check your credentials.","content":{"text/plain":{"schema":{"type":"string"}}}},"403":{"description":"Returns forbidden error message. Check your permissions.","content":{"text/plain":{"schema":{"type":"string"}}}},"404":{"$ref":"#/components/responses/NOT_FOUND"},"409":{"description":"Returns conflict error message. Raw body does not exist.","content":{"text/plain":{"schema":{"type":"string"}}}}},"operationId":"getInboxEmailMessageBodyAsRaw"}}}}
```

## Get message source

> Get HTML source of email.

```json
{"openapi":"3.1.0","info":{"title":"Email Sandbox","version":"2.0.0"},"tags":[{"name":"Messages","description":"Interactions with messages"}],"servers":[{"description":"Mailtrap API","url":"https://mailtrap.io"}],"security":[{"HeaderAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"HeaderAuth":{"type":"apiKey","description":"Pass the API token in the Api-Token","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"responses":{"NOT_FOUND":{"description":"Returns not found error message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFoundResponse"}}}}},"schemas":{"NotFoundResponse":{"title":"NotFoundResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}}}},"paths":{"/api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id}/body.htmlsource":{"get":{"summary":"Get message source","description":"Get HTML source of email.","tags":["Messages"],"responses":{"200":{"description":"Returns HTML source of a message.","content":{"text/html":{"schema":{"type":"string"}}}},"401":{"description":"Returns unauthorized error message. Check your credentials.","content":{"text/plain":{"schema":{"type":"string"}}}},"403":{"description":"Returns forbidden error message. Check your permissions.","content":{"text/plain":{"schema":{"type":"string"}}}},"404":{"$ref":"#/components/responses/NOT_FOUND"},"409":{"description":"Returns conflict error message. HTML source does not exist.","content":{"text/plain":{"schema":{"type":"string"}}}}},"operationId":"getInboxEmailMessageBodyAsHtmlSource"}}}}
```

## Get HTML message

> Get formatted HTML email body. Not applicable for plain text emails.

```json
{"openapi":"3.1.0","info":{"title":"Email Sandbox","version":"2.0.0"},"tags":[{"name":"Messages","description":"Interactions with messages"}],"servers":[{"description":"Mailtrap API","url":"https://mailtrap.io"}],"security":[{"HeaderAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"HeaderAuth":{"type":"apiKey","description":"Pass the API token in the Api-Token","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"responses":{"UNAUTHENTICATED":{"description":"Returns unauthorized error message. Check your credentials.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthenticatedResponse"}}}},"NOT_FOUND":{"description":"Returns not found error message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFoundResponse"}}}}},"schemas":{"UnauthenticatedResponse":{"title":"UnauthenticatedResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}},"NotFoundResponse":{"title":"NotFoundResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}}}},"paths":{"/api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id}/body.html":{"get":{"summary":"Get HTML message","description":"Get formatted HTML email body. Not applicable for plain text emails.","tags":["Messages"],"responses":{"200":{"description":"Returns message body in html format.","content":{"text/html":{"schema":{"type":"string"}}}},"401":{"$ref":"#/components/responses/UNAUTHENTICATED"},"403":{"description":"Returns forbidden error message. Check your permissions.","content":{"application/json":{"schema":{"type":"object","properties":{"errors":{"type":"string"}}}}}},"404":{"$ref":"#/components/responses/NOT_FOUND"},"409":{"description":"Returns conflict error message. HTML source does not exist.","content":{"text/plain":{"schema":{"type":"string"}}}}},"operationId":"getInboxEmailMessageBodyAsHtml"}}}}
```

## Get message as .eml

> Get email message in .eml format.

```json
{"openapi":"3.1.0","info":{"title":"Email Sandbox","version":"2.0.0"},"tags":[{"name":"Messages","description":"Interactions with messages"}],"servers":[{"description":"Mailtrap API","url":"https://mailtrap.io"}],"security":[{"HeaderAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"HeaderAuth":{"type":"apiKey","description":"Pass the API token in the Api-Token","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"responses":{"NOT_FOUND":{"description":"Returns not found error message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFoundResponse"}}}}},"schemas":{"NotFoundResponse":{"title":"NotFoundResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}}}},"paths":{"/api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id}/body.eml":{"get":{"summary":"Get message as .eml","description":"Get email message in .eml format.","tags":["Messages"],"responses":{"200":{"description":"Returns .eml of the message.","content":{"message/rfc822":{"schema":{"type":"string","format":"binary"}}}},"401":{"description":"Returns unauthorized error message. Check your credentials.","content":{"text/plain":{"schema":{"type":"string"}}}},"403":{"description":"Returns forbidden error message. Check your permissions.","content":{"text/plain":{"schema":{"type":"string"}}}},"404":{"$ref":"#/components/responses/NOT_FOUND"},"409":{"description":"Returns conflict error message. .eml body does not exist.","content":{"text/plain":{"schema":{"type":"string"}}}}},"operationId":"getInboxEmailMessageBodyAsEml"}}}}
```

## Get mail headers

> Get mail headers of a message

```json
{"openapi":"3.1.0","info":{"title":"Email Sandbox","version":"2.0.0"},"tags":[{"name":"Messages","description":"Interactions with messages"}],"servers":[{"description":"Mailtrap API","url":"https://mailtrap.io"}],"security":[{"HeaderAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"HeaderAuth":{"type":"apiKey","description":"Pass the API token in the Api-Token","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"responses":{"UNAUTHENTICATED":{"description":"Returns unauthorized error message. Check your credentials.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthenticatedResponse"}}}},"PERMISSION_DENIED":{"description":"Returns forbidden error message. Check your permissions.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PermissionsDeniedResponse"}}}},"NOT_FOUND":{"description":"Returns not found error message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFoundResponse"}}}}},"schemas":{"UnauthenticatedResponse":{"title":"UnauthenticatedResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}},"PermissionsDeniedResponse":{"title":"PermissionsDeniedResponse","type":"object","properties":{"errors":{"type":"string","description":"Error message"}}},"NotFoundResponse":{"title":"NotFoundResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}}}},"paths":{"/api/accounts/{account_id}/inboxes/{inbox_id}/messages/{message_id}/mail_headers":{"get":{"summary":"Get mail headers","description":"Get mail headers of a message","tags":["Messages"],"responses":{"200":{"description":"Returns mail headers of the message","content":{"application/json":{"schema":{"type":"object","properties":{"headers":{"type":"object","description":"An object containing key/value pairs of header names and value. The key/value pairs must be strings."}}}}}},"401":{"$ref":"#/components/responses/UNAUTHENTICATED"},"403":{"$ref":"#/components/responses/PERMISSION_DENIED"},"404":{"$ref":"#/components/responses/NOT_FOUND"}},"operationId":"getMailHeadersOfEmailMessage"}}}}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mailtrap.io/developers/email-sandbox/messages.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
