Protect Text

Exclude specific content from compression.

Use the protect() function to wrap text that should not be compressed. When using the API directly, wrap content in <ttc_safe> tags.

Usage

from thetokencompany import TheTokenCompany, protect

client = TheTokenCompany(api_key="ttc-...")

header = """INCIDENT REPORT #4821
Date: 2026-01-15
Severity: Critical"""

document = f"""{protect(header)}

At approximately 14:32 UTC, the payment processing service began
experiencing elevated error rates due to a misconfigured connection pool..."""

result = client.compress(document, aggressiveness=0.4)

Result

Input
<ttc_safe>
INCIDENT REPORT #4821
Date: 2026-01-15
Severity: Critical
</ttc_safe>
At approximately 14:32 UTC, the payment processing service began experiencing elevated error rates due to a misconfigured connection pool...
Output
INCIDENT REPORT #4821
Date: 2026-01-15
Severity: Critical
14:32 UTC payment processing elevated error rates misconfigured connection pool...

When to use

  • Document headers - dates, IDs, severity levels, and metadata that must stay exact
  • Code snippets - protect code blocks that must remain syntactically valid
  • Structured data - JSON keys, XML tags, or template variables
  • Proper nouns - names, brands, or technical terms that shouldn't be altered