# internal_error

> Unexpected error at Rivr

- Status: 500 Internal Server Error
- Returned by: /api/public
- Operations: [createOrder](https://developers.rivr.io/reference/api-public/createOrder.md), [getOrder](https://developers.rivr.io/reference/api-public/getOrder.md), [getOrderStatus](https://developers.rivr.io/reference/api-public/getOrderStatus.md), [getOrderReceipt](https://developers.rivr.io/reference/api-public/getOrderReceipt.md), [refundOrder](https://developers.rivr.io/reference/api-public/refundOrder.md), [cancelOrder](https://developers.rivr.io/reference/api-public/cancelOrder.md), [sendOrderToDevice](https://developers.rivr.io/reference/api-public/sendOrderToDevice.md), [getDevices](https://developers.rivr.io/reference/api-public/getDevices.md), [listMerchants](https://developers.rivr.io/reference/api-public/listMerchants.md), [getMerchant](https://developers.rivr.io/reference/api-public/getMerchant.md), [getOnboardingProgress](https://developers.rivr.io/reference/api-public/getOnboardingProgress.md), [createOnboardingLink](https://developers.rivr.io/reference/api-public/createOnboardingLink.md), [getOnboardingLinks](https://developers.rivr.io/reference/api-public/getOnboardingLinks.md), [getOnboardingLink](https://developers.rivr.io/reference/api-public/getOnboardingLink.md), [refreshOnboardingLink](https://developers.rivr.io/reference/api-public/refreshOnboardingLink.md), [listOrderSettlements](https://developers.rivr.io/reference/api-public/listOrderSettlements.md), [getOrderSettlement](https://developers.rivr.io/reference/api-public/getOrderSettlement.md), [getNextUnreadSettlement](https://developers.rivr.io/reference/api-public/getNextUnreadSettlement.md), [createSubscription](https://developers.rivr.io/reference/api-public/createSubscription.md), [getSubscription](https://developers.rivr.io/reference/api-public/getSubscription.md)
- Retry (`retryWhen`): `never`
- Did anything happen? (`outcome`): `unknown` (Unknown)
- Rivr's services
- Page in the portal: https://developers.rivr.io/errors/internal_error
- Try it: `GET https://developers.rivr.io/errors/simulate/internal_error` answers with the code's exact wire form; `?succeedAfter=N&attempt=K` gives a 200 once `attempt` passes `N`

## What it means

Something unexpected failed at Rivr, and whether the request was carried out isn't known. The body used to be empty.

## What your system does

Check the order, or what the request was about, before you retry. The exception is `PUT /api/public/orders/{orderId}` (createOrder): a lost answer or a rare `500` can be sent again with the same order id, because a `PUT` with the same id creates at most one order (when the same order is created at the same time, one of the requests gets `409`). The retry still redoes some things: an unpaid order is written again and the patient may get its message again, and if the order wasn't saved, the credit check runs again. If it persists, contact Rivr with the call's time and path.

## Is it worth retrying?

No, not without changing the call.

`retryWhen`: `never`. Don't send it again. The answer is final for this request: read the current state, the order for example, and act on that.

## Did anything happen?

`outcome`: `unknown`. **Unknown.** The answer doesn't say whether what you asked for has happened, through this call or an earlier one. Read the state first.

The error comes from a catch-all and can follow writes: a customer created or updated and a credit check made, an order saved, a refund queued, an order cancelled or sent to the device, an onboarding link issued and sent, a subscription created or given more payments, or a settlement marked as read. A read changed nothing.

Read the state (`resolveWith`):

- `createOrder` → [`GET /api/public/orders/{orderId}`](https://developers.rivr.io/reference/api-public/getOrder.md): `204`: the order doesn't exist. `200` shows its status. The same `PUT` with the same order id creates no second order, but an unpaid order is written again and the patient may get its message again, and if the order wasn't saved, the credit check runs again.
- `refundOrder` → [`GET /api/public/orders/{orderId}/status`](https://developers.rivr.io/reference/api-public/getOrderStatus.md): `status` 8 (Refunded): the refund is made. It runs asynchronously, so the status can stay 4 (Completed) for a while although it is queued. With an `Idempotency-Key` this code means nothing was written, since an error after the first write answers `idempotency_outcome_unknown`.
- `cancelOrder` → [`GET /api/public/orders/{orderId}/status`](https://developers.rivr.io/reference/api-public/getOrderStatus.md): `status` 32 (Cancelled) means done. Another call on a cancelled order answers `204`.
- `sendOrderToDevice` → [`GET /api/public/orders/{orderId}/status`](https://developers.rivr.io/reference/api-public/getOrderStatus.md): Sending doesn't change the order, so `status` doesn't show whether the device got it. 1 (Created): no payment is done or parked, but the order may already show on the device and a payment may be under way there without the status changing, so look at the device before you send again with a new key. 2 (Pending): an invoice, bank or financing payment is under way. 4 (Completed): the order is paid. 8 (Refunded) or 32 (Cancelled): the order is refunded or cancelled. Anything but 1 answers `order_not_sendable` on another attempt. With an `Idempotency-Key` this code means nothing was sent, since an error after the line before the send answers `idempotency_outcome_unknown`.
- `createOnboardingLink` → [`GET /api/public/onboarding-links`](https://developers.rivr.io/reference/api-public/getOnboardingLinks.md): Look for the organisation number. If there is an open link, a new `POST` gives it back; if there is only a draft with `url` null, a new `POST` creates another draft, so get the draft's link with `POST /api/public/onboarding-links/{id}/refresh` instead.
- `refreshOnboardingLink` → [`GET /api/public/onboarding-links/{id}`](https://developers.rivr.io/reference/api-public/getOnboardingLink.md)
- `createSubscription` → [`GET /api/public/subscriptions/{subscriptionId}`](https://developers.rivr.io/reference/api-public/getSubscription.md): When you have the id from before. The same body again doesn't add payments with the same `externalReference` a second time.
- `getNextUnreadSettlement` → [`GET /api/public/order-settlements`](https://developers.rivr.io/reference/api-public/listOrderSettlements.md): The settlement may already be marked as read, and then doesn't come back from next-unread.

## Example: /api/public

```http
HTTP/1.1 500 Internal Server Error
Content-Type: application/json

{
  "propertyName": null,
  "message": "Something unexpected failed at Rivr, and whether the request was carried out is not known. Check the order or what the request was about before you retry.",
  "errorCode": "internal_error",
  "code": "internal_error",
  "type": "https://developers.rivr.io/errors/internal_error"
}
```

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