Retrieve the list of all states of a country
This API retrieves the list of all states of the specified country.
You must specify appropriate details for the country_id parameter in the API request.
Before you begin
- You need a valid API key or access token. See Set up API authentication.
Permission: Manage API Keys (on the Administrator security object) — Required to access Zenoti APIs.
Endpoint
GET /v1/countries/{country_id}/states
Base URL: https://api.zenoti.com
Request
Headers
| Header | Required | Description |
|---|---|---|
| Authorization | Yes | bearer {{access_token}} |
Path parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| country_id | integer (int32) | Yes | Mandatory Unique identifier of the required country for which you want to retrieve the list of states. |
Query parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| add_defaults_for_dropdown | boolean | No | false | Optional Indicates whether default state selections for the country are to be displayed in the Countries list. Default value: false. |
Response
Success (200 OK)
{}
Example
curl --request GET \
--url 'https://api.zenoti.com/v1/countries/{country_id}/states' \
--header 'Authorization: bearer {{access_token}}'
const response = await fetch('https://api.zenoti.com/v1/countries/{country_id}/states', {
method: 'GET',
headers: {
'Authorization': 'bearer {{access_token}}'
},
});
const data = await response.json();
import requests
response = requests.get(
'https://api.zenoti.com/v1/countries/{country_id}/states',
headers={
'Authorization': 'bearer {{access_token}}',
},
)
data = response.json()
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "bearer {{access_token}}");
var response = await client.GetAsync(
"https://api.zenoti.com/v1/countries/{country_id}/states");
var data = await response.Content.ReadAsStringAsync();
require 'net/http'
require 'json'
uri = URI('https://api.zenoti.com/v1/countries/{country_id}/states')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['Authorization'] = 'bearer {{access_token}}'
response = http.request(request)
data = JSON.parse(response.body)
Error codes
| Status | Description |
|---|---|
| 400 | 400 |
| 401 | Unauthorized -- invalid or expired access token |
| 429 | Too many requests -- rate limit exceeded |