> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes. # Redact a message PATCH https://%7BYour_Space_Name%7D.signalwire.com/api/messaging/messages/{message_id} Content-Type: application/json Redact the body of a previously sent message. This endpoint clears the message body for compliance, privacy, or moderation purposes — it does not support arbitrary updates to message attributes. The only accepted value for `body` is an empty string (`""`); any other value is rejected. Messages that are still in progress (`queued` or `initiated`) cannot be redacted. Messages in terminal states such as `delivered`, `undelivered`, or `failed` are eligible. Once redacted, the original body is overwritten and cannot be recovered. The `:message_id` path parameter is the message segment ID — the same ID returned by the create endpoint and shown in `/api/messaging/logs`. Use this SignalWire REST operation for message redaction by message segment ID. Integrations built around Message SIDs can use the Compatibility API's [Update message](/docs/compatibility-api/rest/messages/update-message) operation instead. #### Permissions The API token used to authenticate must have the following scope(s) enabled to make a successful request: _Messaging_. [Learn more about API scopes](/docs/platform/your-signalwire-api-space). Reference: https://signalwire.com/docs/apis/rest/messages/update-message ## Authentication - `Authorization` header (basic auth, required) — SignalWire Basic Authentication using Project ID and API Token. The client sends HTTP requests with the Authorization header containing the word Basic followed by a space and a base64-encoded string of project_id:token. The project ID will be used as the username and the API token as the password. Example: ``` Authorization: Basic base64(project_id:token) ``` ## Request ### Path parameters - `message_id` (string, required) — The message segment ID — the same ID returned by the create endpoint and shown in `/api/messaging/logs`. ### Body (application/json) This endpoint expects a Message.UpdateMessageRequest. - `body` (string, required) — Must be an empty string (`""`) to redact the message. Any non-empty value is rejected with `body_must_be_empty`. This is the only field that can be updated. ## Response ### 200 Response returned when a message has been successfully redacted. - `id` (string, required) — The unique ID of the message. This is the `MessageSegment` ID, consistent with the dashboard and the `/api/messaging/logs` endpoint. - `from` (string, required) — The source phone number. - `to` (string, required) — The destination phone number. - `body` (string, required) — The message body text. Returns an empty string when the message has been redacted. - `status` (enum, required) — Delivery state of the message. - Allowed values: `queued`, `initiated`, `sent`, `delivered`, `undelivered`, `failed`, `read` - `direction` (enum, required) — The direction of the message. - Allowed values: `inbound`, `outbound` - `kind` (enum, required) — The kind of message. - Allowed values: `sms`, `mms`, `whatsapp` - `media` (list of string, required) — Array of URLs for any media attachments on the message. Empty for SMS. - `number_of_segments` (integer, required) — Number of segments the message body was split into for delivery. - `error_code` (string, required, nullable) — Provider-specific error code if delivery failed. Null when no error occurred. - `error_message` (string, required, nullable) — Human-readable error message if delivery failed. Null when no error occurred. - `created_at` (datetime, required) — Date and time when the message was created. - `project_id` (string, required) — The ID of the project the message belongs to. - `status_callback_url` (string, required, nullable) — Callback URL configured to receive message status events. Null if no callback was configured. - `message_uri` (string, required) — Relative URL for retrieving the message via the `/api/messaging/logs` endpoint. ## Errors ### 400 Bad Request Error The request is invalid. - `error` (enum, required) - Allowed values: `Bad Request` ### 401 Unauthorized Error Access is unauthorized. - `error` (enum, required) - Allowed values: `Unauthorized` ### 404 Not Found Error The server cannot find the requested resource. - `error` (enum, required) - Allowed values: `Not Found` ### 422 Unprocessable Entity Error The request contains invalid parameters. See errors for details. - `errors` (list of Types.StatusCodes.RestApiErrorItem, required) — List of validation errors. ### 500 Internal Server Error An internal server error occurred. - `error` (enum, required) - Allowed values: `Internal Server Error` ## Types ### Types.StatusCodes.RestApiErrorItem Details about a specific error. - `type` (string, required) — The category of error. - `code` (string, required) — A specific error code. - `message` (string, required) — A description of what caused the error. - `url` (string, required) — A link to documentation about this error. - `attribute` (string, optional, nullable) — The request parameter that caused the error, if applicable. ## Examples **Request** ```json { "body": "" } ``` **Response** ```json { "id": "c2d3e4f5-a6b7-8901-cdef-234567890abc", "from": "+15559876543", "to": "+15551234567", "body": "Your order #12345 has shipped!", "status": "queued", "direction": "outbound", "kind": "sms", "media": [], "number_of_segments": 1, "error_code": null, "error_message": null, "created_at": "2024-05-06T12:20:00Z", "project_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "status_callback_url": null, "message_uri": "/api/messaging/logs/c2d3e4f5-a6b7-8901-cdef-234567890abc" } ``` **SDK Code** ```python import requests url = "https://{your_space_name}.signalwire.com/api/messaging/messages/message_id" payload = { "body": "" } headers = { "Content-Type": "application/json" } response = requests.patch(url, json=payload, headers=headers, auth=("", "")) print(response.json()) ``` ```javascript const url = 'https://{your_space_name}.signalwire.com/api/messaging/messages/message_id'; const credentials = btoa(":"); const options = { method: 'PATCH', headers: { Authorization: `Basic ${credentials}`, 'Content-Type': 'application/json' }, body: '{"body":""}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://{your_space_name}.signalwire.com/api/messaging/messages/message_id" payload := strings.NewReader("{\n \"body\": \"\"\n}") req, _ := http.NewRequest("PATCH", url, payload) req.SetBasicAuth("", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://{your_space_name}.signalwire.com/api/messaging/messages/message_id") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Patch.new(url) request.basic_auth("", "") request["Content-Type"] = 'application/json' request.body = "{\n \"body\": \"\"\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.patch("https://{your_space_name}.signalwire.com/api/messaging/messages/message_id") .basicAuth("", "") .header("Content-Type", "application/json") .body("{\n \"body\": \"\"\n}") .asString(); ``` ```php request('PATCH', 'https://{your_space_name}.signalwire.com/api/messaging/messages/message_id', [ 'body' => '{ "body": "" }', 'headers' => [ 'Content-Type' => 'application/json', ], 'auth' => ['', ''], ]); echo $response->getBody(); ``` ```csharp using RestSharp; using RestSharp.Authenticators; var client = new RestClient("https://{your_space_name}.signalwire.com/api/messaging/messages/message_id"); client.Authenticator = new HttpBasicAuthenticator("", ""); var request = new RestRequest(Method.PATCH); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"body\": \"\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let credentials = Data(":".utf8).base64EncodedString() let headers = [ "Authorization": "Basic \(credentials)", "Content-Type": "application/json" ] let parameters = ["body": ""] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://{your_space_name}.signalwire.com/api/messaging/messages/message_id")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "PATCH" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```