The Province by Postal Code endpoint resolves any valid Spanish postal code to the province it belongs to. Spanish postal codes are five digits long, and the first two digits uniquely identify the province — for example, any code beginning withDocumentation 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.
28 maps to Madrid and any code beginning with 23 maps to Jaén. Ship Quote uses this lookup internally inside POST /rates/compareByPostalCode to derive the province before querying rate tables, but the endpoint is also useful in your own UI for autocomplete flows: accept a partial postal code from the user, call this endpoint, and display the resolved province before the user submits the full shipping request.
Endpoint
Path Parameters
A five-digit Spanish postal code (e.g.
28001, 23700). Only the first two
digits are used for the province lookup — 28001, 28080, and 28950 all
resolve to Madrid. The API validates that the value is exactly five numeric
digits; any other format returns a 400 error.Common Spanish province prefixes:| Prefix | Province |
|---|---|
01 | Álava |
02 | Albacete |
08 | Barcelona |
18 | Granada |
23 | Jaén |
28 | Madrid |
41 | Sevilla |
46 | Valencia |
Response
ReturnsHTTP 200 OK with a single province object when a match is found.
MongoDB ObjectId of the province document.
Uppercased ISO-2 country code. Always
ES for the seeded dataset.Country name as stored (e.g.
Spain).Short administrative region code for the province (e.g.
J for Jaén, M
for Madrid).Fully-qualified province code (e.g.
ES-J, ES-M). Pass this value as the
province parameter when calling POST /rates/compareByProvinceCode.Display name of the province (e.g.
Jaén, Madrid).Lowercase, accent-stripped version of the province name used for internal
indexing (e.g.
jaen, madrid).The two-digit prefix used as the lookup key (e.g.
23, 28).Geographic classification. Always
province for the Spanish seed data.ISO 8601 creation timestamp.
ISO 8601 last-updated timestamp.
Examples
Jaén response
Madrid response
Error Responses
Internally,
getProvinceByPostalCode() slices the first two characters from
the supplied code and performs an O(1) lookup against an in-memory Map
that is populated at server boot. No MongoDB query is issued at request time,
making this endpoint extremely fast even under high concurrency.