Skip to main content
Traces can contain personal information, credentials, and other sensitive data. Braintrust supports three approaches to protecting that data in your logs, which you can use separately or together:
  • Redact during ingestion: Braintrust receives your logs and sends unredacted text from selected fields to a detection model hosted on Baseten. Braintrust replaces detected sensitive text before storing the logs.
  • Hide fields when read: Braintrust stores your logs and datasets unchanged and hides selected fields from some or all members when they view or query them.
  • Redact before upload: An SDK masking function, span customizers, or bt span plugins remove sensitive values within your application or on your machine. Values they remove are not sent to Braintrust.
Redaction removes sensitive values from stored logs. Hiding controls who can see values that Braintrust stores. If a value must never leave your application, remove it before upload.

Redact during ingestion

Ingestion redaction detects sensitive text, such as names, email addresses, and credentials, in incoming project logs and replaces it before storage. You define protected fields: named rules that each choose which log fields to scan and which types of sensitive information to redact. Create them for one project or your entire organization without changing your application code.
Ingestion redaction is in private preview, available to a limited set of customers. Behavior can change during the preview. To request access, contact Braintrust.
Thread messages with names, addresses, phone numbers, and emails replaced by redaction markers, outlined in purple.

How redaction works

Redaction runs on incoming project logs before storage:
  1. Select text: Braintrust applies the protected fields from your project and organization to identify which fields and entity types to scan. Each rule redacts only its own entity types in its own fields. Selected fields include strings nested in objects and arrays.
  2. Detect sensitive information: Braintrust sends unredacted text from the selected fields, with the name of the key that holds each value, to a Braintrust-managed detection model hosted on Baseten, a subprocessor. The model identifies text matching the rule’s entity types.
  3. Replace and store: Braintrust replaces the text identified by the model with category markers such as [REDACTED_EMAIL], then stores the records. Text outside the detected spans and the object and array structure are preserved.
Only string values in incoming project logs are scanned. Object keys are never redacted. Existing records, direct writes to datasets or experiments, and image, audio, or file attachment contents are excluded.
For organizations on the EU data plane, unredacted text selected for detection and its key names are sent to a Baseten-hosted model endpoint outside the EU. Using the EU data plane does not keep ingestion redaction processing within the EU.
Redaction is permanent and not guaranteed. You can’t recover replaced text, even after you delete the rule. Detection can miss values, and if redaction fails, Braintrust stores the records without redaction. To keep specific values from ever reaching Braintrust, redact them before upload.

Create protected fields

Only members of the Owners permission group can view or configure protected fields. Other members see a message that only organization owners can manage protected fields. Braintrust recommends creating protected fields at the project level during private preview.
1

Choose the scope

Go to Settings > Data protection, then select a tab:
  • Project: Redact logs in the selected project. The tab also lists rules inherited from your organization, labeled Inherited from organization, which you can’t edit or delete here.
  • Organization: Redact logs in every existing and new project.
2

Define the rule

Click Protected field, then:
  1. Enter a Name for the rule.
  2. Set Stage to Ingest. The Action is Redact. If Applies to appears, keep it at Project logs.
  3. Under Entity types to redact, select at least one category, such as Names or Emails. Selecting a category redacts all of its types. To choose specific types, click the category again.
  4. Under Fields to redact, click Field, then select a top-level field or enter a nested path such as input.messages[0].content. On the Project tab, the list also suggests nested paths from the project’s logs, such as metadata.user.email. Paths must start with input, output, expected, error, metadata, comments, or context. Fields don’t need to exist in your logs yet.
  5. Optionally, under Fields to pass through, click Field and add paths that this rule never redacts, such as input.messages[0].role. The rule skips each pass-through field and everything nested under it, so passing through a parent field also skips any redacted fields below it. Paths match exactly, so input.messages[0].role covers only the first message. Other rules, including rules inherited from your organization, still redact the field if they include it.
  6. Optionally, under Values to never redact, add text this rule keeps, such as your company name. Type a value, then press Enter or click Value. To remove a value, click it. If detected text contains a listed value, the rule redacts only the rest. For example, with Ada listed, Ada Lovelace becomes Ada [REDACTED_PERSON]. Matching ignores case and can match part of a word. Other rules can still redact the value.
  7. Optionally, expand Preview rule to see example text redacted with the selected entity types.
  8. Click Create.
