You can delete individual records of messages or media associated with messages by using the HTTP DELETE functionality of the API.
- To delete individual message records through the API, make an HTTP DELETE request to the message resource.
- To delete individual media files associated with MMS messages through the API,make an HTTP DELETE request to the message media resource.
Please note, deleting the record of a message does not automatically delete the media associated with the message (if applicable). If you need to delete a message and its associated media you’ll need to delete both the message and media records separately.
If you want to delete the message body but preserve the message record, you make an HTTP POST request to the message resource. This will update the message body to be "" while the other message resource properties will remain intact.
An even better option would be to get Message Body Redaction enabled for your account, which allows you to redact the message bodies before they’re stored in long-term storage. Request access and pricing information by filling out this form.