# order_modified_concurrently

> The order was written at the same time

- Status: 409 Conflict
- Returned by: /api/public
- Operations: [createOrder](https://developers.rivr.io/reference/api-public/createOrder.md)
- Retry (`retryWhen`): `same_request`
- Did anything happen? (`outcome`): `partial` (Something else happened)
- Creating an order in /api/public
- Page in the portal: https://developers.rivr.io/errors/order_modified_concurrently
- Try it: `GET https://developers.rivr.io/errors/simulate/order_modified_concurrently` answers with the code's exact wire form; `?succeedAfter=N&attempt=K` gives a 200 once `attempt` passes `N`

## What it means

Another request wrote the same order at the same time, or created the same new patient, so this request did not save the order. It may already have looked up, created or updated the patient and run the credit check, and for a new order started the order, which the other request then completed, so an order number may have been used up. The answer carries `Retry-After`: 1 second for the order, 5 seconds when it was the patient.

## What your system does

Wait `Retry-After` and send the same request again with the same order id. The request then continues the order that exists: an unpaid order is written again, and the patient may then get its message again. Read the order with `GET /api/public/orders/{orderId}` if you first want to see what the other request saved.

## Is it worth retrying?

Yes. The same call can succeed in a while.

`retryWhen`: `same_request`. Send the very same request again, unchanged: the same `Idempotency-Key` and the same order id. Wait `Retry-After` seconds when the answer has the header, otherwise a short while that grows with each attempt.

## Did anything happen?

`outcome`: `partial`. **Something else happened.** What you asked for did not happen, but something else had already happened, see the note.

This request did not save the order, but it may have looked up, created or updated the patient and run the credit check, and for a new order started the order, which the other request completed, so an order number may have been used up. With Avarda, credit may have been reserved again, and credit with Avarda may have been held for the patient without the order carrying it. Nothing was charged.

Read the state (`resolveWith`):

- `createOrder` → [`GET /api/public/orders/{orderId}`](https://developers.rivr.io/reference/api-public/getOrder.md): `200`: the order with the id exists, written or completed by the other request. `204`: there is no order yet. A retry with the same id creates no second order.

## Example: /api/public

```http
HTTP/1.1 409 Conflict
Content-Type: application/json
Retry-After: 1

{
  "propertyName": "orderId",
  "message": "The order was modified concurrently by another request. Retry the request.",
  "errorCode": "order_modified_concurrently",
  "code": "order_modified_concurrently",
  "type": "https://developers.rivr.io/errors/order_modified_concurrently"
}
```

The `title`, `detail`, `message` and `error_description` texts are exactly as the API writes them today.
