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

# Redact String • AI Agent SDK

> redact_string: Redact potential secrets from a string.

# redact\_string

Function

> This function is defined in the [**redact**](https://praison.ai/docs/sdk/reference/praisonaiagents/modules/redact.md) module.

Redact potential secrets from a string.

This is a best-effort function that looks for common patterns
like "api\_key=xxx" or "password: xxx" in strings, plus secrets carried
in URLs (`scheme://user:pass@host` userinfo, `?token=xxx` query
params and `/bot&lt;id&gt;:&lt;token&gt;/` path segments).

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def redact_string(text: str, enabled: bool) -> str
```

## Parameters

**text** `str` *required*

String to redact

**enabled** `bool` (default: True)

If False, returns text unchanged

### Returns

**Returns** `str`

String with potential secrets redacted

## Uses

* `_URL_USERINFO_PATTERN.sub`
* `_URL_BOT_TOKEN_PATTERN.sub`
* `_REDACT_KV_PATTERN.sub`

## Used By

* [`scrub_pii_text`](../functions/scrub_pii_text)

## Source

> [card] [View on GitHub](https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/trace/redact.py#L233)
>
> `praisonaiagents/trace/redact.py` at line 233


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.