Maildrop
Search…
⌃K
Links
🗑

Delete a Message

This is the GraphQL mutation to run when you want to delete a message from a mailbox.

Do I need to delete messages from Maildrop?

In most cases, you shouldn't need to delete any messages. Mailboxes are temporary, and if no email messages are sent to a mailbox within 24 hours, the mailbox is completely erased automatically. Additionally, when there are a large amount of incoming messages, mailboxes that haven't seen messages recently may get emptied before the 24 hour window.
If you are sending a large number of automated messages (for example, testing sending out batches of messages to a large database of mock email addresses) then as a courtesy, you should delete those messages as part of your testing script cleanup phase.
​
post
https://api.maildrop.cc/graphql
Deletes an individual message, by id, from a mailbox.
This GraphQL mutation takes a mailbox name and a message id as required parameters. This only returns a boolean of whether the message was deleted or not. Incorrect mailbox/id combinations will still return true.
Parameters
Header
Content-Type
String
application/json
Body
String
'{"query":"mutation Example { delete(mailbox:\"testing\", id:\"abc123\") }"}'
Responses
200: OK
​

Examples

curl
React
curl --request POST \
--header 'content-type: application/json' \
--url https://api.maildrop.cc/graphql \
--data '{"query":"mutation Example { delete(mailbox:\"testing\", id:\"abc123\") }"}'
returns:
{"data":{"delete":true}}
export const DELETE_MESSAGE = gql`
mutation DeleteMessage($mailbox: String!, $id: String!) {
delete(mailbox: $mailbox, id: $id)
}
}`;
​
interface MutationReturn {
delete: boolean;
}
​
interface MutationVariables {
mailbox: string;
id: string;
}
​
interface MyComponentProps {
mailbox: string;
id: string;
}
​
const MyComponent = (props: MyComponentProps) => {
const [deleteMessage, { data, loading, error }] = useMutation<MutationReturn, MutationVariables>(DELETE_MESSAGE, {
variables: { mailbox: props.mailbox, id: props.id }
});
return (
<div>
{loading && <div>Deleting...</div>}
{!loading && <button onClick={deleteMessage}>Delete Message</button>}
{!loading && error && <div>There was an error.</div>}
{!loading && data?.delete && <div>Message deleted.</div>}
</div>
);
};
​
​