The rule applies to logs ingested after you create it.
3

Verify the results

Send representative test logs, then go to Logs and inspect the covered fields.In LLM message views, rendered Markdown text, and the data editor, category markers appear as labeled pills. For example, [REDACTED_EMAIL] displays as Redacted email address. Exports, API queries, and scorers receive the category marker text.Check for missed values and incorrect redactions before relying on the results. For values you can match reliably, such as known credential formats, also redact before upload.

Change protected fields

After you create a protected field, you can edit its name, entity types, fields to redact, fields to pass through, and values to never redact. You can also disable or delete it. Changes apply to logs ingested after you save, and text that was already redacted stays redacted. Removing fields or entity types, adding pass-through fields or values to never redact, or disabling or deleting a rule stops redacting that text in new logs. The rule table on the Data protection page shows whether each rule is Enabled or Disabled.
  • Edit: Click a rule or its edit icon, change its settings, and click Save. You can’t change a rule’s Stage after you create it.
  • Disable: Open the rule, turn off the Enabled switch, and click Save. The rule stops applying but keeps its configuration. Turn the switch back on to apply it again. Disabled organization rules don’t appear on the Project tab.
  • Delete: Click the rule’s delete icon, or open the rule and click Delete, then confirm with Delete.

Failure behavior

Ingestion redaction fails open:
  • If redaction fails for a log record, Braintrust stores that record without ingestion redaction. Successfully redacted records in the same batch retain their redactions.
  • If policy lookup or evaluation fails, Braintrust can store the entire batch without ingestion redaction.
  • Ingestion redaction has a time budget of 45 seconds per batch by default, including policy lookup and redaction. If that budget expires, Braintrust stores unfinished records without ingestion redaction.

Hide fields when read

Read rules hide selected fields in project logs or datasets from some or all members, without changing stored data. Read rules don’t apply to experiments.
Read rules are in private preview, available to a limited set of customers. Behavior can change during the preview. To request access, contact Braintrust.
Purple outlines highlight Hidden field indicators in the Expected column and the Some fields hidden notice under Metadata.

How read rules work

Read rules apply each time a member views or queries logs or datasets:
  1. Store unchanged: Braintrust stores logs and datasets with their full values.
  2. Match the reader: Braintrust checks the project and organization read rules, and each rule’s Hide from setting, to decide which fields to hide from the member. Changes to permission group membership can take about a minute to take effect.
  3. Remove hidden fields: Braintrust omits each hidden field, and everything nested under it, from the data the member reads. Trace, log, and dataset views mark where fields are hidden:
    • A hidden field shows Hidden field in place of its value.
    • An object with some hidden fields inside it shows Some fields hidden above the remaining content.
    • A span’s raw data lists the hidden paths, labeled Hidden by protected-field rules.
    In query results, a hidden field looks the same as a field that was never logged. Queries that could reveal hidden values are rejected. See Query limitations.
A read rule controls what members see. It doesn’t remove data from storage, so it isn’t a substitute for redaction. To keep a value out of stored logs, redact it during ingestion or before upload.

Create read rules

Only members of the Owners permission group can view or configure read rules. Members who can’t configure read rules are still subject to them.
1

Choose the scope

Go to Settings > Data protection, then select a tab:
  • Project: Hide fields in the selected project’s logs or datasets. The tab also lists rules inherited from your organization, labeled Inherited from organization, which you can’t edit or delete here.
  • Organization: Hide fields in every existing and new project.
2

Define the rule

