---
title: "Encode File"
method: POST
path: "/api/scanner/encode/file"
tags: ["Encoding"]
---

# Encode File

`POST /api/scanner/encode/file`

Upload and encode a file for PII detection. Supports PDF, DOCX, CSV, images, and more.
The file is processed server-side and returned as base64-encoded content with PII replaced by Privacy Twins.

**SDK Usage:**
```typescript
const result = await client.encodeFile({
  file: blob,
  fileName: 'customer-report.pdf',
  processImages: true,
  platform: 'node_sdk'
});
```

## Response `200`

File encoded successfully

- EncodeFileResponse
  - `success` boolean
  - `encodedFile` string — Base64-encoded file content with PII replaced
  - `continuationId` string
  - `transformations` Transformation[]
    - `originalHash` string — Cryptographic hash of the original value
    - `twinHash` string — Cryptographic hash of the twin value
    - `entityType` 'PERSON' | 'EMAIL_ADDRESS' | 'PHONE_NUMBER' | 'US_SSN' | 'DATE_TIME' | 'LOCATION' | 'CREDIT_CARD' | 'IP_ADDRESS' | 'IBAN_CODE' | 'US_PASSPORT' | 'US_DRIVER_LICENSE' | 'NRP' | 'MEDICAL_LICENSE' | 'URL' — Type of PII entity detected
    - `catalogItemId` string — Internal catalog item identifier
    - `position` object
      - `start` integer — Start character index in the original text
      - `end` integer — End character index in the original text
    - `score` number, double — Detection confidence score (0.0–1.0)
    - `original` string — Original PII value (available for local decoding)
    - `twin` string — Synthetic Privacy Twin value
    - `components` TransformationComponent[] — Sub-part breakdowns (e.g., first name, last name)
      - `original` string — Original sub-part value
      - `twin` string — Twin sub-part value
      - `type` 'FIRST_NAME' | 'LAST_NAME' | 'CITY' | 'STATE' | 'DATE_FULL_FORMAT' | 'MONTH_NAME' | 'DAY' | 'YEAR' — Component type
  - `mimeType` string — MIME type of the processed output
  - `fileName` string — Output file name
  - `originalContent` string — Original extracted text content
  - `encodedContent` string — Text content with Privacy Twins applied
  - `imageBypassed` boolean — Whether image processing was bypassed

## Other responses

- `401` — Authentication failed or token expired
- `403` — Trial expired or subscription required

## Changes

- **2026-08-20** `0e1db3b6bc7c` — 1 breaking, 9 info
  - the response's body type/format changed from ``/`` to `object`/`` for status `200`
  - added the optional property `continuationId` to the response with the `200` status
  - added the optional property `encodedContent` to the response with the `200` status
  - added the optional property `encodedFile` to the response with the `200` status
  - …6 more
- **2026-03-07** `f19009a654f5` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/privacypal/apis/privacypal-api/changes/api/scanner/encode/file/post.md)

---

[API](https://skmtc.dev/privacypal/apis/privacypal-api.md) · [All operations](https://skmtc.dev/privacypal/apis/privacypal-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/privacypal/privacypal-api/revisions/0e1db3b6bc7c/schema)
