# Branches

Branches identify a merchant's pickup locations. Use a branch's `id` as `origin.branch_id` when creating a delivery.

## Create a branch

Enable `branch:write` on the API key and send `POST /v2/branches`:

```json
{
  "name": "Main branch",
  "phone": "+96590000000",
  "latitude": 29.3359,
  "longitude": 48.0758
}
```

Coordinates are top-level `latitude` and `longitude` fields. Store the returned `id` for later requests.

## Operations

| Method   | Path                | Action            | Permission      |
| -------- | ------------------- | ----------------- | --------------- |
| `GET`    | `/v2/branches`      | List branches     | `branch:read`   |
| `POST`   | `/v2/branches`      | Create a branch   | `branch:write`  |
| `GET`    | `/v2/branches/{id}` | Retrieve a branch | `branch:read`   |
| `PUT`    | `/v2/branches/{id}` | Update a branch   | `branch:update` |
| `DELETE` | `/v2/branches/{id}` | Delete a branch   | `branch:delete` |

Branches belong to the merchant associated with the API key. When updating, send only changed fields; resubmitting the current branch name returns `400`. See the [API reference](https://docs.armadadelivery.com/v2/reference.md) for request fields and responses.
