# Delivery Areas

Delivery areas define the geographic zones a restaurant delivers to. Each area is a polygon of latitude/longitude points with its own delivery fee, delay, minimum order amount, and optional weekly schedules. Areas become active for online ordering once they are linked to a delivery consumption mode. `deliveryFee`, `minimumAmount`, and `minimumAmountForFreeDelivery` are expressed in cents (`250` = 2.50); `deliveryDelay` is expressed in minutes.

**Access flag required:** Replacing the delivery areas of a restaurant requires the `CAN_EDIT_AREAS` access flag in addition to role-based authorization.

#### Reference Values

schedules\[\].day

Day of week: `MON`, `TUE`, `WED`, `THU`, `FRI`, `SAT`, `SUN`

schedules\[\].start / end

Time in minutes from midnight (e.g., `690` = 11:30, `840` = 14:00).

schedules\[\].orderingQuota

Maximum number of orders accepted in the time slot. `null` means no quota.

### `GET /areas/restaurant/{restaurantId}` - List Delivery Areas

Retrieve all delivery areas of a restaurant, including their polygon points and weekly schedules.

#### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| restaurantId | integer | Yes | The unique identifier of the restaurant. |

#### Response

```json
{
  "status": 200,
  "code": "fetch_areas_succeed",
  "message": "The areas for the given restaurant have been successfully fetched.",
  "data": [
    {
      "areaId": 31,
      "uuid": "c4d5e6f7-a8b9-0123-cdef-456789abcdef",
      "restaurantId": 200,
      "name": "Paris Center",
      "deliveryFee": 250,
      "deliveryDelay": 30,
      "isActivated": true,
      "minimumAmount": 1500,
      "paymentLater": false,
      "minimumAmountForFreeDelivery": 3000,
      "forceOnlinePayment": true,
      "priority": 1,
      "isScheduleModeEnabled": true,
      "points": [
        {
          "lat": 48.8738,
          "lng": 2.295
        },
        {
          "lat": 48.8738,
          "lng": 2.36
        },
        {
          "lat": 48.845,
          "lng": 2.36
        },
        {
          "lat": 48.845,
          "lng": 2.295
        }
      ],
      "schedules": [
        {
          "start": 690,
          "end": 840,
          "day": "MON",
          "orderingQuota": 20
        },
        {
          "start": 1080,
          "end": 1320,
          "day": "MON",
          "orderingQuota": null
        }
      ]
    }
  ]
}
```

##### Response Properties

Every field in the example is listed below. Explicit requiredness is shown when the endpoint contract defines it.

| Property | Type | Example | Description |
| --- | --- | --- | --- |
| status | integer | 200 | HTTP status code returned by the API. |
| code | string | "fetch\_areas\_succeed" | Machine-readable application code for the result. |
| message | string | "The areas for the given restaurant have been successfully fetched." | Human-readable result message. Do not use this value for program logic. |
| data | array | \[…\] | Endpoint-specific response payload. |
| data\[\] | object | {…} | Endpoint-specific response payload. |
| data\[\].areaId | integer | 31 | Identifier of the associated area. |
| data\[\].uuid | string | "c4d5e6f7-a8b9-0123-cdef-456789abcdef" | The uuid value. |
| data\[\].restaurantId | integer | 200 | Identifier of the restaurant. |
| data\[\].name | string | "Paris Center" | The name value. |
| data\[\].deliveryFee | integer | 250 | The delivery fee value. |
| data\[\].deliveryDelay | integer | 30 | The delivery delay value. |
| data\[\].isActivated | boolean | true | Whether activated is enabled or applies. |
| data\[\].minimumAmount | integer | 1500 | The minimum amount value. |
| data\[\].paymentLater | boolean | false | The payment later value. |
| data\[\].minimumAmountForFreeDelivery | integer | 3000 | The minimum amount for free delivery value. |
| data\[\].forceOnlinePayment | boolean | true | The force online payment value. |
| data\[\].priority | integer | 1 | The priority value. |
| data\[\].isScheduleModeEnabled | boolean | true | Whether schedule mode enabled is enabled or applies. |
| data\[\].points | array | \[…\] | List of points entries. |
| data\[\].points\[\] | object | {…} | Object containing points fields. |
| data\[\].points\[\].lat | number | 48.8738 | The lat value. |
| data\[\].points\[\].lng | number | 2.295 | The lng value. |
| data\[\].schedules | array | \[…\] | List of schedules entries. |
| data\[\].schedules\[\] | object | {…} | Object containing schedules fields. |
| data\[\].schedules\[\].start | integer | 690 | The start value. |
| data\[\].schedules\[\].end | integer | 840 | The end value. |
| data\[\].schedules\[\].day | string | "MON" | The day value. |
| data\[\].schedules\[\].orderingQuota | integer | 20 | The ordering quota value. |

