Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/juadariasmar/inventory_project/llms.txt

Use this file to discover all available pages before exploring further.

Categories provide the organizational structure for your product catalog and drive automatic product code generation. Every category has a prefijo — a short, uppercase string of two to eight alphanumeric characters (e.g. BEB, ALI, OF01) that is unique within the company. When a product is created without an explicit code, the API generates one in the format {prefijo}-{NNN} (e.g. BEB-001, ALI-042). Updating a category’s prefix affects only future code generation — existing product codes are never renamed. Each category belongs to exactly one company tenant; the empresaId is always resolved from the authenticated session.

Endpoints

MethodPathDescriptionAuth required
GET/api/categoriasList all categories for the companyActive session
POST/api/categoriasCreate a new categoryADMIN
PUT/api/categorias/[id]Update name and/or prefixADMIN
DELETE/api/categorias/[id]Delete a category (fails if products are assigned)ADMIN
POST/api/categorias/bulk-deleteDelete multiple categories at onceADMIN

GET /api/categorias

Returns all categories that belong to the authenticated user’s company, ordered by name. The response includes the product count embedded in each category by the service layer.
curl -X GET "https://your-domain.com/api/categorias" \
  -H "Cookie: <session-cookie>"
Response Returns a JSON array of category objects. Each object contains:
id
number
Unique category identifier.
nombre
string
Human-readable category name. Unique within the company.
prefijo
string
Short uppercase code used for product code generation (e.g. "BEB"). Unique within the company.
empresaId
string
The company this category belongs to (resolved from session).
Error cases
StatusCause
401No active session, or user is not in ACTIVO state.
403User has no company assigned.
500Unexpected server error.

POST /api/categorias

Creates a new category. The prefijo must be unique across all categories in the company. Once set, the prefix is used to generate codes for any products added to this category without a manual code.
nombre
string
required
Category name. Must be unique within the company.
prefijo
string
Product code prefix. Must be 2–8 uppercase alphanumeric characters with no spaces or symbols (validated against /^[A-Z0-9]{2,8}$/). Submitted values are automatically uppercased before validation. Must be unique within the company. If omitted, a prefix is auto-generated from the category name.
curl -X POST "https://your-domain.com/api/categorias" \
  -H "Content-Type: application/json" \
  -H "Cookie: <session-cookie>" \
  -d '{
    "nombre": "Bebidas",
    "prefijo": "BEB"
  }'
Returns the created category object with HTTP 201 Created. Error cases
StatusCause
400Missing nombre, or prefix fails the format rule (/^[A-Z0-9]{2,8}$/) when explicitly provided.
403Not an ADMIN, or user has no company assigned.
409A category with the same nombre or prefijo already exists in the company.
500Unexpected server error.

PUT /api/categorias/[id]

Updates the nombre and/or prefijo of a category. Both fields are required in the request body — partial updates are not supported. The prefix change only applies to codes generated from this point forward; existing product codes that already use the old prefix are not modified.
id
number
required
The category’s numeric ID.
nombre
string
required
New category name. Must be unique within the company.
prefijo
string
required
New product code prefix. 2–8 uppercase alphanumeric characters. Must be unique within the company.
curl -X PUT "https://your-domain.com/api/categorias/5" \
  -H "Content-Type: application/json" \
  -H "Cookie: <session-cookie>" \
  -d '{
    "nombre": "Bebidas y Refrescos",
    "prefijo": "BEBR"
  }'
Returns the updated category object. Error cases
StatusCause
400Missing or blank fields, or invalid prefix format.
403Not an ADMIN.
404Category not found.
409Another category already uses the same nombre or prefijo.
500Unexpected server error.

DELETE /api/categorias/[id]

Permanently deletes a category. The operation is blocked if any products in the company are currently assigned to this category — you must reassign or delete those products first. This guard prevents orphaned products that would have a null categoriaId, which the schema does not allow.
id
number
required
The category’s numeric ID.
curl -X DELETE "https://your-domain.com/api/categorias/5" \
  -H "Cookie: <session-cookie>"
Response
{ "mensaje": "Categoría eliminada correctamente" }
Error cases
StatusCause
400Category has one or more products assigned to it.
403Not an ADMIN.
404Category not found.
500Unexpected server error.

POST /api/categorias/bulk-delete

Deletes multiple categories in one request. Like the single-delete endpoint, this operation is blocked if any of the selected categories have products assigned. All categories in the batch must be free of products, otherwise nothing is deleted.
ids
number[]
required
Array of category IDs to delete. Must contain at least one valid positive integer.
curl -X POST "https://your-domain.com/api/categorias/bulk-delete" \
  -H "Content-Type: application/json" \
  -H "Cookie: <session-cookie>" \
  -d '{ "ids": [5, 7, 9] }'
Response
eliminadas
number
Number of categories deleted.
ids
number[]
The IDs that were actually removed.
Error cases
StatusCause
400Empty or invalid ids array, or one or more categories have products.
403Not an ADMIN.
404None of the given IDs exist in the company.
500Unexpected server error.

Build docs developers (and LLMs) love