# Redact individual files

{% hint style="info" %}
**Required global permission:** Use the API to parse or redact a text string
{% endhint %}

You can use the Textual SDK to redact and synthesize values in individual files.

Before you perform these tasks, remember to [instantiate the SDK client](https://docs.tonic.ai/textual/tonic-textual-api/textual-api-instantiate-sdk).

For a self-hosted instance, you can also configure the S3 bucket to use to store the files. For more information, go to [textual-config-pipeline-upload](https://docs.tonic.ai/textual/textual-install-administer/configuring-textual/enable-and-configure-textual-features/textual-config-pipeline-upload "mention"). For an example of an IAM role with the required permissions, go to [#file-upload-example-iam-role](https://docs.tonic.ai/textual/textual-install-administer/configuring-textual/enable-and-configure-textual-features/pipelines-example-iam-roles#file-upload-example-iam-role "mention").

## Sending a file to Textual <a href="#textual-api-send-file" id="textual-api-send-file"></a>

To send an individual file to Textual, you use [`textual.start_file_redaction`](https://tonic-textual-sdk.readthedocs-hosted.com/en/latest/redact/api.html#tonic_textual.redact_api.TextualNer.start_file_redaction).

You first open the file so that Textual can read it, then make the call for Textual to read the file.

```python
with open("<path to the file>", "r") as f:
    j = textual.start_file_redaction(f,"<file name>")
```

The response includes:

* The file name
* The identifier of the job that processed the file. You use this identifier to retrieve a transformed version of the file.

## Getting the file with redacted or synthesized values <a href="#textual-api-get-redacted-file" id="textual-api-get-redacted-file"></a>

After you use [`textual.start_file_redaction`](https://tonic-textual-sdk.readthedocs-hosted.com/en/latest/redact/api.html#tonic_textual.redact_api.TextualNer.start_file_redaction) to send the file to Textual, you use [`textual.download_redacted_file`](https://tonic-textual-sdk.readthedocs-hosted.com/en/latest/redact/api.html#tonic_textual.redact_api.TextualNer.download_redacted_file) to retrieve a transformed version of the file.

To identify the file, you use the job identifier that you received from `textual.start_file_redaction`. You can [specify the entity type handling](https://docs.tonic.ai/textual/tonic-textual-api/datasets-redaction/api-redaction-entity-type-handling) for the detected entity values.

Before you make the call to download the file, you specify the path to download the file content to.

{% code overflow="wrap" %}

```python
with open("<path to output location>", "wb") as fo:
    fo.write(textual.download_redacted_file(<job identifier>)
```

{% endcode %}


---

# Agent Instructions: 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:

```
GET https://docs.tonic.ai/textual/tonic-textual-api/datasets-redaction/textual-api-redact-files.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
