Skip to main content

List All Categories

Response

categories
array
Array of category objects

Example Request

curl -X GET https://api.example.com/categoria \
  -H "Content-Type: application/json"

Example Response

[
  {
    "id": 1,
    "nombre": "Electronics",
    "estado": true,
    "fechaCreacion": "2026-03-06T10:30:00"
  },
  {
    "id": 2,
    "nombre": "Clothing",
    "estado": true,
    "fechaCreacion": "2026-03-05T14:20:00"
  }
]

Get Category by ID

Path Parameters

id
long
required
The unique identifier of the category

Response

id
long
Unique identifier for the category
nombre
string
required
Category name
estado
boolean
Category status (active/inactive)
fechaCreacion
datetime
Timestamp when the category was created

Example Request

curl -X GET https://api.example.com/categoria/1 \
  -H "Content-Type: application/json"

Example Response

{
  "id": 1,
  "nombre": "Electronics",
  "estado": true,
  "fechaCreacion": "2026-03-06T10:30:00"
}

Error Responses

  • 404 Not Found: Category with the specified ID does not exist

Create Category

Request Body

nombre
string
required
Category name (must be unique and not blank)
estado
boolean
default:"true"
Category status (active/inactive)

Response

Returns the created category object with auto-generated fields.
id
long
Auto-generated unique identifier
nombre
string
Category name
estado
boolean
Category status
fechaCreacion
datetime
Auto-generated creation timestamp

Example Request

curl -X POST https://api.example.com/categoria \
  -H "Content-Type: application/json" \
  -d '{
    "nombre": "Home & Garden",
    "estado": true
  }'

Example Response

{
  "id": 3,
  "nombre": "Home & Garden",
  "estado": true,
  "fechaCreacion": "2026-03-06T15:45:00"
}

Validation Rules

  • nombre cannot be blank (validation message: “El nombre es obligatorio”)
  • nombre must be unique across all categories

Update Category

Path Parameters

id
long
required
The unique identifier of the category to update

Request Body

nombre
string
required
Updated category name (must be unique and not blank)
estado
boolean
Updated category status

Response

Returns the updated category object.
id
long
Category identifier
nombre
string
Updated category name
estado
boolean
Updated category status
fechaCreacion
datetime
Original creation timestamp

Example Request

curl -X PUT https://api.example.com/categoria/3 \
  -H "Content-Type: application/json" \
  -d '{
    "nombre": "Home & Garden Supplies",
    "estado": true
  }'

Example Response

{
  "id": 3,
  "nombre": "Home & Garden Supplies",
  "estado": true,
  "fechaCreacion": "2026-03-06T15:45:00"
}

Error Responses

  • 404 Not Found: Category with the specified ID does not exist

Deactivate Category

Path Parameters

id
long
required
The unique identifier of the category to deactivate

Response

Returns a 204 No Content status on success.

Example Request

curl -X PUT https://api.example.com/categoria/desactivar/3 \
  -H "Content-Type: application/json"

Response

204 No Content

Delete Category

Path Parameters

id
long
required
The unique identifier of the category to delete

Response

Returns a 204 No Content status on success.

Example Request

curl -X DELETE https://api.example.com/categoria/3 \
  -H "Content-Type: application/json"

Response

204 No Content
This is a permanent deletion. Consider using the deactivate endpoint for soft deletes instead.

Build docs developers (and LLMs) love