Delete a message
Delete a sent message from its tracking number, for example when it went to the wrong recipient.
Prerequisites
The message's tracking number:
- in the send response:
RecipientsAnswer, one number per recipient. See Multiple recipients; - or in the logs: field
TrackingId.
Example
DeleteMessageByTrackingId returns true when the server accepts the deletion.
var args = new DeleteMessageByTrackingIdArgs
{
EndPointUri = endpoint,
Serial = serial, ApiUser = apiUser, ApiPassword = apiPassword,
TrackingId = trackingId,
CultureId = "en-CA",
};
bool deleted;
try
{
deleted = MessageHelper.DeleteMessageByTrackingId(args);
}
catch (Exception ex) // network errors: the SDK does not catch them
{
logger.LogError(ex, "Deletion failed");
deleted = false;
}
Good to know
| Point | Detail |
|---|---|
| Effect | The message is destroyed on the server and its files can no longer be downloaded: the recipient's link no longer leads to any message. Its log remains, with status Destroy (3) and an activity that carries the IP address of the call. |
| Notice | The licence holder receives an email confirming the destruction. |
| Result | A boolean only. A failure does not say why: unknown number, access refused or network error. |
| Network errors | .NET lets them through as an exception; Python and PHP return false. |
| Several recipients | Each recipient receives their own copy of the message, with its tracking number: deletion only targets the recipient of that number. To withdraw the message from everyone, delete each number. |
| Your messages only | Only messages sent with your licence can be deleted, not those of another user of your organization. |
| What is already open | Deletion can do nothing about what the recipient has already read or downloaded. |
| Traceability | Log each deletion: who asked for it, when, and the tracking number, without the message content. |
Common errors
| Symptom | Likely cause | Solution |
|---|---|---|
| Returns false | Unknown tracking number, message identifier passed instead of the tracking number, or wrong environment | Check where the number comes from and the environment. |
| Returns false with a valid number | Another user's message, message already deleted, or licence without the logs permission | Check the sender and the message's state in the logs. |
| Python: returns false with no error | Number passed as a string | Pass a uuid.UUID. |
| .NET: exception on the call | Network error | Catch it, as in the example. |
Next
- Logs: check the message's state
- Status codes