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

# Batch Encode

`POST /api/scanner/encode/batch`

Encode multiple data items in a single request. All items share one `continuationId` for efficient batch processing.

**Request body:** A JSON array of encode items (not an object with an `items` property).

**SDK Usage:**
```typescript
const result = await client.encodeBatch({
  items: [
    { data: 'Alice Smith, alice@email.com', sourceContainer: 'users' },
    { data: 'Bob Jones, 555-123-4567', sourceContainer: 'users' }
  ]
});
```

## Request body

- EncodeBatchItem[]
  - `data` string, required — Input text containing potential PII
  - `sourceContainer` string
  - `sourceElement` string
  - `metadata` EncodingMetadata — Arbitrary metadata attached to the encoding for audit trail purposes
    - `rowId` string
    - `sourceTable` string
    - `sourceColumn` string
    - `recordType` string
    - `source` string
    - `sourceDataType` string
    - `sourceDataKey` string
    - `sourceDataOutlet` string
  - `scoreThreshold` number, double
  - `language` string

## Response `200`

Batch encoded successfully

- EncodeBatchResponse
  - `success` boolean
  - `continuationId` string — Shared continuation ID for all batch items
  - `results` EncodeResponse[]
    - `success` boolean
    - `encodedData` string — Text with PII replaced by Privacy Twins
    - `continuationId` string — Unique ID for decoding this data later
    - `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
    - `statistics` EncodingStatistics
      - `originalLength` integer — Character count of original input
      - `encodedLength` integer — Character count of encoded output
      - `piiEntitiesDetected` integer — Number of PII entities found
      - `transformationsApplied` integer — Number of transformations applied
      - `processingTimeMs` number — Server-side processing time in milliseconds
    - `message` string
  - `statistics` object
    - `itemsProcessed` integer
    - `totalProcessingTimeMs` number
    - `averageTimePerItemMs` number

## Other responses

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

## Changes

- **2026-08-20** `0e1db3b6bc7c` — 1 breaking, 4 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 `results` to the response with the `200` status
  - added the optional property `statistics` to the response with the `200` status
  - …1 more
- **2026-03-07** `f19009a654f5` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/privacypal/apis/privacypal-api/changes/api/scanner/encode/batch/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)
