> 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/midapi-v2/storage/save-asset.md).

# Save Asset

Service that stores an asset in the context of an operation and returns the key with which it is later referenced.

### Endpoint

```
POST /storage
```

### Headers

| Name              | Type   | Required | Description                                                                                                                   |
| ----------------- | ------ | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
| **Authorization** | string | **Yes**  | Consumer Token in Bearer format `Bearer <token>`. See [Authentication](/docs.facephi-en/rest-api/midapi-v2/autenticacion.md). |
| **consumer-id**   | string | **Yes**  | Consumer identifier.                                                                                                          |

### Request body

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

#### Parameters

| Parameter       | Type   | Required | Description                                                                                                                                                    |
| --------------- | ------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `operationId`   | string | **Yes**  | Identifier of the operation to which the asset belongs, as returned by [Create Operation](/docs.facephi-en/rest-api/midapi-v2/operations/create-operation.md). |
| `asset`         | object | **Yes**  | Asset to store.                                                                                                                                                |
| `asset.context` | string | **Yes**  | Asset context. See [Asset contexts](/docs.facephi-en/rest-api/midapi-v2/storage.md#contextos-de-asset).                                                        |
| `asset.file`    | string | **Yes**  | Content of the asset encoded in **Base64**, in the format required by its context.                                                                             |

{% hint style="warning" %}
The four image contexts require the tokenized buffer generated by the capture SDK. A JPEG or PNG image in Base64 is rejected with `400`. The only context that accepts a free binary is `TOKEN_BIN_IAD`.
{% endhint %}

The maximum size per asset is **10 MiB**, applied to the encoded content.

#### Request example

```json
{
  "operationId": "0192a3f4-7b21-7c44-9e1a-3f5b8c2d1e04",
  "asset": {
    "context": "TOKEN_FRONT_DOCUMENT",
    "file": "<base64>"
  }
}
```

### Responses

#### `200` Success

#### Response parameters

| Parameter   | Type   | Description                                                                                              |
| ----------- | ------ | -------------------------------------------------------------------------------------------------------- |
| `fileKey`   | string | Asset key, in the form `{operationId}/{CONTEXTO}`. It is sent back unchanged when referencing the asset. |
| `timestamp` | string | Response timestamp in format **ISO 8601**.                                                               |

#### Response example

```json
{
  "fileKey": "0192a3f4-7b21-7c44-9e1a-3f5b8c2d1e04/TOKEN_FRONT_DOCUMENT",
  "timestamp": "2026-06-26T12:00:03.000Z"
}
```

#### Derived contexts

When storing an asset `TOKEN_BIN_IAD` the context is also available `TOKEN_BEST_IMAGE` of the same operation, with the best image from that capture. A `TOKEN_BEST_IMAGE` may be stored later; if one is already stored, that one is kept.

Query [Get File Keys](/docs.facephi-en/rest-api/midapi-v2/operations/get-file-keys.md) to confirm which contexts are available in the operation.

#### Other responses

| Code  | Description                                                                                                                                                                               |
| ----- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `400` | The `operationId` does not have the expected format, the content does not correspond to the declared context, or the asset is empty or exceeds the maximum size.                          |
| `403` | The consumer is not provisioned with the service `STORAGE`.                                                                                                                               |
| `404` | The operation does not exist or belongs to another consumer.                                                                                                                              |
| `409` | An asset of that context already exists in the operation.                                                                                                                                 |
| `410` | The operation has expired.                                                                                                                                                                |
| `429` | The consumer has exceeded its request rate limit. The response includes `Retry-After` with the wait seconds, and `X-RateLimit-Limit` and `X-RateLimit-Burst` with the current thresholds. |

The body of an error response has the form described in [MIDAPI v2](/docs.facephi-en/rest-api/midapi-v2.md#respuestas-de-error).
