## Connect a device with a temporary challenge

Connect a device to the terminal that owns the given 8-digit temporary challenge.
The code must be unexpired. On success the device is bound, a fresh API key token
(prefixed with `reservepay_`) is returned, and the temporary challenge is cleared.

If the terminal is already bound to a different device, `ALREADY_CONNECTED` is returned.
If it is bound to the same device, the previous key is revoked and a new one is issued.

If the terminal is disabled, `NOT_ENABLED` is returned.

If the terminal has no installation linked, `NOT_CONFIGURED` is returned.

## Endpoint signature

```http
POST https://api.reservepay.com/terminals/connect-device-by-code HTTP/1.1
Content-Type: application/json
Accept: application/json

{
  code: string,
  device_id: string,
}
```

Returns: string

## Request arguments

### `code` (string)

**Required**. 8-digit temporary challenge for the terminal.

### `device_id` (string)

**Required**. Device UUID generated on device.

## Errors specific to this endpoint

### `ALREADY_CONNECTED`

The terminal is connected to another device.

### `INVALID_CHALLENGE`

The code is unknown or has expired.

### `NOT_ENABLED`

The terminal exists but is disabled; enable it before connecting a device.

### `NOT_CONFIGURED`

The terminal has no installation linked; assign an installation first.

## Errors common to all endpoints

### `UNHANDLED_ERROR`

Raised when the server encounters an unexpected internal error.

### `INVALID_ARGUMENTS`

Raised when the request contains invalid or missing parameters.

### `BAD_VERSION`

Raised when requesting an unsupported or deprecated API version.
