Overview
The Countries API allows you to manage country (País) records in the system. Countries are the top level of the geographic hierarchy: Country → State → City.
Model Structure
Table: paises
Primary Key: id_pais
Fields
Unique identifier for the country
Country name (max 80 characters, must be unique)
Record creation timestamp
Record last update timestamp
Relationships
Collection of states/departments belonging to this country
List All Countries
Note: This endpoint is missing from the routes file. Only individual country operations are available.
To list all countries, you would need to access individual country records or implement a custom index route.
Get Single Country
curl --request GET \
--url https://api.coreprojects.com/api/paises/1 \
--header 'Authorization: Bearer YOUR_TOKEN'
200 - Success
404 - Not Found
{
"success" : true ,
"data" : {
"id_pais" : 1 ,
"nombre" : "Colombia" ,
"created_at" : "2024-01-15T10:30:00.000000Z" ,
"updated_at" : "2024-01-15T10:30:00.000000Z" ,
"departamentos" : [
{
"id_departamento" : 1 ,
"nombre" : "Cundinamarca" ,
"id_pais" : 1 ,
"created_at" : "2024-01-15T10:35:00.000000Z" ,
"updated_at" : "2024-01-15T10:35:00.000000Z" ,
"ciudades" : [
{
"id_ciudad" : 1 ,
"nombre" : "Bogotá" ,
"codigo_postal" : "110111" ,
"id_departamento" : 1 ,
"created_at" : "2024-01-15T10:40:00.000000Z" ,
"updated_at" : "2024-01-15T10:40:00.000000Z"
}
]
}
]
}
}
Endpoint
Path Parameters
The unique identifier of the country
Response Fields
Indicates if the request was successful
The country object with nested departments and cities
Create Country
curl --request POST \
--url https://api.coreprojects.com/api/paises \
--header 'Authorization: Bearer YOUR_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"nombre": "Colombia"
}'
201 - Created
422 - Validation Error
422 - Duplicate Entry
{
"success" : true ,
"message" : "País creado exitosamente" ,
"data" : {
"id_pais" : 1 ,
"nombre" : "Colombia" ,
"created_at" : "2024-01-15T10:30:00.000000Z" ,
"updated_at" : "2024-01-15T10:30:00.000000Z"
}
}
Endpoint
Body Parameters
Name of the country (max 80 characters, must be unique)
Validation Rules
nombre: Required, string, maximum 80 characters, must be unique in the system
Update Country
curl --request PUT \
--url https://api.coreprojects.com/api/paises/1 \
--header 'Authorization: Bearer YOUR_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"nombre": "República de Colombia"
}'
200 - Success
404 - Not Found
422 - Validation Error
{
"success" : true ,
"message" : "País actualizado exitosamente" ,
"data" : {
"id_pais" : 1 ,
"nombre" : "República de Colombia" ,
"created_at" : "2024-01-15T10:30:00.000000Z" ,
"updated_at" : "2024-01-15T14:20:00.000000Z"
}
}
Endpoint
Path Parameters
The unique identifier of the country to update
Body Parameters
Updated name of the country (max 80 characters, must be unique)
Delete Country
curl --request DELETE \
--url https://api.coreprojects.com/api/paises/1 \
--header 'Authorization: Bearer YOUR_TOKEN'
200 - Success
404 - Not Found
409 - Conflict
{
"success" : true ,
"message" : "País eliminado exitosamente"
}
Endpoint
Path Parameters
The unique identifier of the country to delete
Business Rules
A country cannot be deleted if it has associated departments (states). You must first delete all departments before deleting the country.
Relationships
Get States by Country
To retrieve all states/departments for a specific country, use the States API:
GET /api/paises/{id_pais}/departamentos
See the States API documentation for more details.