detection

PII detection and redaction

Detect personally identifiable information (emails, phone numbers, US SSNs, credit card numbers, IP addresses, IBANs, US bank routing numbers) in a text. Detection of those types is deterministic (regex + checksum validation, no ML), and every entity comes with exact character offsets (start/end) into the submitted text. Set redact=true to also receive redacted_text: the input with each entity replaced by a placeholder like [EMAIL]. Person names, organizations, and locations/street addresses are NOT detected by default: list person/organization/location in types explicitly to add LLM-backed detection of them (slower, and the text is then capped at 10000 characters).

post/api/v1/pii

Request

  • Base URL: https://api.sapling.ai
  • URL: https://api.sapling.ai/api/v1/pii
  • Auth: one of:
    • HTTP bearer
    • OAuth 2 (authorization code, authorization URL https://api.sapling.ai/oauth/authorize, token URL https://api.sapling.ai/oauth/token, scopes: sapling:api)
    • none

Request body

keystring

Sapling API key. Required when no "Authorization: Bearer <key>" header is sent; when both are sent, the body key takes precedence over the header.

redactboolean

If true, the response includes redacted_text with every detected entity replaced by its placeholder.

return_usageboolean

When true, a successful JSON-object response additionally carries "usage": {"characters": <n>} — the billable character count this request submitted (0 for unbilled requests; the 2.5x adjustment for logographic languages is included, so CJK requests report more than their raw length). Repeat texts inside the billing deduplication window are still counted here even though they are not re-charged, so the number is an upper bound on the final charge. Responses whose body is not a JSON object (e.g. bare-array response formats) cannot carry the field. An existing usage field (such as account/status or completion token usage) is preserved unchanged.

textstring required

The text to scan. Offsets in the response refer to this exact string, so pass raw text (not HTML).

typesstring[]

Restrict detection to these PII types. Defaults to all deterministic types; person, organization, and location run only when listed here explicitly.

Response

Successful response. Field-level schemas and examples: https://sapling.ai/docs/api/pii/

Changes

No recorded changes to this operation across all 1 revision of this API.