> 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).

# Detokenize Image

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

### Endpoint

```
POST /services/detokenize
```

### Headers

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

### Request body

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

#### Parameters

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

#### Request example

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

### Responses

#### `200` Success

#### Response parameters

| Parameter       | Type   | Description                                                              |
| --------------- | ------ | ------------------------------------------------------------------------ |
| `timestamp`     | string | Date and time of the request in format **ISO 8601**.                     |
| `transactionId` | string | Transaction identifier associated with the request processed by the API. |
| `imageBuffer`   | string | Decoded image in format **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"
}
```

#### `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"
}
```
