What is ISO 3166?
ISO 3166 is an international standard for country codes and their subdivisions (states, provinces, regions, etc.). The Address API uses this data to standardize address components when Google’s Geocoding API returns local variants or subdivision names instead of ISO 3166 codes.Why is this needed?
Google’s Geocoding API sometimes returns state information in different formats:- ISO 3166 code (e.g., “CA” for California)
- Full subdivision name (e.g., “California”)
- Local language variant (e.g., “Québec” instead of “QC”)
Endpoint
MANAGE_CONTENT
Request
Headers
| Header | Required | Description |
|---|---|---|
x-commenda-key | Yes | Your API key with MANAGE_CONTENT role |
Content-Type | Yes | Must be application/json |
Body
| Field | Type | Required | Description |
|---|---|---|---|
items | array | Yes | Array of subdivision records to ingest (minimum 1 item) |
items[].country_code | string | Yes | ISO 3166-1 alpha-2 country code (exactly 2 characters) |
items[].subdivision_code | string | Yes | ISO 3166-2 subdivision code (maximum 3 characters) |
items[].subdivision_name | string | null | Yes | Full name of the subdivision (can be null) |
items[].subdivision_local_variant | string | null | Yes | Local language variant of the name (can be null) |
Response
Success response (200 OK)
| Field | Type | Description |
|---|---|---|
upserted | number | Number of records inserted or updated |
How ingestion works
The ingestion process uses an upsert strategy:- Uniqueness: Each record is identified by the combination of
country_codeandsubdivision_code - Insert or update: If a record with the same country/subdivision combination exists, it’s updated. Otherwise, a new record is created
- Duplicate detection: The API validates that no duplicates exist within a single request
- Batch processing: All items in the request are processed in a single transaction
- Validation: Each item is validated for required fields and format constraints
Example requests
Ingest US states
Ingest Canadian provinces
Error responses
Invalid request body (400)
Duplicate records (400)
Missing API key (401)
Missing role (403)
Database schema
The ISO 3166 data is stored in theiso_3166 table:
Best practices
- Batch your requests: Send multiple items in a single request to reduce API calls
- Validate data: Ensure country codes are valid ISO 3166-1 alpha-2 codes
- Handle errors: Check for duplicate records and validation errors in your ingestion pipeline
- Update regularly: Re-run ingestion when subdivision data changes (new states, name changes, etc.)
- Use upsert behavior: Don’t worry about duplicates - the API will update existing records