Delete Matching Messages
Delete all captured messages matching the supplied filters.
Delete all captured messages matching the supplied filters.
Each request deletes up to 50 matching messages. When more remain, the response has more: true; repeat the same request until more is false. Stop if deleted is 0. With no filters, the request deletes every captured message in the account.
Scope: email_testing.messages.delete
Query Parameters
mailbox_idstringoptionalOnly include messages captured by this test inbox.
credential_idstringoptionalOnly include messages sent through this SMTP sink credential.
recipientstringoptionalOnly match messages sent to exactly this recipient address.
senderstringoptionalOnly match messages from exactly this sender address.
recipient_containsstringoptionalOnly match messages whose recipient address contains this text.
sender_containsstringoptionalOnly match messages whose sender address contains this text, for example @example.com.
subject_containsstringoptionalOnly match messages whose subject contains this text.
Sample Request
curl -X DELETE "https://api.maileroo.com/v1/email-testing/messages?mailbox_id=35a3cb89-ea59-4ea3-8edc-a5c5f7bf0bda" \
-H "Authorization: Bearer roo_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"Repeat Until Complete
Repeat the same filtered request while more is true. This Node.js example also stops if a response deletes zero messages:
const url =
"https://api.maileroo.com/v1/email-testing/messages?mailbox_id=35a3cb89-ea59-4ea3-8edc-a5c5f7bf0bda";
let deletedTotal = 0;
while (true) {
const response = await fetch(url, {
method: "DELETE",
headers: { Authorization: `Bearer ${process.env.MAILEROO_API_KEY}` },
});
if (!response.ok) throw new Error(`Delete failed: ${response.status}`);
const { data } = await response.json();
deletedTotal += data.deleted;
if (data.deleted === 0 || !data.more) break;
}
console.log(`Deleted ${deletedTotal} messages`);Sample Response
The response is wrapped in a data object.
{
"data": {
"deleted": 50,
"more": true
}
}