> For the complete documentation index, see [llms.txt](https://docs.facephi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.facephi.com/docs.facephi-en/rest-api/identity-api/identity-api-reference/security-compliance/detokenize-image.md). Agents can also search and read this documentation through its [MCP server](https://docs.facephi.com/~gitbook/mcp).

# Detokenize Image

Service exposed to detokenize the best encrypted image generated by the **Selphi Widget**. The service must receive the string `bestImageToken` and the `transactionId` associated with the identity service previously executed in the Onboarding flow.

### Endpoint

```
POST /services/detokenize
```

### Headers

| Name          | Type   | Required | Description                       |
| ------------- | ------ | -------- | --------------------------------- |
| **x-api-key** | string | **Yes**  | Authorization API key for access. |

### Request body

**Content-Type:** `application/json`

#### Parameters

| Parameter        | Type   | Required | Description                                                                                                             |
| ---------------- | ------ | -------- | ----------------------------------------------------------------------------------------------------------------------- |
| `bestImageToken` | string | **Yes**  | Tokenized image sent in the `bestImage` parameter of the `/identity`.                                                   |
| `transactionId`  | string | No       | Transaction ID associated with the Liveness module operation/validation, obtained from the response of the `/identity`. |

#### Request example

```json
{
  "bestImageToken": "{BEST_IMAGE_TOKEN}",
  "transactionId": "{TRANSACTION_ID}"
}
```

{% hint style="warning" %}
**Maximum request size: 6 MB.** The tokenized image (`bestImageToken`) and the remaining fields count toward this limit. If the limit is exceeded, the gateway responds `413` without processing the request. See [Request size limit](https://docs.facephi.com/pages/bc7bee9358079d52bafa44ad281828eb424e96fe#l%C3%ADmite-de-tama%C3%B1o-de-la-solicitud).
{% endhint %}

### Responses

#### `200` Success

#### Response parameters

| Parameter       | Type   | Description                                                              |
| --------------- | ------ | ------------------------------------------------------------------------ |
| `timestamp`     | string | Request date and time in **ISO 8601**.                                   |
| `transactionId` | string | Transaction identifier associated with the request processed by the API. |
| `imageBuffer`   | string | Decoded image in **Base64**.                                             |

#### Response example

```json
{
  "timestamp": "2024-03-19T12:34:28Z",
  "transactionId": "238ee483-60d9-45ea-85bd-a6bc686d70b7",
  "imageBuffer": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCA..."
}
```

#### `400` Bad Request

```json
{
  "status": 400,
  "title": "Bad Request",
  "detail": "Invalid request.",
  "type": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400",
  "errors": []
}
```

#### `401` Unauthorized

```json
{
  "message": "Unauthorized"
}
```

#### `403` Forbidden

```json
{
  "Message": "User is not authorized to access this resource with an explicit deny"
}
```

#### `413` Payload Too Large

The request exceeds the maximum allowed size. The gateway rejects it **without processing it**: the response does not include `serviceResultCode` or `serviceTransactionId`. See [Request size limit](https://docs.facephi.com/pages/bc7bee9358079d52bafa44ad281828eb424e96fe#l%C3%ADmite-de-tama%C3%B1o-de-la-solicitud).

Request larger than 6 MB and up to 10 MB (`Content-Type: application/json`):

```json
{
  "message": "Request Too Long"
}
```

Request larger than 10 MB (10,485,760 bytes) (`Content-Type: text; charset=utf-8`, plain text, not JSON):

```
HTTP content length exceeded 10485760 bytes.
```

#### `502` Bad Gateway

```json
{
  "status": 502,
  "title": "Bad Gateway",
  "detail": "Server got an invalid response.",
  "type": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502"
}
```

#### `504` Gateway Timeout

```json
{
  "message": "Endpoint request timed out"
}
```
