Shipping Zones
Define where you ship and which carriers serve each place, then check coverage at runtime.
A shipping zone answers two questions at once: where do I ship? and with whom, there?
The operations — create a zone, assign it to a shop, look one up at runtime — are in Shipping Zones.
How the pieces fit
Zone "Norte de México" created once, at account level
├── region MX the whole country
├── region MX / NL only Nuevo León
└── region MX / NL / Monterrey only that city
│
├── assigned to Shop 1204
│ ├── carrier 12 (all services)
│ └── carrier 45 (service 6 only)
└── assigned to Shop 1310 the same zone, reused
Three steps, and each one is a separate call:
- Create the zone with its regions —
POST /config/shipping-zones - Assign it to a shop —
POST /config/shops/{shop_id}/shipping-zones - Add carriers to that shop's zone —
POST .../carriers
A zone on its own does nothing. Creating it is step one of three.
A zone needs at least one region. Creating one with an empty
regionsarray is rejected — a zone that covers nothing has no meaning.
Regions nest
API reference → Create shipping zone
{ "country_code": "MX" } // all of Mexico
{ "country_code": "MX", "level1": "NL" } // only Nuevo León
{ "country_code": "MX", "level1": "NL", "level2": "Monterrey" } // only MonterreyLeave a level empty and the zone covers everything below it.
curl -X POST https://queries.test.envia.com/config/shipping-zones \
-H "Authorization: Bearer $ENVIA_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Norte de México",
"regions": [
{ "country_code": "MX", "level1": "NL" },
{ "country_code": "MX", "level1": "COAH" },
{ "country_code": "MX", "level1": "TAMPS" }
]
}'Zones are reusable
The zone lives at account level. Assign the same one to several shops instead of duplicating it — and when the coverage changes, you change it once.
Detaching a zone from a shop does not delete it: DELETE .../shipping-zones/{shop_zone_id} removes the assignment, the zone survives for the other shops.
Adding carriers
API reference → Add a carrier to a shop zone
curl -X POST https://queries.test.envia.com/config/shops/1204/shipping-zones/88/carriers \
-H "Authorization: Bearer $ENVIA_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "carrier_id": 45, "service_id": 6 }'service_id is optional. Omit it and the whole carrier serves the zone; send it to restrict the zone to a single service.
To remove one later you need
carrier_entry_id— the id of the entry, returned when you added it. Not the carrier id. It is the most common mistake with this resource.
The question you actually ask at runtime
API reference → Look up which carriers serve a destination
curl -G https://queries.test.envia.com/config/shops/33488/shipping-zones/lookup \
-H "Authorization: Bearer $ENVIA_TOKEN" \
-d country=CO -d level1=CO-DC{ "data": { "carriers": [ { "carrier_id": 16, "service_id": null } ], "fallback": false } }level1 is matched exactly, so send the code your zone stores
level1 is matched exactly, so send the code your zone storesThe match is a string comparison against the region's level1. Regions hold ISO 3166-2 subdivision codes — CO-DC, not Bogotá D.C..
Send the name a buyer typed and you get a perfectly valid response with an empty carriers array and no error at all:
level1=CO-DC → carriers: [ { "carrier_id": 16 } ]
level1=Bogotá D.C. → carriers: [] ← same status, no warning
This is the failure that reaches production: a checkout maps the buyer's state name straight into level1, sees no carriers, and shows "no shipping available" for a destination you do cover. Read the codes from the zone's own regions array and map to those.
Sending only country is usually not enough
country is usually not enoughA region whose level1 is set only matches a lookup that sends that same level1. If your zones are defined per state, a country-only lookup matches nothing — again with no error.
Only regions that left level1 empty match a country-only lookup.
Read fallback before you read carriers
fallback before you read carriers| What it means | |
|---|---|
fallback: true | This shop has no active zones at all. Nothing to match against — fall back to your default carriers |
fallback: false, carriers: [] | Zones exist, but none of them covers this destination |
fallback: false, carriers: [...] | The answer |
fallback describes the shop's configuration, not the destination. It is true only when the shop has zero active zone assignments — so false on its own is not confirmation that a zone matched.
Where does shop_id come from?
shop_id come from?De GET /company/shops. Every shop-scoped operation needs one, and that is the only place to enumerate them.
Where this sits
| Decides | |
|---|---|
| Shipping zones | Can you ship there, and with whom |
| Checkout | What the buyer is offered |
| Shipping rules | Which service the order actually gets |
Endpoints
| Operation | Reference |
|---|---|
| List zones | GET /config/shipping-zones |
| Create zone | POST /config/shipping-zones |
| Get zone | GET /config/shipping-zones/{id} |
| Update zone | PUT /config/shipping-zones/{id} |
| Delete zone | DELETE /config/shipping-zones/{id} |
| Shop's zones | GET /config/shops/{shop_id}/shipping-zones |
| Assign to shop | POST /config/shops/{shop_id}/shipping-zones |
| Detach from shop | DELETE .../shipping-zones/{shop_zone_id} |
| Carriers in a zone | GET .../carriers |
| Add carrier | POST .../carriers |
| Remove carrier | DELETE .../carriers/{carrier_entry_id} |
| Look up a destination | GET .../shipping-zones/lookup |
Next steps
Choose which carriers and services your buyers see at checkout, and what each one is called.
Assign a service to each store order automatically, with no one choosing by hand.
The carriers you can ship with, the countries each one serves, and what each one supports.
Updated 18 days ago