Messages
Work with the emails and SMS messages that you send to Mailosaur for testing.
The Message object
Message objects represent an email or SMS received by Mailosaur and contain all the data you might need to perform any number of manual or automated tests.
{
"id": "77061c9f-da47-4009-9f33-9715a3bbf00c",
"received": "2019-08-06T17:44:07.197781+00:00",
"subject": "Email subject line",
"from": [{
"name": "Acme",
"email": "noreply@example.com"
}],
"to": [{
"name": "Jane Doe",
"email": "janedoe@abc1234.mailosaur.net"
}],
"cc": [],
"bcc": [],
"html": {
"links": [{
"href": "https://example.com/signup",
"text": "Sign Up Now"
}],
"images": [],
"body": "Lorem ipsum..."
},
"text": {
"links": [{
"href": "https://example.com/signup",
"text": "https://example.com/signup"
}],
"body": "Lorem ipsum..."
},
"attachments": [],
"metadata": {
"headers": [{
"field": "MIME-Version",
"value": "1.0"
}]
},
"server": "abcd1234"
}
Message summaries
When performing list or search queries, a truncated summary of each message is returned instead of the full object:
{
"id": "77061c9f-da47-4009-9f33-9715a3bbf00c",
"received": "2019-08-06T17:44:07.197781+00:00",
"subject": "Email subject line",
"from": [{
"name": "Acme",
"email": "noreply@example.com"
}],
"to": [{
"name": "Jane Doe",
"email": "janedoe@abc1234.mailosaur.net"
}],
"cc": [],
"bcc": []
}
Attributes
id
string Unique identifier for the message.received
datetime The date and time the message was received by Mailosaur, in ISO 8601 format.subject
string The subject line of the message.from
array The sender of the message. Note: This will usually only have one item, but technically it is possible to have multiple senders (yes, we were surprised too!)Show child attributes
name
string The message sender's name.email
string The message sender's email address (alwaysnull
for SMS messages).phone
string The message sender's telephone number (alwaysnull
for email messages).
to
,cc
andbcc
array The recipients of the message. Note:cc
andbcc
will always benull
for SMS messages.Show child attributes
name
string The message recipient's name.email
string The message sender's email address (alwaysnull
for SMS messages).phone
string The message sender's telephone number (alwaysnull
for email messages).
html
object The HTML content of the message (alwaysnull
for SMS messages).Show child attributes
body
string HTML content.image
array Images found within the HTML content, each returned as an object with propertiesalt
(the alternative text for the image) andsrc
.links
array Hyperlinks, each returned as an object with propertiestext
(the display text of the link) andhref
.
text
object The text content of the message.Show child attributes
body
string Text content.links
array Hyperlinks, each returned as an object with propertiestext
(the display text of the link) andhref
.
attachments
array The attachments associated with the message.Show child attributes
id
string Unique identifier for the message.contentType
string The MIME type of the attachment.fileName
string The file name of the attachment.contentId
string The content identifier (for attachments that are embedded within the body of the message).length
string The file size, in bytes.url
string The URL from which the attachment can be downloaded.
metadata
object Additional information associated with the message.Show child attributes
headers
array Message headers, each returned as an object with propertiesfield
andvalue
.
server
string Unique identifier of the server containing the message.
Retrieve a message
Retrieves the detail for a single email message. Simply supply the unique identifier for the required message.
get https://mailosaur.com/api/messages/:id
Parameters
Name | Type | In | Description |
---|---|---|---|
id | string | path | The identifier of the email message to be retrieved. This can be found via other API calls such as Search for messages. |
To get the ID of a message you need to call one of our other API calls which returns a list of messages. Each message in the list will contain an ID which you can use to make this call.
Response
Status: 200 OK
// Message object
Delete a message
Permanently deletes a message. This operation cannot be undone. Also deletes any attachments related to the message.
delete https://mailosaur.com/api/messages/:id
Parameters
Name | Type | In | Description |
---|---|---|---|
id | string | path | The identifier of the message to be deleted. |
Response
Status: 204 No Content
List all messages
Returns a list of your messages in summary form. The summaries are returned sorted by received date, with the most recently-received messages appearing first.
get https://mailosaur.com/api/messages?server=:server
Parameters
Name | Type | In | Description |
---|---|---|---|
server | string | query | The identifier of the server hosting the messages. |
page | int | query | Used in conjunction with itemsPerPage to support pagination. |
itemsPerPage | int | query | A limit on the number of results to be returned per page. Can be set between 1 and 1000 items, the default is 50. |
receivedAfter | datetime | query | Limits results to only messages received after this date/time. |
Response
Status: 200 OK
// Array of Message object
Delete all messages
Permanently deletes all messages held by the specified server. This operation cannot be undone. Also deletes any attachments related to each message.
delete https://mailosaur.com/api/messages?server=:server
Parameters
Name | Type | In | Description |
---|---|---|---|
server | string | query | The identifier of the server to be emptied. |
Response
Status: 204 No Content
Search for messages
Returns a list of message summaries matching the specified search criteria, in summary form. The summaries are returned sorted by received date, with the most recently-received messages appearing first.
post https://mailosaur.com/api/messages/search?server=:server
Parameters
Name | Type | In | Description |
---|---|---|---|
server | string | query | The identifier of the server hosting the messages. |
page | int | query | Used in conjunction with itemsPerPage to support pagination. |
itemsPerPage | int | query | A limit on the number of results to be returned per page. Can be set between 1 and 1000 items, the default is 50. |
receivedAfter | datetime | query | Limits results to only messages received after this date/time. |
Request
Message Summaries To get the full message content, including HTML & Text body content, you need to use the Retrieve a message endpoint. Alternatively you can search and retrieve in a single call by using our official client libraries.
{
"sentFrom": "noreply@example.com",
"sentTo": "someone@abcd1234.mailosaur.net",
"subject": "Email address",
"body": "Hey Alice,",
"match": "ALL"
}
Name | Type | Description |
---|---|---|
sentFrom | string | The full email address from which the target email was sent. |
sentTo | string | The full email address to which the target email was sent. |
subject | string | The value to seek within the target email’s subject line. |
body | string | The value to seek within the target email’s HTML or text body. |
match | string | If set to ALL (default), then only results that match all specified criteria will be returned. If set to ANY , results that match any of the specified criteria will be returned. |
Response
Status: 200 OK
{
"items": [
// Message summary object
]
}