Click Protected field, then:
  1. Enter a Name for the rule.
  2. Set Applies to to Project logs or Dataset. A Dataset rule covers every dataset in its scope.
  3. Set Stage to Read. The Action changes to Hide. Dataset rules use Read automatically.
  4. Under Fields to hide, click Field, then select a top-level field or enter a nested path such as metadata.user. On the Project tab, the list also suggests nested paths from the project’s logs or datasets, such as metadata.user.email. Paths must start with input, output, expected, error, metadata, comments, or context. Fields don’t need to exist in your data yet.
  5. Under Hide from, select an option:
    • Everyone except specific members or groups: Hides the fields from every member, including members who join later, except the members and permission groups you select. To hide the fields from everyone, leave the selection at No one. The fields are also hidden from you unless you select yourself or one of your groups.
    • Specific members and groups: Hides the fields only from the members and groups you select. Choose at least one member or group.
  6. Click Create.

Change read rules

After you create a read rule, you can edit its name, fields to hide, and Hide from selection. You can also disable or delete it. Changes apply to new views and queries as soon as you save. Braintrust stores the data unchanged, so disabling or deleting a rule loses nothing. The rule table on the Data protection page shows whether each rule is Enabled or Disabled, and what it Applies to.
  • Edit: Click a rule or its edit icon, change its settings, and click Save. You can’t change a rule’s Applies to or Stage after you create it. If the rule uses a condition that the Hide from options can’t represent, the dialog shows the condition as read-only and keeps it unchanged when you save.
  • Disable: Open the rule, turn off the Enabled switch, and click Save. The fields become visible again, and the rule keeps its configuration. Turn the switch back on to hide them again. Disabled organization rules don’t appear on the Project tab.
  • Delete: Click the rule’s delete icon, or open the rule and click Delete, then confirm with Delete. The fields become visible again.

Query limitations

If a query reads logs from several projects, a field hidden from you in one of those projects is hidden in every row the query returns. A query’s outermost select can return a hidden field, a field nested inside it, or a field that contains it, under its own name or a new one, such as metadata, metadata.model, or metadata AS m. Braintrust removes the hidden parts from the returned column, or omits the column if the selected value is itself hidden. Custom columns on the Logs page follow the same rules, so a custom column that reads a hidden field doesn’t block the page. How the column appears depends on what it does:
  • Returns a hidden field, or a field nested inside or containing one, such as input.input.command or metadata: Shows only the parts that aren’t hidden, or no value if the returned value is itself hidden.
  • Computes on a hidden field, such as len(input.input.command) or lower(input): Shows no value.
  • Has the same name as a built-in field, such as project_id: Takes the place of that field and follows the rules above.
  • Is named input: Causes the query to be rejected. A custom column named input that doesn’t read a hidden field works as usual.
Some queries are rejected because they could reveal hidden values:
  • Queries that filter, sort, group, aggregate, or compute on a hidden field, or on a field nested inside or containing it, including through a renamed column, such as ORDER BY m, or a custom column.
  • Queries that rename one of these fields in a subquery. An outer query can rename a field that the subquery returns whole.
  • Some selects of nested paths through arrays.
  • Audit log queries.
  • Async queries.
You also can’t restore a dataset snapshot while any of its fields are hidden from you. Full-text search skips any top-level field that contains a hidden field. For example, if metadata.user is hidden from you, search skips all of metadata. Facets and classifications, which Topics builds on, are also hidden from you.

Redact before upload

To remove sensitive values before they reach Braintrust, change data before it leaves your application or machine. Braintrust SDKs provide masking functions and span customizers for data logged by your application, and the bt CLI provides span plugins for coding-agent traces:
  • Masking functions: Functions that replace sensitive parts of field values, one value at a time, in a fixed set of fields: input, output, expected, metadata, context, scores, and metrics. The SDK runs your function on every record it logs. If it fails, the SDK uploads an error message in place of the affected field instead of the unmasked value.
  • Span customizers: Code that changes, adds, or removes fields on a span, including tags and error. The SDK runs your customizers before it uploads each span. Which spans they cover, and what happens when one fails, depends on the SDK.
  • Span plugins: JavaScript modules that change coding-agent traces, which don’t pass through an SDK. The bt CLI runs your plugins on your machine before it uploads the traces. See Transform spans with JavaScript.
Support for masking functions and span customizers varies by SDK. See the Redact sensitive data page for TypeScript, Python, Go, Java, or Ruby.
The C# SDK doesn’t support masking functions or span customizers. To remove sensitive data from its traces, use ingestion redaction, or remove it before you log it.

Next steps