list-country-states
Method: GET
Path: /common/countries/{country_iso_code}/states
Tags: Locations
Summary
Retrieve country wise states
Storefront SDK Usage
SDK Method: sdk.helpers.listCountryStates()
Example:
typescript
const { data, error } = await sdk.helpers.listCountryStates({
country_iso_code: "IN"
});
if (error) {
console.error("Failed to get states:", error);
return;
}
console.log("States found:", data.states?.length || 0);
data.states?.forEach(state => {
console.log(`State: ${state.name} (${state.iso_code})`);
});
// Get states for different country
const { data: usStates, error: usError } = await sdk.helpers.listCountryStates({
country_iso_code: "US"
});
if (usError) {
console.error("Failed to get US states:", usError);
return;
}
console.log("US States:", usStates.states?.map(s => s.name).join(", "));TypeScript Definition
typescript
"list-country-states": {
parameters: {
query?: never;
header?: never;
path: {
/** @description ISO 3166-1 alpha-2 country code (e.g., `IN` for India). */
country_iso_code: string;
};
cookie?: never;
};
requestBody?: never;
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": {
message: string;
success: boolean;
content: {
states: components["schemas"]["CountryState"][];
};
};
};
};
400: components["responses"]["BadRequest"];
401: components["responses"]["Unauthorized"];
403: components["responses"]["Forbidden"];
500: components["responses"]["InternalServerError"];
504: components["responses"]["GatewayTimeout"];
};
};Component References
| Reference | Resolves To |
|---|---|
components["schemas"]["CountryState"] | CountryState |
components["responses"]["BadRequest"] | BadRequest |
components["responses"]["Unauthorized"] | Unauthorized |
components["responses"]["Forbidden"] | Forbidden |
components["responses"]["InternalServerError"] | InternalServerError |
components["responses"]["GatewayTimeout"] | GatewayTimeout |
Parameters
- country_iso_code (path): ISO 3166-1 alpha-2 country code (e.g.,
INfor India).
Responses
200
OK
400
Bad request
401
Authentication failed. Codes include token-required, token-expired and token_not_valid for an invalid or expired token.
403
Access denied. token-required requires an authenticated session; permission-denied means the caller cannot access this resource. On POS, session-expired requires signing in again.
500
The request failed because of an unexpected error.
504
The request timed out.
OpenAPI Definition
json
{
"tags": [
"Locations"
],
"operationId": "list-country-states",
"summary": "Retrieve country wise states",
"externalDocs": {
"url": "https://llm-docs.commercengine.io/storefront/operations/list-country-states",
"description": "API reference for the list-country-states operation"
},
"parameters": [
{
"name": "country_iso_code",
"in": "path",
"description": "ISO 3166-1 alpha-2 country code (e.g., `IN` for India).",
"required": true,
"schema": {
"type": "string",
"maxLength": 2,
"minLength": 2,
"pattern": "^[A-Z]{2}$"
}
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"message",
"success",
"content"
],
"properties": {
"message": {
"type": "string"
},
"success": {
"type": "boolean"
},
"content": {
"properties": {
"states": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CountryState"
}
}
},
"required": [
"states"
],
"type": "object"
}
}
}
}
}
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"403": {
"$ref": "#/components/responses/Forbidden"
},
"500": {
"$ref": "#/components/responses/InternalServerError"
},
"504": {
"$ref": "#/components/responses/GatewayTimeout"
}
},
"security": [
{
"Authorization": []
},
{
"X-Api-Key": []
}
],
"x-speakeasy-group": "common",
"x-speakeasy-ignore": true,
"x-speakeasy-name-override": "listCountryStates"
}Auto-generated from OpenAPI spec and TypeScript definitions