# Pair New Device

- Sandbox: `POST https://sandbox.payme.io/api/vas/pos/pair`
- Production: `POST https://live.payme.io/api/vas/pos/pair`

## Credentials

- Request body field `payme_client_key` (required): Your private API Key
- Request body field `seller_payme_id` (required): Your Merchant's unique ID in our system

## Overview

This method is used to pair a stand-alone terminal to a POS/ECR. Each stand-alone terminal has a unique ID that is used in the paring process, this method is called first and then the pairing process is finalized by calling the authenticate method. Target URLs


As a part of the pairing process, the devices will be numbered automatically - The first device - 001 and onwards.

When initiating a payment request, you will need to use this identifier and mention it as a part of the API endpoint `sales` request.

## Parameters

This endpoint takes no path, query or header parameters.

## Request body

Content type: `application/json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `payme_client_key` | string | yes | Your private API Key |
| `seller_payme_id` | string | yes | Your Merchant's unique ID in our system |
| `pos_id` | string | yes | The ID you must choose for your POS. Must be a string of digits, between "001" and "999" |
| `terminal_id` | string | yes | A unique payment terminal identifier, this ID is displayed on the POS in the pairing process |
| `name` | string | no | The name of the POS, this will be displayed on the devices screen. Usually this is the Merchant's name |

### Request example

```json
{
  "payme_client_key": "partner_key",
  "seller_payme_id": "MPLXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX",
  "pos_id": "001",
  "terminal_id": "9000015000",
  "name": "John Doe"
}
```

## Code samples

### curl

```bash
curl -X POST 'https://sandbox.payme.io/api/vas/pos/pair' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "payme_client_key": "partner_key",
  "seller_payme_id": "MPLXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX",
  "pos_id": "001",
  "terminal_id": "9000015000",
  "name": "John Doe"
}'
```

### Node.js

```javascript
const response = await fetch("https://sandbox.payme.io/api/vas/pos/pair", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "payme_client_key": "partner_key",
    "seller_payme_id": "MPLXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX",
    "pos_id": "001",
    "terminal_id": "9000015000",
    "name": "John Doe"
  }),
});

console.log(await response.text());
```

### Python

```python
import requests

response = requests.post(
    "https://sandbox.payme.io/api/vas/pos/pair",
    json={
        "payme_client_key": "partner_key",
        "seller_payme_id": "MPLXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX",
        "pos_id": "001",
        "terminal_id": "9000015000",
        "name": "John Doe",
    },
)

print(response.text)
```

### PHP

```php
<?php

$body = <<<'BODY'
{
  "payme_client_key": "partner_key",
  "seller_payme_id": "MPLXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX",
  "pos_id": "001",
  "terminal_id": "9000015000",
  "name": "John Doe"
}
BODY;

$ch = curl_init('https://sandbox.payme.io/api/vas/pos/pair');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => $body,
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
```

## Responses

### 200 — OK (success)

| Field | Type | Description |
| --- | --- | --- |
| `status_code` | number | Status of the request (0: success, otherwise error) |

```json
{
  "status_code": 0
}
```

### 500 — Internal Server Error (error)

| Field | Type | Description |
| --- | --- | --- |
| `status_code` | number | Status of the request (0: success, otherwise error) |
| `status_error_details` | string | Error message to the client |
| `status_additional_info` | string | Additional error information |
| `status_error_code` | number | Our unique error code |

```json
{
  "status_code": 1,
  "status_error_details": "Wrong terminalID",
  "status_additional_info": null,
  "status_error_code": -1001
}
```
