How do I get the message id to delete a message?

A customer submitted a question asking where to get the messageId value in order to delete a message using the DELETE /api/addresses/:email/messages/:messageId endpoint.

Deleting a Specific Message

  1. List messages in the inbox to get messageId
    curl -H 'Mailsac-Key: YOUR_API_KEY_HERE' https://mailsac.com/api/addresses/user1@mailsac.com/messages. The REST API will return a JSON object that contains the _id field. This is the messageId (in this example our messageId is BotvTxaona7gLID1Adtpfj8Fnfi7HSSv-0).
  2. Delete message using the messageId
    curl -H 'Mailsac-Key: YOUR_API_KEY_HERE' -X DELETE https://mailsac.com/api/addresses/user1@mailsac.com/messages/BotvTxaona7gLID1Adtpfj8Fnfi7HSSv-0

In addition to deleting a specific message, all messages in an inbox can be deleted.
Example:
curl -H 'Mailsac-Key: YOUR_API_KEY_HERE' -X DELETE https://mailsac.com/api/addresses/user1@mailsac.com/messages

Also of note, the SMTP header Message-ID is different from the Mailsac message _id.

Mailsac’s message _id is unique to the Mailsac service, and generated by Mailsac. This is because Mailsac can’t be certain the SMTP Message-ID header is unique across the entire service, since it is user generated.