# Localities & Regions

> Validate delivery coverage before customers check out. Show them if their comuna is covered.

Source: https://api-doc.4nortes.app/localities

Check if a customer's location is covered before they check out. Use the same region and comuna data you see in your panel to validate addresses.

<a id="overview"></a>

## How it works

Chile has 16 regions, each with multiple comunas. When syncing an order, you identify the destination comuna in the `destination_locality` field - the same locations shown in your panel dropdowns.

```
Region (e.g., "Metropolitana de Santiago")
  └── Locality (e.g., "Santiago")
  └── Locality (e.g., "Providencia")
  └── Locality (e.g., "Las Condes")
  ...
```

<a id="regions"></a>

## Regions

Regions are the top-level geographic divisions. Each region has:

| Field              | Type    | Description                      |
| ------------------ | ------- | -------------------------------- |
| `id`               | integer | Unique region identifier         |
| `name`             | string  | Region name                      |
| `slug`             | string  | URL-friendly identifier          |
| `localities_count` | integer | Number of comunas in this region |

### Example Regions

| Name               | Slug                      |
| ------------------ | ------------------------- |
| Arica y Parinacota | arica-y-parinacota        |
| Tarapacá           | tarapaca                  |
| Antofagasta        | antofagasta               |
| Atacama            | atacama                   |
| Coquimbo           | coquimbo                  |
| Valparaíso         | valparaiso                |
| Metropolitana      | metropolitana-de-santiago |
| O'Higgins          | ohiggins                  |
| Maule              | maule                     |
| Ñuble              | nuble                     |
| Biobío             | biobio                    |
| La Araucanía       | la-araucania              |
| Los Ríos           | los-rios                  |
| Los Lagos          | los-lagos                 |
| Aysén              | aysen                     |
| Magallanes         | magallanes                |

<a id="localities"></a>

## Comunas

Comunas (localities) are the delivery areas within each region. Each has:

| Field       | Type    | Description                                                      |
| ----------- | ------- | ---------------------------------------------------------------- |
| `id`        | integer | Unique locality identifier                                       |
| `name`      | string  | Locality name                                                    |
| `slug`      | string  | URL-friendly identifier                                          |
| `type`      | string  | `urban`, `rural` or `both`                                       |
| `region_id` | integer | The region it belongs to                                         |
| `aliases`   | array   | Alternative spellings that are also matched when you send a name |

### Name or id — both work

`destination_locality` on `POST /orders/create` (and on `POST /rates/quote`) accepts either form:

- **The name** (or an alias). Matching ignores case and accents, so `"Nunoa"` resolves to `Ñuñoa`. If nothing matches you get a `404` with `Locality not found: …`.
- **The numeric id**, sent **as a string**: `"2"`, not `2`. Ids come from `GET /localities` or from a previous quote's `locality_id`. Prefer this once you have mapped your addresses — it can't be misread.

```json
{
  "destination_address": "Calle Principal 123",
  "destination_locality": "Providencia"
}
```

```json
{
  "destination_address": "Calle Principal 123",
  "destination_locality": "2"
}
```

> **Note:**
>
> Fetch the [full list of comunas](https://api-doc.4nortes.app/api/references.md#list-localities) once and cache it. This data rarely changes.

<a id="coverage"></a>

## Check coverage before you create

Your account delivers to a configured set of comunas. An order to a comuna outside that set is rejected with a `422` (`Merchant … has no coverage for locality: …`) - after the customer has already checked out, if you don't validate earlier.

Call [`POST /rates/quote`](https://api-doc.4nortes.app/api/references.md#quote-rates) with the destination and weight while the customer is still in your checkout. It runs the same locality resolution and coverage check as order creation and returns the price and transit time, so you can show the shipping cost and block uncovered addresses up front.
