# Business

A **business** is the recipient of a B2B order: the company you ship inventory to, as opposed to an end consumer in a D2C order. Each business holds one or more **delivery locations** — the physical addresses an order can be sent to.

### Why these endpoints matter

Creating a B2B order does not take an address. It takes a reference:

```json
"business": {
  "id": "Testing-business-SC",
  "delivery_location_id": "Testing-location-SC"
}
```

So a business and its locations have to exist **before** you can create an order for them, and you need their ids. That is what this folder is for: `Get all` resolves the ids you already have, `Create in bulk` registers the ones you do not.

### Ids are yours or ours

Both a business and a location accept an `external_id` — your own identifier. When you provide one, it is what the API returns and what you use when creating orders, so you never have to store a Melonn id on your side. When you do not, the responses fall back to Melonn's internal id and you use that instead.

### One active location at a time

A business can accumulate several delivery locations over time — an address changes, a branch closes — while only one is current. Each location reports `active` so you can tell which one to send orders to. Use it rather than assuming the first or the most recent entry is the right one.

### Endpoints

-   **`Get all`** — every business registered for you, each with its delivery locations. The response is not truncated, regardless of how many you have. Filter by `email` when you are looking for a specific one.
    
-   **`Create in bulk`** — register several businesses in one request, each with its delivery locations. Beyond contact details it takes `logo_url` (must resolve to a `.jpg`, `.jpeg` or `.png`; the image is fetched and stored on our side) and `business_vas` (ids of value-added services to associate — these are validated, so an unknown id fails the request).
    

### Response Codes

| Status Code | Description |
| --- | --- |
| 200 OK | Request completed successfully. |
| 400 Bad Request | Validation error — for example a logo URL that is not a supported image. |
| 401 Unauthorized | Missing or invalid `x-api-key`. |
| 404 Not Found | A referenced VAS id does not exist. |
