Categories provide the organizational structure for your product catalog and drive automatic product code generation. Every category has aDocumentation 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.
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
| Method | Path | Description | Auth required |
|---|---|---|---|
| GET | /api/categorias | List all categories for the company | Active session |
| POST | /api/categorias | Create a new category | ADMIN |
| PUT | /api/categorias/[id] | Update name and/or prefix | ADMIN |
| DELETE | /api/categorias/[id] | Delete a category (fails if products are assigned) | ADMIN |
| POST | /api/categorias/bulk-delete | Delete multiple categories at once | ADMIN |
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.Unique category identifier.
Human-readable category name. Unique within the company.
Short uppercase code used for product code generation (e.g.
"BEB"). Unique within the company.The company this category belongs to (resolved from session).
| Status | Cause |
|---|---|
401 | No active session, or user is not in ACTIVO state. |
403 | User has no company assigned. |
500 | Unexpected server error. |
POST /api/categorias
Creates a new category. Theprefijo 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.
Category name. Must be unique within the company.
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.201 Created.
Error cases
| Status | Cause |
|---|---|
400 | Missing nombre, or prefix fails the format rule (/^[A-Z0-9]{2,8}$/) when explicitly provided. |
403 | Not an ADMIN, or user has no company assigned. |
409 | A category with the same nombre or prefijo already exists in the company. |
500 | Unexpected server error. |
PUT /api/categorias/[id]
Updates thenombre 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.
The category’s numeric ID.
New category name. Must be unique within the company.
New product code prefix. 2–8 uppercase alphanumeric characters. Must be unique within the company.
| Status | Cause |
|---|---|
400 | Missing or blank fields, or invalid prefix format. |
403 | Not an ADMIN. |
404 | Category not found. |
409 | Another category already uses the same nombre or prefijo. |
500 | Unexpected 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 nullcategoriaId, which the schema does not allow.
The category’s numeric ID.
| Status | Cause |
|---|---|
400 | Category has one or more products assigned to it. |
403 | Not an ADMIN. |
404 | Category not found. |
500 | Unexpected 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.Array of category IDs to delete. Must contain at least one valid positive integer.
Number of categories deleted.
The IDs that were actually removed.
| Status | Cause |
|---|---|
400 | Empty or invalid ids array, or one or more categories have products. |
403 | Not an ADMIN. |
404 | None of the given IDs exist in the company. |
500 | Unexpected server error. |