Country
Standardized country codes and names following ISO 3166-1 alpha-2 standard for international country identification.
The ref_country Object
Country collection stores standardized country codes and their corresponding full names for international identification and localization.
| Field Name | Type | Description |
|---|---|---|
code | string | Primary key. ISO 3166-1 alpha-2 country code (e.g., "US", "GB", "DE"). |
user_created | object | User who created the country record. Read-only. Links to directus_users. |
date_created | datetime | Timestamp in ISO 8601 when the country record was created. Read-only. |
user_updated | object | User who last updated the country record. Read-only. Links to directus_users. |
date_updated | datetime | Timestamp in ISO 8601 when the country record was last updated. Read-only. |
country_name | string | Full official country name. |
List Countries
List existing countries.
- REST
- GraphQL
GET /items/ref_country
query {
ref_country {
code
country_name
date_created
date_updated
}
}
Query Parameters
Supports all global query parameters.
Returns
An array of up to limit country objects. If no items are available, data will be an empty array.
Retrieve a Country
Retrieve a specific country by code.
- REST
- GraphQL
GET /items/ref_country/:code
query {
ref_country_by_id(id: "country_code") {
code
country_name
user_created {
id
first_name
last_name
}
date_created
user_updated {
id
first_name
last_name
}
date_updated
}
}
Returns
Returns a country object if a valid country code was provided.
Create a Country
Create a new country.
- REST
- GraphQL
POST /items/ref_country
{
"code": "XX",
"country_name": "Example Country"
}
mutation {
create_ref_country_item(data: {
code: "XX"
country_name: "Example Country"
}) {
code
country_name
}
}
Query Parameters
Supports all global query parameters.
Request Body
A partial country object.
Returns
Returns the country object for the created country.
Update a Country
Update an existing country.
- REST
- GraphQL
PATCH /items/ref_country/:code
{
"country_name": "Updated Country Name"
}
mutation {
update_ref_country_item(id: "country_code", data: {
country_name: "Updated Country Name"
}) {
code
country_name
}
}
Query Parameters
Supports all global query parameters.
Request Body
A partial country object.
Returns
Returns the country object for the updated country.
Delete a Country
Delete an existing country.
- REST
- GraphQL
DELETE /items/ref_country/:code
mutation {
delete_ref_country_item(id: "country_code") {
code
}
}
Returns
Empty body.
Sample Data
| Code | Country Name |
|---|---|
| AD | Andorra |
| AE | United Arab Emirates |
| AF | Afghanistan |
| AG | Antigua and Barbuda |
| AI | Anguilla |