# Connect a terminal the business already has

`POST /businesses/{bid}/payment-terminal/connect`

Requires the `businesses` scope.

For a business that already has a Tranzila terminal: its name, password and API keys. Stored sealed and never returned. When the terminal answers to the keys it is `active` at once (`verified: true`); otherwise the details wait to be connected by BillOS (`stage: connecting`). No setup fee. The sandbox connects a simulated terminal. Owner only.

## Path parameters

| Name | Type | | Description |
|---|---|---|---|
| `bid` | string | **required** | Business id, from `POST /businesses`. |

## Body

| Field | Type | | Description |
|---|---|---|---|
| `terminalName` | string | **required** |  |
| `pw` | string | **required** | The terminal password. |
| `appKey` | string | **required** | The API app key. |
| `appSecret` | string | **required** | The API secret. |

## Response

`201`: `{ "ok": true, … }`

| Field | Type | | Description |
|---|---|---|---|
| `ok` | boolean | **required** |  |
| `terminal` | PaymentTerminal | **required** | The business's own card terminal (clearing). Opened by the business through the acquirer's and the terminal provider's own forms, held under BillOS's dealer account; the money goes from the acquirer to the business's bank and never passes through BillOS. No credential is ever returned. |
| `verified` | boolean |  | The terminal answered to the keys and is active. |

Errors: `400`, `401`, `403`, `404`, `409`, `429`, `503`. Every failure answers `{ "error", "reason", "hint", "param", "doc_url", "retryable", "request_id" }`: branch on `reason`, and read `hint` for what to change (https://docs.billos.co.il/errors.md).

## Examples

### cURL

```bash
curl -X POST "$BASE/businesses/$BID/payment-terminal/connect" \
  -H "X-Api-Key: $KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "terminalName": "string",
    "pw": "string",
    "appKey": "string",
    "appSecret": "string"
  }'
```
### Node

```node
const res = await fetch(`${BASE}/businesses/${BID}/payment-terminal/connect`, {
  method: 'POST',
  headers: {
    'X-Api-Key': KEY,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "terminalName": "string",
    "pw": "string",
    "appKey": "string",
    "appSecret": "string"
  }),
})
const data = await res.json()
if (!data.ok) throw new Error(data.reason)
```
### Python

```python
import requests
res = requests.post(
    f"{BASE}/businesses/{BID}/payment-terminal/connect",
    headers={"X-Api-Key": KEY},
    json={
      "terminalName": "string",
      "pw": "string",
      "appKey": "string",
      "appSecret": "string"
    },
)
data = res.json()
```
### PHP

```php
$ch = curl_init("$BASE/businesses/$BID/payment-terminal/connect");
curl_setopt_array($ch, [
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => ["X-Api-Key: $KEY", 'Content-Type: application/json'],
  CURLOPT_POSTFIELDS => json_encode([
    'terminalName' => 'string',
    'pw' => 'string',
    'appKey' => 'string',
    'appSecret' => 'string',
  ]),
]);
$data = json_decode(curl_exec($ch), true);
```
### C#

```csharp
using System.Text;
using System.Text.Json;

using var http = new HttpClient();
using var req = new HttpRequestMessage(HttpMethod.Post, $"{BASE}/businesses/{BID}/payment-terminal/connect");
req.Headers.Add("X-Api-Key", KEY);
req.Content = new StringContent("""
    {
      "terminalName": "string",
      "pw": "string",
      "appKey": "string",
      "appSecret": "string"
    }
    """, Encoding.UTF8, "application/json");
using var res = await http.SendAsync(req);
var data = JsonDocument.Parse(await res.Content.ReadAsStringAsync()).RootElement;
```