Address Formats

For endpoints returning a country object, we return an 'addressing' attribute, which contains useful information about the specific country and how they format addresses.

It will contain the following:

  • labels: English text for different fields, such as Postal Code vs ZIP Code
  • zip_regex: Regex for validation of ZIP Codes (might return null)
  • zip_examples An array of ZIP Code examples (might be empty)
  • fields: contains two attributes, available and required.
    • available lists all fields which the country uses for address inputs. Can be null for some countries, meaning we have no data.
    • required lists all fields that are required to fill out for the country. Can be null for some countries, meaning we have no data.

country not included as an option in field, but you might still want to include it in UIs etc.

The fields.required array might not contain name, as it technically depends on the recipient, but it is generally adviced to have the field visible regardless.

By using fields.available, you can display certain fields conditionally, for example not all countries use "state" for shipping. It also orders by which field to show first in the UI.

labels has 4 attributes: state, zip, city, district. Each with an english translation. You can use that to switch the text on the input labels, for example from ZIP Code to Postal Code.