Create and update countries and regions

To add a country to Commerce, issue a POST request to the /ccadmin/v1/countries/addCountries endpoint.

You can also create the country’s regions in the same request.

The following example shows a sample request body for creating two countries (India and Sri Lanka), each with two regions.

{
    "countries": [{
            "countryCode": "IN",
            "displayName": "India",

            "regions": [{
                    "regionCode": "IN-KA",
                    "displayName": "Karnataka",
                    "abbreviation": "KA"
                },
                {
                    "regionCode": "IN-SK",
                    "displayName": "Sikkim",
                    "abbreviation": "SK"
                }
            ]
        },
        {
            "countryCode": "LK",
            "displayName": "SriLanka",
            "regions": [{
                    "regionCode": "LK-GA",
                    "displayName": "Galle",
                    "abbreviation": "GA"
                },
                {
                    "regionCode": "LK-CO",
                    "displayName": "Colombo",
                    "abbreviation": "CO"
                }
            ]
        }
    ]
}

The following example shows the response body returned:

[
  {
    "repositoryId": "IN",
    "regions": [
      {
        "regionCode": "IN-KA",
        "displayName": "Karnataka",
        "repositoryId": "IN-KA",
        "abbreviation": "KA"
      },
      {
        "regionCode": "IN-SK",
        "displayName": "Sikkim",
        "repositoryId": "IN-SK",
        "abbreviation": "SK"
      }
    ],
    "countryCode": "IN",
    "displayName": "India"
  },
  {
    "repositoryId": "LK",
    "regions": [
      {
        "regionCode": "LK-CO",
        "displayName": "Colombo",
        "repositoryId": "LK-CO",
        "abbreviation": "CO"
      },
      {
        "regionCode": "LK-GA",
        "displayName": "Galle",
        "repositoryId": "LK-GA",
        "abbreviation": "GA"
      }
    ],
    "countryCode": "LK",
    "displayName": "SriLanka"
  }
]

To add regions to an existing country, issue a PUT request to the /ccadmin/v1/countries/{id}/addRegions endpoint.

The following example shows a sample request body for creating two new regions in an existing country.

{   
    "countryCode": "IN",
    "displayName": "India",
    "regions": [
       {
            "regionCode": "IN-TG",
            "displayName": "Telangana",
            "abbreviation": "TG"
        }
    ]
}

The following example shows the response body returned:

{   
    "countryCode": "IN",
    "displayName": "India",
    "regions": [
       {
            "regionCode": "IN-TG",
            "displayName": "Telangana",
            "abbreviation": "TG"
        }
    ]
}