**Full replacement:** the endpoint below replaces the _entire_ list of delivery areas of the restaurant. All existing areas and their schedules are deleted, then recreated from the payload - any area missing from the payload is permanently lost, and new `areaId` values are assigned on every call. To modify a single area you must resend _all_ areas. Include the `areaId` of an existing area in its payload object to preserve its `uuid` and its consumption mode bindings (the returned `areaId` still changes); areas sent without an `areaId` lose those bindings.

### `POST /areas/restaurant/{restaurantId}` - Replace Delivery Areas

Replace all delivery areas of a restaurant with the provided list, in a single transaction. Unknown fields in the payload are silently ignored.

#### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| restaurantId | integer | Yes | The unique identifier of the restaurant. |

#### Request Body

```json
{
  "areas": [
    {
      "areaId": 31,
      "name": "Paris Center",
      "deliveryFee": 250,
      "deliveryDelay": 30,
      "isActivated": true,
      "minimumAmount": 1500,
      "minimumAmountForFreeDelivery": 3000,
      "forceOnlinePayment": true,
      "isScheduleModeEnabled": true,
      "priority": 1,
      "points": [
        {
          "lat": 48.8738,
          "lng": 2.295
        },
        {
          "lat": 48.8738,
          "lng": 2.36
        },
        {
          "lat": 48.845,
          "lng": 2.36
        },
        {
          "lat": 48.845,
          "lng": 2.295
        }
      ],
      "schedules": [
        {
          "start": 690,
          "end": 840,
          "day": "MON",
          "orderingQuota": 20
        }
      ]
    },
    {
      "name": "Paris West",
      "deliveryFee": 400,
      "deliveryDelay": 45,
      "isActivated": true,
      "minimumAmount": 2000,
      "minimumAmountForFreeDelivery": null,
      "forceOnlinePayment": true,
      "isScheduleModeEnabled": false,
      "points": [
        {
          "lat": 48.8738,
          "lng": 2.25
        },
        {
          "lat": 48.8738,
          "lng": 2.295
        },
        {
          "lat": 48.845,
          "lng": 2.295
        },
        {
          "lat": 48.845,
          "lng": 2.25
        }
      ]
    }
  ]
}
```

##### Request Body Properties

Every field in the example is listed below. Explicit requiredness is shown when the endpoint contract defines it.

| Property | Type | Example | Description |
| --- | --- | --- | --- |
| areas | array | \[…\] | List of areas entries. |
| areas\[\] | object | {…} | Object containing areas fields. |
| areas\[\].areaId | integer | 31 | Identifier of the associated area. |
| areas\[\].name | string | "Paris Center" | The name value. |
| areas\[\].deliveryFee | integer | 250 | The delivery fee value. |
| areas\[\].deliveryDelay | integer | 30 | The delivery delay value. |
| areas\[\].isActivated | boolean | true | Whether activated is enabled or applies. |
| areas\[\].minimumAmount | integer | 1500 | The minimum amount value. |
| areas\[\].minimumAmountForFreeDelivery | integer | 3000 | The minimum amount for free delivery value. |
| areas\[\].forceOnlinePayment | boolean | true | The force online payment value. |
| areas\[\].isScheduleModeEnabled | boolean | true | Whether schedule mode enabled is enabled or applies. |
| areas\[\].priority | integer | 1 | The priority value. |
| areas\[\].points | array | \[…\] | List of points entries. |
| areas\[\].points\[\] | object | {…} | Object containing points fields. |
| areas\[\].points\[\].lat | number | 48.8738 | The lat value. |
| areas\[\].points\[\].lng | number | 2.295 | The lng value. |
| areas\[\].schedules | array | \[…\] | List of schedules entries. |
| areas\[\].schedules\[\] | object | {…} | Object containing schedules fields. |
| areas\[\].schedules\[\].start | integer | 690 | The start value. |
| areas\[\].schedules\[\].end | integer | 840 | The end value. |
| areas\[\].schedules\[\].day | string | "MON" | The day value. |
| areas\[\].schedules\[\].orderingQuota | integer | 20 | The ordering quota value. |

