> ## Documentation Index
> Fetch the complete documentation index at: https://developers.telnyx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Message Redaction

> Redact message content and phone numbers from message records and reporting for privacy and compliance.

Message redaction removes sensitive content from Message Detail Records (MDRs), message webhooks, and Telnyx reporting surfaces. Delivery metadata — status, timestamps, error codes, cost — remains available, though content-level investigation is restricted while redaction is on.

Message redaction is enabled per messaging profile and requires activation on the organization. Contact [support](https://support.telnyx.com/) or the account team to have the organization added to the redaction allowlist before configuring profiles.

## What redaction changes

When redaction is enabled on a profile, the following fields are redacted when retrieving messages via [GET /v2/messages/{id}](/api-reference/messages/retrieve-a-message) and in Telnyx reporting exports:

| Field                      | Behavior                                                                                                                        |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `text` and `original_text` | Replaced with an empty string                                                                                                   |
| MMS `subject`              | Replaced with an empty string                                                                                                   |
| MMS `media`                | Replaced with an empty list                                                                                                     |
| Counterparty phone number  | Final four digits replaced with `****` — the destination (`to`) for outbound messages, the source (`from`) for inbound messages |

Everything else is preserved, including the message ID, direction, status, delivery status, timestamps, error codes, carrier, line type, encoding, parts, cost, and TCR campaign information. Content hashes (`text_hash`, `bytes_hash`) are preserved in legacy v1 MDR responses.

<Note>
  Redaction applies at read time. The counterparty number is always masked on the side of the message that is external to Telnyx — the `to` number on outbound messages, the `from` number on inbound messages. The customer's own Telnyx number on the other side of the record is never masked.
</Note>

## Redaction levels

The `redaction_level` setting controls whether inbound webhook payloads are also redacted:

| Level         | MDRs (API + reporting) | Inbound message webhooks                                                |
| ------------- | ---------------------- | ----------------------------------------------------------------------- |
| `1`           | Redacted               | Not redacted — full text and source number delivered to the webhook URL |
| `2` (default) | Redacted               | Redacted — text, media, and the source number masked                    |

Delivery status webhooks (`message.finalized` events) are redacted whenever redaction is enabled, at any level: `text`, `media`, and `subject` are blanked and the destination phone number is masked. Delivery status fields themselves — status, timestamps, error codes — are unaffected.

<Note>
  MDR redaction applies identically at levels `1` and `2`. Any level other than `2` disables webhook redaction but leaves MDRs redacted. Level `2` is the default and recommended setting.
</Note>

## Enable redaction

Once the organization is on the redaction allowlist, set the fields on a messaging profile:

<CodeGroup>
  ```bash curl theme={null}
  curl -X PATCH "https://api.telnyx.com/v2/messaging_profiles/{profile_id}" \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer ***" \
    -d '{
      "redaction_enabled": true,
      "redaction_level": 2
    }'
  ```

  ```python Python theme={null}
  import os
  from telnyx import Telnyx

  client = Telnyx(api_key=os.environ.get("TELNYX_API_KEY"))

  response = client.messaging_profiles.update(
      "your_messaging_profile_id",
      redaction_enabled=True,
      redaction_level=2,
  )

  print(f"Redaction enabled: {response.data.redaction_enabled} (level {response.data.redaction_level})")
  ```

  ```javascript Node theme={null}
  import Telnyx from 'telnyx';

  const client = new Telnyx({ apiKey: process.env.TELNYX_API_KEY });

  const response = await client.messagingProfiles.update(
    'your_messaging_profile_id',
    {
      redaction_enabled: true,
      redaction_level: 2,
    }
  );

  console.log(`Redaction enabled: ${response.data.redaction_enabled} (level ${response.data.redaction_level})`);
  ```

  ```ruby Ruby theme={null}
  require "telnyx"

  client = Telnyx::Client.new(api_key: ENV["TELNYX_API_KEY"])

  response = client.messaging_profiles.update(
    "your_messaging_profile_id",
    redaction_enabled: true,
    redaction_level: 2
  )

  puts "Redaction enabled: #{response.data.redaction_enabled} (level #{response.data.redaction_level})"
  ```

  ```go Go theme={null}
  package main

  import (
    "context"
    "fmt"
    "os"

    "github.com/team-telnyx/telnyx-go/v4"
    "github.com/team-telnyx/telnyx-go/v4/option"
  )

  func main() {
    client := telnyx.NewClient(
      option.WithAPIKey(os.Getenv("TELNYX_API_KEY")),
    )
    response, err := client.MessagingProfiles.Update(
      context.TODO(),
      "your_messaging_profile_id",
      telnyx.MessagingProfileUpdateParams{
        RedactionEnabled: telnyx.Bool(true),
        RedactionLevel:    telnyx.Int64(2),
      },
    )
    if err != nil {
      panic(err.Error())
    }
    fmt.Printf("Redaction enabled: %v (level %d)\n", response.Data.RedactionEnabled, response.Data.RedactionLevel)
  }
  ```

  ```java Java theme={null}
  package com.telnyx.example;

  import com.telnyx.sdk.client.TelnyxClient;
  import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
  import com.telnyx.sdk.models.messagingprofiles.MessagingProfileUpdateParams;

  public final class Main {
      public static void main(String[] args) {
          TelnyxClient client = TelnyxOkHttpClient.fromEnv();

          var params = MessagingProfileUpdateParams.builder()
              .redactionEnabled(true)
              .redactionLevel(2)
              .build();

          var response = client.messagingProfiles()
              .update("your_messaging_profile_id", params);

          System.out.println("Redaction enabled: " + response.data().redactionEnabled()
              + " (level " + response.data().redactionLevel() + ")");
      }
  }
  ```

  ```csharp .NET theme={null}
  using Telnyx;

  TelnyxConfiguration.SetApiKey(Environment.GetEnvironmentVariable("TELNYX_API_KEY"));

  var service = new MessagingProfileService();
  var response = await service.UpdateAsync(
      "your_messaging_profile_id",
      new MessagingProfileUpdateOptions
      {
          RedactionEnabled = true,
          RedactionLevel = 2
      }
  );

  Console.WriteLine($"Redaction enabled: {response.Data.RedactionEnabled} (level {response.Data.RedactionLevel})");
  ```

  ```php PHP theme={null}
  <?php
  require_once 'vendor/autoload.php';

  use Telnyx\Client;

  $client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'YOUR_API_KEY');

  $response = $client->messagingProfiles->update(
      messagingProfileID: 'your_messaging_profile_id',
      redactionEnabled: true,
      redactionLevel: 2,
  );

  echo "Redaction enabled: {$response->data->redaction_enabled} (level {$response->data->redaction_level})";
  ```
</CodeGroup>

<Check>Redaction is off (`redaction_enabled: false`) until explicitly enabled on the profile. Existing MDRs created before enabling redaction were stored unredacted and may still show full content when fetched.</Check>

<Note>
  Redaction controls what the Messages API and reporting surfaces return. It is applied when records are read, based on the redaction state captured when each message was sent — it is not a storage-level deletion of message content.
</Note>

## Disable redaction

Set `redaction_enabled` to `false` on the profile. Messages sent after the change produce unredacted MDRs. MDRs created while redaction was active remain redacted — redaction state is fixed at message creation time.

<Check>The `redaction_enabled` and `redaction_level` fields appear in API responses only for organizations on the redaction allowlist. For organizations not on the allowlist, the fields are absent from profile responses and values set via PATCH are ignored.</Check>

## Troubleshooting

<AccordionGroup>
  <Accordion title="PATCHing `redaction_enabled` has no effect">
    The organization is not on the redaction allowlist. The fields are silently dropped from update requests for non-allowlisted organizations (they do not error). Contact support to request activation, then retry the PATCH.
  </Accordion>

  <Accordion title="MDRs still show full text after enabling redaction">
    Redaction applies to messages sent after the profile change. MDRs created before redaction was enabled were stored with content and remain readable. Also verify the profile the message was sent on — redaction is per-profile, so traffic on other profiles is unaffected.
  </Accordion>

  <Accordion title="Inbound webhook still contains content at level 2">
    Confirm the webhook is an inbound **message** webhook (`message.received` event) and not another event type. Also confirm the message was sent to a number on a profile with `redaction_level: 2` — level `1` leaves inbound message webhooks unredacted by design.
  </Accordion>

  <Accordion title="Delivery status webhook shows content even though redaction is on">
    Delivery status events (`message.finalized`) do carry `text`, `media`, and `subject` fields, but when redaction is enabled those fields are blanked and the destination number is masked, at any level. If content is visible, the record predates redaction or the profile has redaction disabled.
  </Accordion>
</AccordionGroup>

## Next steps

<CardGroup cols={2}>
  <Card title="Message Detail Records" icon="file-lines" href="/docs/messaging/messages/message-detail-records">
    Understand MDR fields and status flows used alongside redaction.
  </Card>

  <Card title="Configurable Spend Limits" icon="receipt" href="/docs/messaging/messages/configurable-spend-limits">
    Cap daily spend per messaging profile.
  </Card>
</CardGroup>
