> For the complete documentation index, see [llms.txt](https://docs.tonic.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tonic.ai/textual/tonic-textual-api/textual-python-sdk/datasets-redaction/api-redaction-entity-type-handling.md).

# Configure entity type handling for redaction

{% hint style="info" %}
**Required dataset permission:** Edit dataset settings
{% endhint %}

By default, when you:

* Configure a dataset
* Redact a string
* Retrieve a redacted file

Textual does the following:

* For the string and file redaction, replaces detected values with tokens.
* For LLM synthesis, generates realistic synthesized values.

When you make the request, you can:

* Override the default behavior.
* For individual files and text strings, specify custom entity types to include.

## Specifying the handling option for entity types

For each entity type, you can choose to redact, synthesize, or ignore the value.

* When you redact a value, Textual replaces the value with a token that consists of the entity type. For example, `ORGANIZATION`.
* When you synthesize a value, Textual replaces the value with a different realistic value.
* When you ignore a value, Textual passes through the original value.

To specify the handling option for entity types, you use the `generator_config` parameter.

```python
generator_config={'<entity_type>':'<handling_option>'}
```

Where:

* `<entity_type>` is the identifier of the entity type. For example, `ORGANIZATION`.\
  \
  For the list of built-in entity types that Textual scans for, go to [Built-in entity types](/textual/entity-types/built-in-entity-types.md).\
  \
  For custom entity types, the identifier is the entity type name in all caps. Spaces are replaced with underscores, and the identifier is prefixed with `CUSTOM_`.\
  \
  For example, for a custom entity type named **My New Type**, the identifier is `CUSTOM_MY_NEW_TYPE`.\
  \
  From the **Custom Entity Types** page, to copy the identifier of a custom entity type, click its copy icon.

<figure><img src="/files/Ie532GkeJxy6fNyjgmtM" alt=""><figcaption><p>Copy identifier option for a custom entity type</p></figcaption></figure>

* `<handling_option>` is the handling option to use for the specified entity type. The possible values are `Redaction`, `Synthesis`, `GroupingSynthesis`, `ReplacementSynthesis`, and `Off`.

For example, to synthesize organization values, and ignore languages:

```
generator_config={'ORGANIZATION':'Synthesis', 'LANGUAGE':'Off'}
```

## Specifying a default handling option

For string and file redaction, you can specify a default handling option to use for entity types that are not specified in `generator_config`.

To do this, you use the `generator_default` parameter.

`generator_default` can be either `Redaction`, `Synthesis`, `GroupingSynthesis`, `ReplacementSynthesis`, or `Off`.

## Providing added and excluded values for entity types

You can also configure added and excluded values for each entity type.

You add values that Textual does not detect for an entity type, but should. You exclude values that you do not want Textual to identify as that entity type.

* To specify the added values, use `label_allow_lists`.
* To specify the excluded values, use `label_block_lists`.

For each of these parameters, the value is a list of entity types to specify the added or excluded values for. To specify the values, you provide an array of regular expressions.

```python
{'<entity_type>':['<regex>']}
```

The following example uses `label_allow_lists` to add values:

* For `NAME_GIVEN`, adds the values `There` and `Here`.
* For `NAME_FAMILY`, adds values that match the regular expression `([a-z]{2})`.

```python
(label_allow_lists={
    'NAME_GIVEN':['There','Here'], 
    'NAME_FAMILY':['([a-z]{2})']
    }
)
```

## Including custom entity types

When you redact a string or download a redacted file, you can provide a comma-separated list of custom entity types to include. Textual then scans for and redacts those entity types based on the configuration in `generator_config`.&#x20;

```
custom_entities="["<entity type identifier>"]
```

For example:

```python
custom_entities=["CUSTOM_COGNITIVE_ACCESS_KEY", "CUSTOM_PERSONAL_GRAVITY_INDEX"]
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.tonic.ai/textual/tonic-textual-api/textual-python-sdk/datasets-redaction/api-redaction-entity-type-handling.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
