Skip to main content
POST
/
categories
Create Category
curl --request POST \
  --url https://api.example.com/categories \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>"
}
'
{
  "error": false,
  "msg": "categorie was created sucessfully"
}

Endpoint

POST /categories
Creates a new category in the system. The category name must be unique and meet the validation requirements.

Request Body

name
string
required
The name of the category to create.Validation Rules:
  • Minimum length: 3 characters
  • Must be a string
  • Must be unique (cannot already exist)

Request Example

{
  "name": "bebidas"
}

Response

error
boolean
Indicates whether an error occurred during the request.
msg
string
A message describing the result of the operation.

Success Response

{
  "error": false,
  "msg": "categorie was created sucessfully"
}

Error Responses

Empty Request Body (400)

Returned when no request body is provided.
{
  "error": true,
  "msg": "request body is empty"
}

Invalid Category Name (400)

Returned when the category name doesn’t meet validation requirements (less than 3 characters).
{
  "error": true,
  "msg": "categorie name is invalid"
}

Duplicate Category Name (409)

Returned when a category with the same name already exists in the system.
{
  "error": true,
  "msg": "categorie name exist"
}

Build docs developers (and LLMs) love