> 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/operations/create-operation.md).

# Create Operation

Service that creates an operation and returns its ID along with its expiration time.

The `operationId` returned is the one sent when [storing an asset](https://docs.facephi.com/docs.facephi-en/rest-api/midapi-v2/storage/save-asset.md) and is the first segment of every asset key.

### Endpoint

```
POST /operation
```

### Headers

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

### Request body

The body is optional: a request without a body creates the operation anyway.

#### Parameters

| Parameter           | Type   | Required | Description                                                                                                |
| ------------------- | ------ | -------- | ---------------------------------------------------------------------------------------------------------- |
| `merchantReference` | string | No       | Your own reference for this operation: the order, case, or cart it corresponds to. Maximum 128 characters. |

#### Request example

```json
{
  "merchantReference": "ORD-4417"
}
```

{% hint style="info" %}
`merchantReference` is an **informational**reference. The service stores and returns it, but it cannot be used to look up or operate on the operation: an operation is always identified by its `operationId`. It is not unique, so two operations can have the same reference without being related.
{% endhint %}

It is stored without leading or trailing whitespace, and a blank reference is equivalent to omitting it.

### Responses

#### `201` Created

#### Response parameters

| Parameter           | Type   | Description                                                   |
| ------------------- | ------ | ------------------------------------------------------------- |
| `operationId`       | string | Operation identifier (UUID).                                  |
| `timestamp`         | string | Creation time in **ISO 8601** (UTC) format.                   |
| `expiresAt`         | string | Expiration time in **ISO 8601** (UTC) format.                 |
| `merchantReference` | string | The reference sent, returned as is. Omitted if none was sent. |

#### Response example

```json
{
  "operationId": "0192a3f4-7b21-7c44-9e1a-3f5b8c2d1e04",
  "timestamp": "2026-06-26T12:00:00Z",
  "expiresAt": "2026-06-26T12:15:00Z",
  "merchantReference": "ORD-4417"
}
```

#### Other responses

| Code  | Description                                                                                                                                                                                       |
| ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `400` | `merchantReference` exceeding 128 characters, or a malformed body.                                                                                                                                |
| `401` | Token is missing, invalid, or expired.                                                                                                                                                            |
| `403` | The consumer is not provisioned for the `OPERATION`.                                                                                                                                              |
| `429` | The consumer has exceeded its request rate limit. The response includes `Retry-After` with the wait time in seconds, and `X-RateLimit-Limit` and `X-RateLimit-Burst` with the current thresholds. |
| `503` | The service is temporarily unavailable.                                                                                                                                                           |

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