> For the complete documentation index, see [llms.txt](https://apidocs.akinon.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://apidocs.akinon.com/commerce-openapis/admin/cities/list-cities.md).

# List cities

Returns a paginated list of cities ordered by priority ascending, then name ascending.

Unlike the storefront endpoint, this admin endpoint returns **all** cities regardless of their `is_active` status.

Filter by `country`, `country__code`, `name`, `name_startswith`, `retailstore__isnull`, `retailstore__is_active`, or `store_type`. Order results with `sort`.

```json
{"openapi":"3.1.0","info":{"title":"Admin API","version":"1.0.0"},"tags":[{"name":"Cities","description":"Administrative endpoints for **cities** — the city records used as the second level of the address hierarchy (Country → City → Township → District).\n\nA city belongs to a single country and consists of a display name, an active/inactive status, an optional sort priority, an optional post/zip code, and optional multilingual translations of the name.\n\n## Core Capabilities\n\n**1. City Listing & Filtering**\n* Retrieve a paginated list of all cities (active and inactive), ordered by priority ascending, then name ascending.\n* Filter by country, country code, name (exact or starts-with prefix), presence of a retail store, retail store active status, or retail store type.\n* Order results with the `sort` parameter.\n\n**2. City Lifecycle Management**\n* Create a city under a country with a unique name within that country.\n* Fully or partially update an existing city, including its translations.\n* Deactivate a city (soft delete — sets `is_active` to `false`; the record is not removed).\n\n**3. Multilingual Names**\n* Store translated names under the `translations` field, keyed by language code.\n\n## City Fields\n\n| Field | Type | Description |\n|-------|------|-------------|\n| `pk` | integer | The unique identifier of the city. Assigned by the server; read-only. |\n| `is_active` | boolean | Whether the city is active. |\n| `name` | string (max 128 chars) | The display name of the city. Required on create and full update. |\n| `country` | integer | The identifier of the country this city belongs to. Required on create and full update. |\n| `priority` | integer or `null` | The sort priority of the city. Lower values appear first; `null` sorts after all numbered priorities. Optional. |\n| `postcode` | string or `null` | The post/zip code associated with the city. Optional. |\n| `translations` | object or `null` | A mapping of language codes to translated field values. Example: `{\"tr\": {\"name\": \"İstanbul\"}}`. Optional; defaults to `{}`. |\n\n## Filtering & Ordering\n\n| Parameter | Match | Notes |\n|-----------|-------|-------|\n| `name` | Exact | Case-sensitive exact match on the city name. |\n| `name_startswith` | Case-insensitive prefix | `?name_startswith=ist` matches `Istanbul`. |\n| `country` | Exact (integer) | Keeps only cities belonging to the given country id. |\n| `country__code` | Exact, case-insensitive | `?country__code=tr` and `?country__code=TR` return the same cities. |\n| `retailstore__isnull` | Boolean | `false` keeps only cities that have at least one retail store (via their townships); `true` keeps only cities with no retail store. |\n| `retailstore__is_active` | Boolean | Filters by the `is_active` status of retail stores linked through townships. |\n| `store_type` | Exact, case-sensitive | Keeps only cities whose retail stores (via townships) have the given store type name. |\n\nResults are ordered by `priority` ascending first, then `name` ascending. Use the `sort` query parameter to change the order; prefix with `-` for descending (e.g. `?sort=-pk`).\n\n## Validation Rules\n\n* `name` and `country` are required on create and full update.\n* The combination of `country` and `name` must be unique **at the application layer** (there is no database-level unique constraint). A duplicate is rejected with `406 Not Acceptable` carrying `{\"non_field_errors\": \"<message>\", \"error_code\": \"<code>\"}`. This check applies to **create** (`POST`) and **update** (`PUT`/`PATCH`).\n\n## Soft Delete\n\nCalling `DELETE /cities/{id}/` does **not** remove the record from the database. It sets `is_active` to `false`. The record can be reactivated at any time with `PATCH /cities/{id}/` sending `{\"is_active\": true}`.\n\n## Dynamic Settings & Environment Variables\n\nNo dynamic settings (`dj_dynamic_settings`) are read directly by the city endpoints. Listing, create, update, and deactivate operations behave identically regardless of management panel configuration.\n\nThe `DEFAULT_COUNTRY_CODE` dynamic setting — registered in `omnishop/address/settings/conf.py` — identifies which country is used as the default in address forms and checkout flows, but it is consumed by the address and checkout services, not by these administrative endpoints.\n\n**Environment variables:** No environment variables are read directly by these endpoints."}],"servers":[{"description":"Omnitron Remote Proxy (external access — recommended)","url":"https://{omnitron_url}/api/v1/remote/{channel_id}","variables":{"omnitron_url":{"default":"sandbox.akinon.com","description":"Omnitron server URL (e.g., {omnitron.akinon.com})"},"channel_id":{"default":"1","description":"The channel identifier the remote request is routed through"}}},{"description":"Commerce API Server (internal / direct access only)","url":"https://{commerce_url}/api/v1","variables":{"commerce_url":{"default":"sandbox.akinon.com","description":"Internal commerce server URL, reachable only from within the Omnitron network"}}}],"security":[{"tokenAuth":[]}],"components":{"securitySchemes":{"tokenAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"Token credential sent in the Authorization header, in the form: `Token <your-token>`. Requires a staff (admin) account."}},"parameters":{"page":{"name":"page","in":"query","required":false,"description":"The page number to return.","schema":{"type":"integer","default":1}},"limit":{"name":"limit","in":"query","required":false,"description":"The number of items to return per page.","schema":{"type":"integer","default":10}},"sort":{"name":"sort","in":"query","required":false,"description":"Orders the results by one or more fields. Separate multiple fields with commas. Prefix a field with a hyphen (`-`) for descending order.","schema":{"type":"string"}}},"schemas":{"PaginatedCityList":{"type":"object","description":"A paginated list of cities.","properties":{"count":{"type":"integer","description":"Total number of cities matching the request."},"next":{"type":["string","null"],"format":"uri","description":"URL of the next page, or `null` if this is the last page."},"previous":{"type":["string","null"],"format":"uri","description":"URL of the previous page, or `null` if this is the first page."},"results":{"type":"array","description":"The cities on the current page.","items":{"$ref":"#/components/schemas/City"}}}},"City":{"type":"object","description":"A city record.","properties":{"pk":{"type":"integer","readOnly":true,"description":"The unique identifier of the city."},"is_active":{"type":"boolean","description":"Whether the city is active. Inactive cities are excluded from storefront address lookups."},"name":{"type":"string","maxLength":128,"description":"The display name of the city."},"country":{"type":"integer","description":"The identifier of the country this city belongs to."},"priority":{"type":["integer","null"],"description":"The sort priority of the city. Lower values appear first; `null` sorts after all numbered priorities."},"postcode":{"type":["string","null"],"maxLength":255,"description":"The post/zip code associated with the city."},"translations":{"type":["object","null"],"description":"A mapping of language codes to translated field values. Example: `{\"tr\": {\"name\": \"İstanbul\"}}`.","additionalProperties":{"type":"object","additionalProperties":{"type":"string"}},"default":{}}}},"ValidationError":{"type":"object","description":"Returned when the request contains invalid or missing data. Errors are grouped by the field they apply to: each key is the name of a field from the request and its value is a list of one or more messages describing what is wrong with that field. Messages that do not belong to any single field are grouped under `non_field_errors`.","properties":{"non_field_errors":{"type":"array","description":"Error messages that apply to the request as a whole rather than to a specific field.","items":{"type":"string"}}},"additionalProperties":{"type":"array","description":"The list of error messages for the field named by the key.","items":{"type":"string"}}},"Error":{"type":"object","description":"An error response.","properties":{"detail":{"type":"string","description":"A human-readable description of the error."}},"additionalProperties":true}},"responses":{"ValidationError":{"description":"The request contains invalid or missing data.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationError"}}}},"Unauthorized":{"description":"Authentication credentials were not provided or are invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Forbidden":{"description":"The authenticated user does not have administrator privileges.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"CityPageNotFound":{"description":"The requested page of the city list does not exist — the page number is beyond the last page or is not a number.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/cities/":{"get":{"tags":["Cities"],"operationId":"listCities","summary":"List cities","description":"Returns a paginated list of cities ordered by priority ascending, then name ascending.\n\nUnlike the storefront endpoint, this admin endpoint returns **all** cities regardless of their `is_active` status.\n\nFilter by `country`, `country__code`, `name`, `name_startswith`, `retailstore__isnull`, `retailstore__is_active`, or `store_type`. Order results with `sort`.","parameters":[{"$ref":"#/components/parameters/page"},{"$ref":"#/components/parameters/limit"},{"$ref":"#/components/parameters/sort"},{"name":"name","in":"query","description":"Filter by name. Case-sensitive exact match.","required":false,"schema":{"type":"string"}},{"name":"country","in":"query","description":"Filter by country identifier. Keeps only cities belonging to the given country.","required":false,"schema":{"type":"integer"}},{"name":"country__code","in":"query","description":"Filter by country code. Case-insensitive exact match.","required":false,"schema":{"type":"string"}},{"name":"name_startswith","in":"query","description":"Filter by name prefix. Case-insensitive starts-with match — `?name_startswith=ist` matches `Istanbul`.","required":false,"schema":{"type":"string"}},{"name":"retailstore__isnull","in":"query","description":"Filter by retail store presence (via townships). `false` keeps only cities that have at least one retail store; `true` keeps only cities with no retail store.","required":false,"schema":{"type":"boolean"}},{"name":"retailstore__is_active","in":"query","description":"Filter by the active status of retail stores linked through townships.","required":false,"schema":{"type":"boolean"}},{"name":"store_type","in":"query","description":"Filter by retail store type name. Case-sensitive exact match. Keeps only cities whose retail stores (via townships) have the given store type name.","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"A page of cities.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedCityList"}}}},"400":{"$ref":"#/components/responses/ValidationError"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/CityPageNotFound"}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://apidocs.akinon.com/commerce-openapis/admin/cities/list-cities.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