#### Response

```json
{
  "status": 201,
  "code": "create_areas_succeed",
  "message": "The areas for the given restaurant have been successfully created.",
  "data": [
    {
      "areaId": 45,
      "uuid": "c4d5e6f7-a8b9-0123-cdef-456789abcdef",
      "restaurantId": 200,
      "name": "Paris Center",
      "deliveryFee": 250,
      "deliveryDelay": 30,
      "isActivated": true,
      "minimumAmount": 1500,
      "paymentLater": false,
      "minimumAmountForFreeDelivery": 3000,
      "forceOnlinePayment": true,
      "priority": 1,
      "isScheduleModeEnabled": true,
      "points": [
        {
          "lat": 48.8738,
          "lng": 2.295
        },
        {
          "lat": 48.8738,
          "lng": 2.36
        },
        {
          "lat": 48.845,
          "lng": 2.36
        },
        {
          "lat": 48.845,
          "lng": 2.295
        }
      ],
      "schedules": [
        {
          "start": 690,
          "end": 840,
          "day": "MON",
          "orderingQuota": 20
        }
      ]
    },
    {
      "areaId": 46,
      "uuid": "d5e6f7a8-b9c0-1234-def0-56789abcdef0",
      "restaurantId": 200,
      "name": "Paris West",
      "deliveryFee": 400,
      "deliveryDelay": 45,
      "isActivated": true,
      "minimumAmount": 2000,
      "paymentLater": false,
      "minimumAmountForFreeDelivery": null,
      "forceOnlinePayment": true,
      "priority": null,
      "isScheduleModeEnabled": false,
      "points": [
        {
          "lat": 48.8738,
          "lng": 2.25
        },
        {
          "lat": 48.8738,
          "lng": 2.295
        },
        {
          "lat": 48.845,
          "lng": 2.295
        },
        {
          "lat": 48.845,
          "lng": 2.25
        }
      ],
      "schedules": []
    }
  ]
}
```

##### Response Properties

Every field in the example is listed below. Explicit requiredness is shown when the endpoint contract defines it.

| Property | Type | Example | Description |
| --- | --- | --- | --- |
| status | integer | 201 | HTTP status code returned by the API. |
| code | string | "create\_areas\_succeed" | Machine-readable application code for the result. |
| message | string | "The areas for the given restaurant have been successfully created." | Human-readable result message. Do not use this value for program logic. |
| data | array | \[…\] | Endpoint-specific response payload. |
| data\[\] | object | {…} | Endpoint-specific response payload. |
| data\[\].areaId | integer | 45 | Identifier of the associated area. |
| data\[\].uuid | string | "c4d5e6f7-a8b9-0123-cdef-456789abcdef" | The uuid value. |
| data\[\].restaurantId | integer | 200 | Identifier of the restaurant. |
| data\[\].name | string | "Paris Center" | The name value. |
| data\[\].deliveryFee | integer | 250 | The delivery fee value. |
| data\[\].deliveryDelay | integer | 30 | The delivery delay value. |
| data\[\].isActivated | boolean | true | Whether activated is enabled or applies. |
| data\[\].minimumAmount | integer | 1500 | The minimum amount value. |
| data\[\].paymentLater | boolean | false | The payment later value. |
| data\[\].minimumAmountForFreeDelivery | integer | 3000 | The minimum amount for free delivery value. |
| data\[\].forceOnlinePayment | boolean | true | The force online payment value. |
| data\[\].priority | integer | 1 | The priority value. |
| data\[\].isScheduleModeEnabled | boolean | true | Whether schedule mode enabled is enabled or applies. |
| data\[\].points | array | \[…\] | List of points entries. |
| data\[\].points\[\] | object | {…} | Object containing points fields. |
| data\[\].points\[\].lat | number | 48.8738 | The lat value. |
| data\[\].points\[\].lng | number | 2.295 | The lng value. |
| data\[\].schedules | array | \[…\] | List of schedules entries. |
| data\[\].schedules\[\] | object | {…} | Object containing schedules fields. |
| data\[\].schedules\[\].start | integer | 690 | The start value. |
| data\[\].schedules\[\].end | integer | 840 | The end value. |
| data\[\].schedules\[\].day | string | "MON" | The day value. |
| data\[\].schedules\[\].orderingQuota | integer | 20 | The ordering quota value. |

