Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/plantasur-dev/ship-quote/llms.txt

Use this file to discover all available pages before exploring further.

Zones are the geographic building blocks of the Ship Quote rate engine. Each zone groups one or more destination province admin codes under a single name — for example, Cayco’s ZONA 1 covers only Madrid (ES-M), while its ZONA 7 spans eight north-western provinces. When a quote request arrives with a destination postal code or province, the engine resolves the province’s admin code, finds the matching zone for the active agency, and uses that zone name to look up the correct price row in the agency’s rate table. Postal code exceptions — which override the default zone for specific postal code ranges within a province — are stored in a separate ZoneRules collection, not on the zone document itself. Tecum, for example, redirects certain postal codes in Guadalajara (ES-GU) to ZONA 2 instead of the province’s default zone, enabling fine-grained pricing for rural or remote areas. See the bootstrap reference below for sample ZoneRules data.
Each zone is agency-scoped via agencyId. An agency’s zone set must be complete — every province it serves should be covered by at least one zone, otherwise the rate engine will return no quote for destinations in uncovered provinces.

POST /api/v1/zones

Create a new zone for an agency. The pricingMode and volumetric fields are set to their model defaults on creation; use the bootstrap utilities to set custom values during data seeding.

Request body

agencyId
string
required
MongoDB ObjectId of the agency this zone belongs to.
name
string
required
Zone identifier as it appears in the agency’s rate table (e.g. "ZONA 1", "ZONA 3", "ZONA 21", "NACIONAL"). This value is used verbatim as the lookup key when pricing a shipment.
provinces
array
List of province admin full codes covered by this zone. Each entry must be a string in the format "CC-ADMINCODE" matching the adminFullCode field in the locations collection (e.g. "ES-M" for Madrid, "ES-B" for Barcelona). A zone may cover multiple provinces or none (for special zones such as international or unassigned tiers).
calculationMode
string
Controls which rate table the engine consults when pricing a shipment destined for this zone. Accepted values:
  • "pallet" — use the pallet rate table (default)
  • "parcel" — use the parcel rate table

Response — 201 Created

id
string
MongoDB ObjectId of the newly created zone.
agencyId
string
ObjectId of the owning agency. The GET endpoints populate this with name and code from the agency document.
name
string
Zone name as stored.
provinces
array
Array of province admin full codes covered by this zone.
calculationMode
string
"pallet" or "parcel".
volumetric
object
Volumetric weight configuration for this zone.
pricingMode
object
Internal pricing configuration applied by the engine for this zone. Set automatically by the server; not accepted as a POST request body field.
createdAt
string
ISO 8601 creation timestamp.
updatedAt
string
ISO 8601 last-updated timestamp.

Error responses

StatusCondition
400 Bad RequestagencyId or name is missing, or the request body is malformed.

Examples

curl -X POST http://localhost:3000/api/v1/zones \
  -H "Content-Type: application/json" \
  -d '{
    "agencyId": "507f1f77bcf86cd799439011",
    "name": "ZONA 3",
    "provinces": ["ES-AV", "ES-GU", "ES-SG", "ES-VA"],
    "calculationMode": "pallet"
  }'

GET /api/v1/zones

Return all zones across all agencies. The agencyId field is populated with the agency’s name and code for convenience. Returns 404 when no zone documents exist in the collection.

Response — 200 OK

An array of zone objects. Each object matches the POST 201 response shape above, with agencyId expanded to include name and code.

Example

curl -X GET http://localhost:3000/api/v1/zones

GET /api/v1/zones/:zoneId

Retrieve the details of a single zone by its MongoDB ObjectId. The agencyId field is populated with the agency’s name and code.

Path parameters

zoneId
string
required
MongoDB ObjectId of the zone to retrieve.

Response — 200 OK

A single zone object (same shape as the POST 201 response, with agencyId populated).

Error responses

StatusCondition
404 Not FoundNo zone document exists with the given zoneId.

Example

curl -X GET http://localhost:3000/api/v1/zones/684b3a1cbe9876543210dcba

Bootstrap reference — real zone definitions

The tables below show the zones loaded by the built-in seed data for Cayco and Tecum, giving concrete examples of how province admin codes are grouped into pricing tiers.

