# GET /api/public/merchants/{merchantId}

> Retrieve a Merchant by MerchantId

- Surface: `/api/public` · operationId `getMerchant` · Group: Merchant
- Authorisation: Token with scope `public:merchants:read`
- Organisation key: needs the capability `settings:read` on the clinic
- The spec: https://developers.rivr.io/openapi/api-public.json
- The spec's introduction: https://developers.rivr.io/reference/api-public.md
- Page in the portal: https://developers.rivr.io/reference/api-public/getMerchant

The examples target the sandbox (`https://api.test.rivr.io`) and need test credentials.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `merchantId` | path | string (uuid) | yes |  |

## Responses

### 200

OK

`application/json`

**Response fields**

| Field | Type | Description |
| --- | --- | --- |
| `merchant` | Merchant |  |
| `merchant.id` | string (uuid) |  |
| `merchant.name` | string | (nullable) |
| `merchant.organisationNumber` | string | (nullable) |
| `merchant.externalId` | string | (nullable) |

**Example**

```json
{
  "merchant": {
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "name": "string",
    "organisationNumber": "string",
    "externalId": "string"
  }
}
```

### 401

The token is missing (`token_missing`), not valid (`token_invalid`), expired (`token_expired`) or could not be
checked (`authentication_unavailable`).

Error codes: [token_missing](https://developers.rivr.io/errors/token_missing.md), [token_invalid](https://developers.rivr.io/errors/token_invalid.md), [token_expired](https://developers.rivr.io/errors/token_expired.md), [authentication_unavailable](https://developers.rivr.io/errors/authentication_unavailable.md)

`application/json`

```json
{
  "title": "Unauthorized",
  "status": 401,
  "detail": "Invalid Authorization Header",
  "propertyName": null,
  "message": "The request has no valid Authorization header. Send the token in the Authorization header, after Bearer.",
  "errorCode": "token_missing",
  "code": "token_missing",
  "type": "https://developers.rivr.io/errors/token_missing"
}
```

### 403

The token lacks the scope (`invalid_scope`) or is a rivr-auth token that is not a clinic token
(`clinic_token_required`). The body also carries `error` and `error_description`, as before.

Error codes: [invalid_scope](https://developers.rivr.io/errors/invalid_scope.md), [clinic_token_required](https://developers.rivr.io/errors/clinic_token_required.md)

`application/json`

```json
{
  "error": "invalid_scope",
  "error_description": "The scope(s) 'public:merchants:read' is required.",
  "propertyName": null,
  "message": "The scope(s) 'public:merchants:read' is required.",
  "errorCode": "invalid_scope",
  "code": "invalid_scope",
  "type": "https://developers.rivr.io/errors/invalid_scope"
}
```

### 404

There is no merchant with the id that the token reaches, or the id is not a UUID: `merchant_not_found`. A merchant
the token does not reach gets exactly the same answer as one that does not exist.

Error codes: [merchant_not_found](https://developers.rivr.io/errors/merchant_not_found.md)

`application/json`

```json
{
  "propertyName": "Merchant",
  "message": "The entity could not be found",
  "errorCode": "merchant_not_found",
  "code": "merchant_not_found",
  "type": "https://developers.rivr.io/errors/merchant_not_found"
}
```

### 500

Something unexpected failed: `internal_error`.

Error codes: [internal_error](https://developers.rivr.io/errors/internal_error.md)

`application/json`

```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"
}
```

## Example request

```bash
curl -X GET https://api.test.rivr.io/api/public/merchants/3fa85f64-5717-4562-b3fc-2c963f66afa6 \
  -H "Authorization: Bearer $ACCESS_TOKEN"
```
