# server_error

> Something failed at Rivr

- Status: 500 Internal Server Error
- Returned by: The account connection (/oauth)
- Retry (`retryWhen`): `never`
- Did anything happen? (`outcome`): `unknown` (Unknown)
- The account connection
- Page in the portal: https://developers.rivr.io/errors/server_error
- Try it: `GET https://developers.rivr.io/errors/simulate/server_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. `POST /oauth/token` and `POST /oauth/deauthorize` answer `500`. On `GET /oauth/authorize` the browser comes back to your address with `?error=server_error&state=…`. The sandbox's approval answers `500` with `{"code":"server_error"}`.

## What your system does

The code exchange: don't repeat the call with the same code; read the list of clinics and start over from `GET /oauth/authorize`. `GET /oauth/authorize`: start over with a new `state` and a new verifier. The exception is `POST /oauth/deauthorize`: the same call can be made again, and it gets the same answer when the clinic is already disconnected. If it persists, contact Rivr.

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

On the code exchange the clinic may already be connected: the code is spent, and the connection isn't undone if only the token failed. On the disconnection the connection may already have ended. On `GET /oauth/authorize` no request was saved.

Read the state (`resolveWith`):

- `oauthToken` → [`GET /api/public/merchants`](https://developers.rivr.io/reference/api-public/listMerchants.md): If the clinic is in the list the connection is made. Start over from `GET /oauth/authorize` to get the clinic's id in a new answer.
- `oauthDeauthorize` → [`GET /api/public/merchants/{merchantId}`](https://developers.rivr.io/reference/api-public/getMerchant.md): `404` with `merchant_not_found` means the connection has ended.

## Example: The account connection (/oauth)

```http
HTTP/1.1 500 Internal Server Error
Content-Type: application/json
Cache-Control: no-store

{
  "error": "server_error",
  "error_description": "The connection could not be completed."
}
```

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