### Consumption Mode Bindings

A delivery area only applies to online ordering once it is bound to a delivery consumption mode of the same restaurant. Binding and unbinding return the consumption mode reloaded with all its linked modules.

### `POST /areas/{areaId}/consumption_modes/{consumptionModeId}` - Bind Area to Consumption Mode

Link a delivery area to a consumption mode, activating the area for that mode. The area must belong to the same restaurant as the consumption mode; otherwise a 403 access\_denied error is returned.

#### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| areaId | integer | Yes | The unique identifier of the delivery area. |
| consumptionModeId | integer | Yes | The unique identifier of the consumption mode. |

#### Response

```json
{
  "status": 200,
  "code": "module_bind_succeed",
  "data": {
    "consumptionModeId": 15,
    "restaurantId": 200,
    "brandId": 100,
    "channelId": 2,
    "type": "MODE_DELIVERY",
    "fee": 250,
    "delay": 30,
    "areas": [
      {
        "areaId": 45,
        "name": "Paris Center"
      }
    ]
  }
}
```

##### Response Properties

Every field in the example is listed below. Explicit requiredness is shown when the endpoint contract defines it.

| Property | Type | Example | Description |
| --- | --- | --- | --- |
| status | integer | 200 | HTTP status code returned by the API. |
| code | string | "module\_bind\_succeed" | Machine-readable application code for the result. |
| data | object | {…} | Endpoint-specific response payload. |
| data.consumptionModeId | integer | 15 | Identifier of the associated consumption mode. |
| data.restaurantId | integer | 200 | Identifier of the restaurant. |
| data.brandId | integer | 100 | Identifier of the brand. |
| data.channelId | integer | 2 | Identifier of the associated channel. |
| data.type | string | "MODE\_DELIVERY" | The type value. |
| data.fee | integer | 250 | The fee value. |
| data.delay | integer | 30 | The delay value. |
| data.areas | array | \[…\] | List of areas entries. |
| data.areas\[\] | object | {…} | Object containing areas fields. |
| data.areas\[\].areaId | integer | 45 | Identifier of the associated area. |
| data.areas\[\].name | string | "Paris Center" | The name value. |

### `DELETE /areas/{areaId}/consumption_modes/{consumptionModeId}` - Unbind Area from Consumption Mode

Remove the link between a delivery area and a consumption mode, deactivating the area for that mode.

#### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| areaId | integer | Yes | The unique identifier of the delivery area. |
| consumptionModeId | integer | Yes | The unique identifier of the consumption mode. |

#### Response

```json
{
  "status": 200,
  "code": "module_unbind_succeed",
  "data": {
    "consumptionModeId": 15,
    "restaurantId": 200,
    "brandId": 100,
    "channelId": 2,
    "type": "MODE_DELIVERY",
    "fee": 250,
    "delay": 30,
    "areas": []
  }
}
```

##### Response Properties

Every field in the example is listed below. Explicit requiredness is shown when the endpoint contract defines it.

| Property | Type | Example | Description |
| --- | --- | --- | --- |
| status | integer | 200 | HTTP status code returned by the API. |
| code | string | "module\_unbind\_succeed" | Machine-readable application code for the result. |
| data | object | {…} | Endpoint-specific response payload. |
| data.consumptionModeId | integer | 15 | Identifier of the associated consumption mode. |
| data.restaurantId | integer | 200 | Identifier of the restaurant. |
| data.brandId | integer | 100 | Identifier of the brand. |
| data.channelId | integer | 2 | Identifier of the associated channel. |
| data.type | string | "MODE\_DELIVERY" | The type value. |
| data.fee | integer | 250 | The fee value. |
| data.delay | integer | 30 | The delay value. |
| data.areas | array | \[\] | List of areas entries. |
