# Open a card terminal

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

Requires the `businesses` scope.

Choose a package. Answers the forms the owner fills next (the acquirer agreement unless `acquirer` is `existing`, then the terminal), and the terminal is `requested` until it is connected: on its own when the card companies approve it, and the owner is told. In the sandbox the terminal is simulated and `active` at once; with `flow: true` it starts at `forms` and `POST /payment-terminal/simulate` walks it through the stages. Owner only.

## Path parameters

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

## Body

| Field | Type | | Description |
|---|---|---|---|
| `package` | string | **required** |  One of: `small`, `half`, `full`. |
| `acquirer` | string |  | `new` (default): no agreement with a card company yet. `existing`: the business already holds a supplier number (its agreement stays as it is, even when its current terminal is with another provider). One of: `new`, `existing`. |
| `flow` | boolean |  | Sandbox only: walk the stages instead of an active terminal at once. |

## 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. |
| `next` | object |  |  |
| `next.acquirerUrl` | string |  |  |
| `next.terminalUrl` | string |  |  |

Errors: `400`, `401`, `403`, `404`, `409`, `429`. 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" \
  -H "X-Api-Key: $KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "package": "small"
  }'
```
### Node

```node
const res = await fetch(`${BASE}/businesses/${BID}/payment-terminal`, {
  method: 'POST',
  headers: {
    'X-Api-Key': KEY,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "package": "small"
  }),
})
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",
    headers={"X-Api-Key": KEY},
    json={
      "package": "small"
    },
)
data = res.json()
```
### PHP

```php
$ch = curl_init("$BASE/businesses/$BID/payment-terminal");
curl_setopt_array($ch, [
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => ["X-Api-Key: $KEY", 'Content-Type: application/json'],
  CURLOPT_POSTFIELDS => json_encode([
    'package' => 'small',
  ]),
]);
$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");
req.Headers.Add("X-Api-Key", KEY);
req.Content = new StringContent("""
    {
      "package": "small"
    }
    """, Encoding.UTF8, "application/json");
using var res = await http.SendAsync(req);
var data = JsonDocument.Parse(await res.Content.ReadAsStringAsync()).RootElement;
```