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

# Redact PHI from text

> 
Replace PHI in free text with indexed placeholders (`[PERSON_1]`, `[MY_IC_1]`)
and return the placeholder→original mapping so you can restore values after
your own model call.

**The mapping is never stored by us.** It is returned in the response and
discarded; you own re-identification. Every response carries a redaction
receipt (engine, version, entity counts) as the auditable proof that redaction
ran — the receipt records what was caught, and is not a claim of perfect
recall.

Detection covers Malaysian identifiers (MyKad/IC, MRN, passport, local phone
formats) alongside names, emails, and card/account numbers. Clinical content is
deliberately preserved: ages, dates like "day 3 post-op", vitals, and dosage
abbreviations are NOT redacted, because stripping them destroys the meaning a
downstream model needs.

**Fail-closed:** if redaction cannot complete, this endpoint returns 503 with a
`failed_closed` receipt and no text — it never returns your input unredacted.
    



## OpenAPI

````yaml /api/openapi-commercial.yaml post /api/v1/redact/
openapi: 3.0.3
info:
  title: Healthproximate API
  version: 1.0.0
  description: >-
    DRG classification, OMOP vocabulary services and a PHI-safe LLM gateway.


    Generated by `manage.py export_commercial_openapi` from an explicit
    operation allowlist (`app/openapi_commercial.py`). An endpoint appears here
    because someone published it, never because it exists.
  contact:
    email: admin@valiancehealth.ai
servers:
  - url: https://api.v2.healthproximate.com
security: []
tags:
  - name: DRG
    description: MS-DRG classification from coded input, free clinical text, or FHIR.
  - name: Vocabulary
    description: OMOP concept search, coding, translation and hierarchy resolution.
  - name: Gateway
    description: >-
      PHI-safe LLM access. Text is redacted before any model sees it and
      re-hydrated in the answer, and every response carries a receipt.
paths:
  /api/v1/redact/:
    post:
      tags:
        - Gateway
      summary: Redact PHI from text
      description: >-

        Replace PHI in free text with indexed placeholders (`[PERSON_1]`,
        `[MY_IC_1]`)

        and return the placeholder→original mapping so you can restore values
        after

        your own model call.


        **The mapping is never stored by us.** It is returned in the response
        and

        discarded; you own re-identification. Every response carries a redaction

        receipt (engine, version, entity counts) as the auditable proof that
        redaction

        ran — the receipt records what was caught, and is not a claim of perfect

        recall.


        Detection covers Malaysian identifiers (MyKad/IC, MRN, passport, local
        phone

        formats) alongside names, emails, and card/account numbers. Clinical
        content is

        deliberately preserved: ages, dates like "day 3 post-op", vitals, and
        dosage

        abbreviations are NOT redacted, because stripping them destroys the
        meaning a

        downstream model needs.


        **Fail-closed:** if redaction cannot complete, this endpoint returns 503
        with a

        `failed_closed` receipt and no text — it never returns your input
        unredacted.
            
      operationId: v1_redact_create
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RedactRequestRequest'
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/RedactRequestRequest'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/RedactRequestRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RedactResponse'
              examples:
                DischargeSummaryLine:
                  value:
                    redacted_text: >-
                      [PERSON_1], IC [MY_IC_1], 72yo day 3 post-op, 500 mg PO
                      amoxicillin
                    mapping:
                      '[PERSON_1]': Ali bin Ahmad
                      '[MY_IC_1]': 880101-14-5501
                    entities_redacted:
                      PERSON: 1
                      MY_IC: 1
                    redaction_receipt:
                      receipt_version: 1
                      engine: presidio-composed
                      engine_version: '1'
                      rehydration_complete: null
                      unresolved_placeholder_count: 0
                      client_preredacted: false
                      entities_redacted:
                        PERSON: 1
                        MY_IC: 1
                      free_text_fields: 1
                      client_asserted_deidentified: false
                      redacted_anyway: false
                      status: ok
                      retention: metadata_only
                  summary: Discharge summary line
          description: Redacted text plus the mapping and receipt
        '400':
          description: Invalid request
        '401':
          description: Authentication required
        '429':
          description: Rate limit exceeded
        '503':
          description: Redaction failed — request refused
      security:
        - api_key_auth: []
        - jwt_auth: []
components:
  schemas:
    RedactRequestRequest:
      type: object
      properties:
        text:
          type: string
          minLength: 1
          description: Free text to redact. PHI is replaced with indexed placeholders.
          maxLength: 100000
        prior_mapping:
          type: object
          additionalProperties:
            type: string
          description: >-
            Optional, and the preferred way to keep placeholders stable. Send
            back the `mapping` a previous call returned: a value already in it
            keeps its placeholder, and a new value gets the next free one.
            Supersedes `conversation_key`: if you send both, this one is used.
        conversation_key:
          type: string
          description: >-
            Deprecated in favour of `prior_mapping`. Supply the same value
            across related calls and the same source value keeps the same
            placeholder. It does this by deriving the placeholder from the
            source value itself, which makes the placeholder a code derived from
            information about the individual, and which cannot detect a
            collision across separate calls. Prefer `prior_mapping`.
          maxLength: 200
        return_mapping:
          type: boolean
          default: true
          description: >-
            Whether to return the placeholder→original mapping. The mapping is
            never stored server-side; set false if you only need redacted text
            and do not intend to re-identify.
      required:
        - text
    RedactResponse:
      type: object
      description: Documents the response shape for the schema; not used for validation.
      properties:
        redacted_text:
          type: string
        mapping:
          type: object
          additionalProperties:
            type: string
          description: >-
            placeholder → original value. Returned to YOU and never persisted by
            us: you own re-identification. Omitted when return_mapping=false.
        entities_redacted:
          type: object
          additionalProperties:
            type: integer
        redaction_receipt:
          type: object
          additionalProperties: {}
      required:
        - entities_redacted
        - mapping
        - redacted_text
        - redaction_receipt
  securitySchemes:
    api_key_auth:
      type: apiKey
      in: header
      name: X-API-Key
      description: >-
        API key for organization authentication. Obtain from the organization
        settings or API key management endpoint.
    jwt_auth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT access token obtained from /login/ endpoint

````