Skip to main content
POST
/
categories
curl --request POST \
  --url https://api.example.com/categories \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "name": "Teas",
    "isActive": true
  }'
{
  "id": 1,
  "name": "Teas",
  "slug": "teas",
  "isActive": true,
  "createdAt": "2024-03-10T12:00:00.000Z"
}
Creates a new category. The slug is automatically generated from the category name.
This endpoint requires authentication with an ADMIN role.

Authentication

Requires a valid JWT token in the Authorization header:
Authorization: Bearer <token>

Body Parameters

name
string
required
Category name. Must be between 2 and 50 characters.Validation:
  • Minimum length: 2 characters
  • Maximum length: 50 characters
  • Must not be empty
  • Must be unique
isActive
boolean
Whether the category should be active. Defaults to true if not provided.

Response

data
Category
The created category object
curl --request POST \
  --url https://api.example.com/categories \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "name": "Teas",
    "isActive": true
  }'
{
  "id": 1,
  "name": "Teas",
  "slug": "teas",
  "isActive": true,
  "createdAt": "2024-03-10T12:00:00.000Z"
}

Build docs developers (and LLMs) love