Cayco zones

ZoneProvincesPricing mode
ZONA 1ES-Mweight
ZONA 2ES-TOweight
ZONA 3ES-AV, ES-GU, ES-SG, ES-VAweight
ZONA 4ES-VI, ES-A, ES-BU, ES-CS, ES-LE, ES-LO, ES-MU, ES-SA, ES-SO, ES-TE, ES-V, ES-Z, ES-CRweight
ZONA 5ES-O, ES-S, ES-CU, ES-SS, ES-NA, ES-BI, ES-P, ES-AB, ES-ZAweight
ZONA 6ES-B, ES-HU, ES-Tweight
ZONA 7ES-C, ES-GI, ES-LU, ES-OR, ES-PO, ES-CC, ES-BA, ES-Lweight
ZONA 11ES-AL, ES-J, ES-MAweight_volume (Andalucia)
ZONA 12ES-SE, ES-COweight_volume (Andalucia)
Cayco’s ZONA 11 and ZONA 12 cover Andalucia and use pricingMode.type = "weight_volume" with volumetric.enabled = true and a tonnage threshold of 1 001 kg. Shipments to these zones are priced using a per-kilogram rate table rather than the standard pallet tier table.

Tecum zones

ZoneProvinces
ZONA 1ES-GU, ES-M
ZONA 2ES-SO, ES-TO
ZONA 3ES-AV, ES-BU, ES-LO, ES-SG, ES-VA, ES-Z
ZONA 4ES-VI, ES-HU, ES-LE, ES-NA, ES-P, ES-SA, ES-TE, ES-V, ES-ZA
ZONA 5ES-CS, ES-SS, ES-L, ES-O, ES-S, ES-T, ES-BI
ZONA 6ES-B, ES-CC
ZONA 7ES-C, ES-GI, ES-LU, ES-OR, ES-PO
ZONA 8(empty — reserved tier)
ZONA 9ES-IB-ML
ZONA 10ES-IB-IB, ES-IB-MN
ZONA 11ES-GC-GC, ES-TF-TE
ZONA 12ES-GC-FU, ES-GC-LA, ES-TF-LP, ES-TF-LG, ES-TF-EH
ZONA 13PT-Madeira
ZONA 14PT-São Miguel
ZONA 16ES-GR
ZONA 17ES-GR
ZONA 21ES-J
ZONA 22ES-CO
ZONA 23ES-AB, ES-AL, ES-CR, ES-SE, ES-MA
ZONA 24ES-BA, ES-CU, ES-H, ES-MU
ZONA 25ES-A, ES-CA
ZONA 16 and ZONA 17 both list ES-GR (Granada) as their province. The engine uses ZoneRules postal code range records to decide which of the two zones applies to a given Granada postal code — postal codes 18001–18330 route to ZONA 16; all other Granada addresses resolve to ZONA 17.

Tecum ZoneRules — postal code range overrides (sample)

Postal code exceptions are stored in the ZoneRules collection, not on the zone document. Each ZoneRules record links a province, a target zone, and an array of postal code ranges. The sample below shows the Guadalajara (ES-GU) and León (ES-LE) overrides loaded by the Tecum bootstrap.
[
  { "province": "ES-GU", "zoneName": "ZONA 2", "postalCodeRanges": [
    { "from": "19261", "to": "19261" },
    { "from": "19280", "to": "19287" },
    { "from": "19300", "to": "19392" },
    { "from": "19432", "to": "19445" },
    { "from": "19460", "to": "19463" },
    { "from": "19492", "to": "19492" },
    { "from": "19495", "to": "19495" }
  ]},
  { "province": "ES-LE", "zoneName": "ZONA 6", "postalCodeRanges": [
    { "from": "24100", "to": "24114" },
    { "from": "24300", "to": "24319" },
    { "from": "24360", "to": "24380" }
  ]},
  { "province": "ES-GR", "zoneName": "ZONA 16", "postalCodeRanges": [
    { "from": "18001", "to": "18015" },
    { "from": "18100", "to": "18199" },
    { "from": "18200", "to": "18330" }
  ]}
]

Build docs developers (and LLMs) love