---
id: presidio-api
name: Presidio API
version: 1.0.0
summary: |
  External HTTP sidecar API for detecting PII in text and anonymizing detected
  entities in the Chat and Rating AI agent pipelines.
externalSystem: true
owners:
  - platform-engineering-team
badges:
  - content: External
    backgroundColor: purple
    textColor: purple
  - content: HTTP API
    backgroundColor: teal
    textColor: teal
receives:
  - id: AnalyzeText
    version: 1.0.0
    group: PII Processing
  - id: AnonymizeText
    version: 1.0.0
    group: PII Processing
  - id: GetRecognizers
    version: 1.0.0
    group: Presidio Configuration Queries
  - id: GetSupportedEntities
    version: 1.0.0
    group: Presidio Configuration Queries
  - id: GetAnonymizers
    version: 1.0.0
    group: Presidio Configuration Queries
styles:
  icon: /icons/third-party/presidio.svg
specifications:
  - type: openapi
    path: https://raw.githubusercontent.com/data-privacy-stack/presidio/refs/heads/main/docs/api-docs/api-docs.yml
    name: OpenAPI V2
---

## Integration Purpose & Boundary

Presidio provides external sidecar HTTP services (Analyzer and Anonymizer) for detecting and redacting personally identifiable information (PII) in text before and after AI model execution. BookWorm's deterministic PII middleware invokes Presidio on behalf of [[service|chat-api]] and [[service|rating-api]] agents so foundation models cannot bypass privacy screening.

:::warning
Although the attached upstream OpenAPI specification documents discovery endpoints (`GetRecognizers`, `GetSupportedEntities`, `GetAnonymizers`), BookWorm's runtime integration invokes only [[command|AnalyzeText]] and [[command|AnonymizeText]]—targeting email addresses, phone numbers, and credit-card numbers. All screening executes **fail-closed**: any timeout or non-success response aborts the AI turn rather than sending unscreened text.
:::

## Integration Profile

| Property                         | Value                                                                                                                                                                                                   |
| :------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Provider / Sidecar**           | Microsoft Presidio (`presidio-analyzer` and `presidio-anonymizer` sidecar containers)                                                                                                                   |
| **BookWorm Consumers**           | [[service\|chat-api]] ([[agent\|book-agent]], [[agent\|book-catalog-researcher]], [[agent\|book-recommendation-researcher]], [[agent\|qa-agent]]) and [[service\|rating-api]] ([[agent\|rating-agent]]) |
| **Runtime Transport & Protocol** | Internal HTTP/HTTPS via service discovery (not routed via public API Gateway)                                                                                                                           |
| **Auth / Credential Boundary**   | Internal cluster network boundary; no public exposure or customer credentials forwarded                                                                                                                 |
| **Data / PII Sensitivity**       | Critical — processes raw customer prompts, review text, and model responses; never log raw inputs, outputs, or detected PII spans                                                                       |
| **Failure / Fallback Behavior**  | Fail-closed — connection errors, timeouts, or non-success status codes propagate and fail the request immediately                                                                                       |

## Visualizations & Specifications

### Privacy Screening Context

<MermaidFileLoader file="mermaids/PresidioAPI-diagram-1.mmd" />

### Service Interactions

<NodeGraph />

<MessageTable format="all" limit={10} showChannels={true} />

## Related Documentation

- [[doc|platform/006-api-and-contracts]] — Consolidated service and contract index.
- [[service|chat-api]] — Conversational consumer of Presidio PII middleware.
- [[service|rating-api]] — Review summarization consumer of Presidio PII middleware.
- [[command|AnalyzeText]] — Request and response contract for PII detection.
- [[command|AnonymizeText]] — Request and response contract for PII redaction.
- [[system|data-privacy]] — External Data Privacy system boundary.
