# Create a business

`POST /businesses`

Requires the `businesses` scope.

One business per end user. Everything else is nested under the id this returns.

A business created with `lastInvoiceNumber` continues an existing numbering sequence. That is how you migrate a dealer off their previous software without restarting their document numbers.

## Body

| Field | Type | | Description |
|---|---|---|---|
| `name` | string | **required** | Legal business name. |
| `taxId` | string | **required** | Checksum-validated. |
| `dealerType` | string | **required** |  One of: `patur`, `murshe`, `company`, `ngo`. |
| `address` | string |  |  |
| `phone` | string |  |  |
| `email` | string |  |  |
| `defaultVatRateBp` | integer |  | Basis points. Defaults to the current statutory rate. |
| `lastInvoiceNumber` | integer |  | Continue an existing sequence from this number. |
| `branding` | Branding |  | Appearance of the rendered PDF. Stored once per business; a logo is stored as a file and referenced by hash, never re-frozen into each document. |

## Response

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

| Field | Type | | Description |
|---|---|---|---|
| `ok` | boolean | **required** |  |
| `business` | Business | **required** | One Israeli dealer (עוסק), one of your end users. |

Errors: `400`, `401`, `403`, `404`, `429`. Every failure answers `{ "error": …, "reason": … }`. Branch on `reason`.

## Examples

### cURL

```bash
curl -X POST "$BASE/businesses" \
  -H "X-Api-Key: $KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "דנה לוי",
    "taxId": "514667426",
    "dealerType": "murshe"
  }'
```
### Node

```node
const res = await fetch(`${BASE}/businesses`, {
  method: 'POST',
  headers: {
    'X-Api-Key': KEY,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "name": "דנה לוי",
    "taxId": "514667426",
    "dealerType": "murshe"
  }),
})
const data = await res.json()
if (!data.ok) throw new Error(data.reason)
```
### Python

```python
import requests
res = requests.post(
    f"{BASE}/businesses",
    headers={"X-Api-Key": KEY},
    json={
      "name": "דנה לוי",
      "taxId": "514667426",
      "dealerType": "murshe"
    },
)
data = res.json()
```