> 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/countries/deactivate-a-country.md).

# Deactivate a country

**Soft-deletes** the country by setting `is_active` to `false`. The record is not removed from the database.

Deactivated countries are excluded from storefront address forms. A country can be reactivated at any time with `PATCH /countries/{id}/` sending `{"is_active": true}`.

```json
{"openapi":"3.1.0","info":{"title":"Admin API","version":"1.0.0"},"tags":[{"name":"Countries","description":"Administrative endpoints for **countries** — the country records used as the geographic reference for addresses, cities, townships, and retail stores.\n\nA country consists of a display name, a unique country code, an active/inactive status, and optional multilingual translations of the name.\n\n## Core Capabilities\n\n**1. Country Listing & Filtering**\n* Retrieve a paginated list of all countries (active and inactive), ordered by name ascending.\n* Filter by `name` (case-insensitive contains), `code` (case-insensitive exact), or the active status of associated retail stores.\n* Order results with the `sort` parameter.\n\n**2. Country Lifecycle Management**\n* Create a country with a unique code and display name.\n* Fully or partially update an existing country.\n* Deactivate a country (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## Country Fields\n\n| Field | Type | Description |\n|-------|------|-------------|\n| `pk` | integer | The unique identifier of the country. Assigned by the server; read-only. |\n| `is_active` | boolean | Whether the country is active. Inactive countries are excluded from storefront address lookups. |\n| `name` | string | The display name of the country. Required on create and full update. |\n| `code` | string (max 3 chars) | The unique country code (e.g. `TR`, `US`). Required on create and full update. Must be unique across all countries (case-sensitive). |\n| `translations` | object or `null` | A mapping of language codes to translated field values. Example: `{\"tr\": {\"name\": \"Türkiye\"}, \"en\": {\"name\": \"Turkey\"}}`. Optional; defaults to `{}`. |\n\n## Filtering & Ordering\n\n| Parameter | Match | Notes |\n|-----------|-------|-------|\n| `name` | Case-insensitive contains | `?name=turkey` matches `Turkey`, `?name=urk` also matches `Turkey`. |\n| `code` | Exact, case-insensitive | `?code=tr` and `?code=TR` return the same record. |\n| `retailstore__is_active` | Boolean | Filters to countries that have at least one retail store whose `is_active` matches this value. |\n\nResults are ordered by `name` ascending by default. Use the `sort` query parameter to change the order on `pk`, `name`, `code`, or `is_active`; prefix with `-` for descending (e.g. `?sort=-pk`).\n\n## Soft Delete\n\nCalling `DELETE /countries/{id}/` does **not** remove the record from the database. It sets `is_active` to `false`, which hides the country from storefront address forms. The record can be reactivated at any time with `PATCH /countries/{id}/` sending `{\"is_active\": true}`.\n\n## Dynamic Settings & Environment Variables\n\nNo dynamic settings (`dj_dynamic_settings`) are read directly by the country 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."}},"responses":{"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"}}}},"CountryNotFound":{"description":"The requested country does not exist.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"schemas":{"Error":{"type":"object","description":"An error response.","properties":{"detail":{"type":"string","description":"A human-readable description of the error."}},"additionalProperties":true}}},"paths":{"/countries/{id}/":{"delete":{"tags":["Countries"],"operationId":"deleteCountry","summary":"Deactivate a country","description":"**Soft-deletes** the country by setting `is_active` to `false`. The record is not removed from the database.\n\nDeactivated countries are excluded from storefront address forms. A country can be reactivated at any time with `PATCH /countries/{id}/` sending `{\"is_active\": true}`.","responses":{"204":{"description":"The country was deactivated successfully. No response body."},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/CountryNotFound"}}}}}}
```


---

# 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/countries/deactivate-a-country.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.
