Skip to content
Developer Docs

Locations

Hierarchical catalogues of countries, states, cities and postal codes to build the fiscal address.

These endpoints act as a read-only catalogue for building the fiscalAddress object of the client organisation registration request. Each level of the hierarchy resolves from the previous one: country → state → city → postal code. The codes you send in fiscalAddress.countryCode, stateCode and cityCode must come from this catalogue; otherwise, registration responds with 404.

Common conventions

  • Sandbox base URL: https://api-sandbox.zertiban.com
  • Headers required on every call:
    • Authorization: Bearer {access_token}
    • x-tenant-id: {businessUuid}

1. List countries

GET/location/v1/countries

Returns every country supported by Zertiban. No parameters.

shell
curl https://api-sandbox.zertiban.com/location/v1/countries \
  -H "Authorization: Bearer {access_token}" \
  -H "x-tenant-id: {businessUuid}"

Response (200):

json
{
  "countries": [
    { "code": "ES", "name": "Spain" },
    { "code": "PT", "name": "Portugal" }
  ]
}
FieldDescription
countries[i].codeISO 3166 alpha-2 code. This is the value you send as countryCode.
countries[i].nameCountry name.

2. States of a country

GET/location/v1/countries/{countryCode}/states

Returns the states or provinces of the given country.

Path parameters:

ParameterTypeDescription
countryCodeStringISO 3166 alpha-2 code (e.g. ES).
shell
curl https://api-sandbox.zertiban.com/location/v1/countries/ES/states \
  -H "Authorization: Bearer {access_token}" \
  -H "x-tenant-id: {businessUuid}"

Response (200):

json
{
  "states": [
    { "code": "ES-AS", "name": "Asturias" },
    { "code": "ES-MD", "name": "Madrid" }
  ]
}
FieldDescription
states[i].codeState code (ISO 3166-2). This is the value you send as stateCode.
states[i].nameState or province name.

3. Cities of a state

GET/location/v1/countries/{countryCode}/states/{stateCode}/cities

Returns the cities of the given state within the country.

Path parameters:

ParameterTypeDescription
countryCodeStringISO 3166 alpha-2 code (e.g. ES).
stateCodeStringState code (e.g. ES-AS).
shell
curl https://api-sandbox.zertiban.com/location/v1/countries/ES/states/ES-AS/cities \
  -H "Authorization: Bearer {access_token}" \
  -H "x-tenant-id: {businessUuid}"

Response (200):

json
{
  "cities": [
    { "code": "ES-AS-OV", "name": "Oviedo" },
    { "code": "ES-AS-GI", "name": "Gijón" }
  ]
}
FieldDescription
cities[i].codeCity code. This is the value you send as cityCode.
cities[i].nameCity name.

4. Postal codes of a city

GET/location/v1/countries/{countryCode}/states/{stateCode}/cities/{cityCode}/postal-codes

Returns the postal codes valid within the given city. Use it to present suggestions or to validate the postalCode that will go into fiscalAddress.

Path parameters:

ParameterTypeDescription
countryCodeStringISO 3166 alpha-2 code (e.g. ES).
stateCodeStringState code (e.g. ES-AS).
cityCodeStringCity code (e.g. ES-AS-OV).
shell
curl https://api-sandbox.zertiban.com/location/v1/countries/ES/states/ES-AS/cities/ES-AS-OV/postal-codes \
  -H "Authorization: Bearer {access_token}" \
  -H "x-tenant-id: {businessUuid}"

Response (200):

json
{
  "postalCodes": [{ "code": "33010" }, { "code": "33011" }]
}

5. Full location resolution

GET/location/v1/locations

Resolves the full location from country, state, city and postal code. Use it to validate in a single step that the combination you are about to send in fiscalAddress is consistent.

Query parameters (all required):

ParameterTypeDescription
countryStringISO 3166 alpha-2 code (e.g. ES).
state_codeStringState code (e.g. ES-AS).
city_codeStringCity code (e.g. ES-AS-OV).
postal_codeStringPostal code (e.g. 33010).
shell
curl "https://api-sandbox.zertiban.com/location/v1/locations?country=ES&state_code=ES-AS&city_code=ES-AS-OV&postal_code=33010" \
  -H "Authorization: Bearer {access_token}" \
  -H "x-tenant-id: {businessUuid}"

Response (200):

json
{
  "country": { "code": "ES", "name": "Spain" },
  "state": { "code": "ES-AS", "name": "Asturias" },
  "city": { "code": "ES-AS-OV", "name": "Oviedo" },
  "postalCode": { "code": "33010" }
}

A 404 on this call means the combination does not exist (for example, a postal code that does not belong to the city). If it happens, revalidate each level with the previous endpoints.

Summary table

MethodEndpointDescription
GET/location/v1/countriesList countries
GET/location/v1/countries/{countryCode}/statesStates of a country
GET/location/v1/countries/{countryCode}/states/{stateCode}/citiesCities of a state
GET/location/v1/countries/{countryCode}/states/{stateCode}/cities/{cityCode}/postal-codesPostal codes of a city
GET/location/v1/locations?country=&state_code=&city_code=&postal_code=Full location resolution

Common errors

CodeTypical cause
400A required parameter is missing from the full-location call.
401Expired token or invalid credentials.
403Incorrect x-tenant-id or insufficient permissions.
404The requested country / state / city / postal-code combination does not exist.