Mask the phone number and the message body in your application logs, and keep a message id that lets you look up the full record where access is controlled. A log that holds every number and every text is a privacy risk and a breach waiting to be reported, and you rarely need it for debugging.
What counts as sensitive in a text
- The phone number, which identifies a person.
- The body. Codes, links, names, addresses and order details.
- Metadata together. A number plus a time plus a short body can reveal more than each does alone.
- Health or financial details. Keep these out of texts entirely. Ready isn't HIPAA compliant and doesn't sign BAAs, so don't send diagnoses, medications or test results.
What to log instead
| Field | Log it as |
|---|---|
| Phone number | Last 2 or 4 digits, or a salted hash |
| Body | Length, segment count, template id |
| Message | The message id from the API |
| Status | queued, delivered, failed, undelivered |
| Time | Request and status timestamps |
| Account | Your tenant or sub-account id |
With the id, template and status, you can answer most support questions without the text itself. Our post on SMS API logging and alerting covers what to alert on.
One-time codes need extra care
A login code in a log is a working credential for a few minutes. Never log the body of a code message, and never put the code in a URL or error message. See SMS OTP and verification API.
How to redact in practice
- Wrap your send call. One function sends and logs. Nothing else prints the number or body.
- Redact before the logger. Mask in code, not in the log viewer.
- Scrub error payloads. A failed request often echoes the body. Strip it.
- Watch third-party tools. Your error tracker, APM and log shipper each copy the data.
- Test it. A unit test that sends a fake number and asserts the log line doesn't contain it catches regressions.
Keep the real record somewhere controlled
Customers will ask for conversation history, and support needs it. Keep full messages in the system built for it, with access limited and every view recorded. Ready's Inbox holds the message history for an account, so your own logs don't need to. Set a deletion rule too: SMS data retention and deletion walks through the choices.
The takeaway
Log ids, counts and statuses. Keep bodies and numbers out of general logs, test the redaction and decide how long anything is kept before the first incident, not after.