API Reference - Countries

Link: https://support.brilliantdirectories.com/support/solutions/articles/12000108120

← Back to API Reference | Getting Started

Countries

The Countries table is a global reference list of country codes and names used throughout the platform for member location fields, search filtering, and geographic data validation. This is a read-only reference table; while CRUD endpoints are available, typical usage is GET operations only to look up valid country codes and names.

Model name in URL: list_countries — DB table: list_countries

The Country Object

FieldTypeDescription
country_idintegerUnique country ID (primary key, read-only)
country_codestringISO 3166-1 alpha-2 country code (EG US, CA, GB); 2 characters
country_namestringFull country name (EG United States); max 255 characters
activeintegerWhether this country is active in the platform; 1 = active, 0 = inactive

List Countries

GET /api/v2/list_countries/get

Returns a paginated list of country records.

Example Request

Copy
curl -X GET "https://www.yourdomain.com/api/v2/list_countries/get?limit=25" \
  -H "X-Api-Key: your-api-key-here"

Example Response

Copy
{
  "status": "success",
  "message": [
    {
      "country_id": "1",
      "country_code": "AF",
      "country_name": "Afghanistan",
      "active": "1"
    },
    {
      "country_id": "236",
      "country_code": "US",
      "country_name": "United States",
      "active": "1"
    }
  ],
  "total": "250",
  "current_page": 1,
  "total_pages": 10,
  "next_page": "MipfKjI="
}

Retrieve a Country Record

GET /api/v2/list_countries/get/{country_id}

Example Request

Copy
curl -X GET "https://www.yourdomain.com/api/v2/list_countries/get/236" \
  -H "X-Api-Key: your-api-key-here"

Example Response

Copy
{
  "status": "success",
  "message": [
    {
      "country_id": "236",
      "country_code": "US",
      "country_name": "United States",
      "active": "1"
    }
  ],
  "total": "1",
  "current_page": 1,
  "total_pages": 1
}

Create a Country Record

POST /api/v2/list_countries/create

Creates a new country record. This endpoint is available but not typically needed as the platform ships with a complete country list.

Example Request

Copy
curl -X POST "https://www.yourdomain.com/api/v2/list_countries/create" \
  -H "X-Api-Key: your-api-key-here" \
  -d "country_code=XX" \
  -d "country_name=Example Country" \
  -d "active=1"

Example Response

Copy
{
  "status": "success",
  "message": {
    "country_id": "251",
    "country_code": "XX",
    "country_name": "Example Country",
    "active": "1"
  }
}

Update a Country Record

PUT /api/v2/list_countries/update

Example Request

Copy
curl -X PUT "https://www.yourdomain.com/api/v2/list_countries/update" \
  -H "X-Api-Key: your-api-key-here" \
  -d "country_id=251" \
  -d "active=0"

Example Response

Copy
{
  "status": "success",
  "message": {
    "country_id": "251",
    "country_code": "XX",
    "country_name": "Example Country",
    "active": "0"
  }
}

Delete a Country Record

DELETE /api/v2/list_countries/delete

Example Request

Copy
curl -X DELETE "https://www.yourdomain.com/api/v2/list_countries/delete" \
  -H "X-Api-Key: your-api-key-here" \
  -d "country_id=251"

Example Response

Copy
{
  "status": "success",
  "message": "list_countries record was deleted"
}