Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Eleazarguitar18/kantuta_pos_back/llms.txt

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

The Categories resource (/inventario/categorias) lets you organise your inventory into named groups. Every Producto belongs to exactly one Categoria, so categories must exist before products can be created. All write operations are audited — the API records which user created or last updated each record via id_user_create / id_user_update. Deletion is always a soft delete: the record remains in the database with estado set to false, preserving referential integrity with linked products.
All endpoints in this section require a valid JWT access token. Include it as Authorization: Bearer <access_token> on every request.

The Categoria object

interface Categoria extends BaseEntityAudit {
  id: number;
  nombre: string;
  productos?: Producto[];
}

// BaseEntityAudit fields included on every Categoria response:
interface BaseEntityAudit {
  estado: boolean;        // false when soft-deleted
  id_user_create: number;
  id_user_update?: number;
  created_at: string;     // ISO 8601 timestamp
  updated_at: string;     // ISO 8601 timestamp
}
id
number
Auto-incremented primary key.
nombre
string
Unique display name of the category (max 100 characters).
estado
boolean
true while the category is active. Set to false by a soft delete.
id_user_create
number
ID of the user who created this record.
id_user_update
number | undefined
ID of the user who last updated this record.
created_at
string
ISO 8601 timestamp of record creation.
updated_at
string
ISO 8601 timestamp of the last update.
productos
Producto[]
Products linked to this category. Only included when the relation is eagerly loaded by the service.

Endpoints

Create a category

POST /inventario/categorias Creates a new inventory category. The nombre field must be unique across all categories — attempting to insert a duplicate name returns a database constraint error.

Request body

nombre
string
required
The category name. Must be a non-empty string of at most 100 characters. Must be unique.
id_user_create
number
required
Numeric ID of the authenticated user performing the creation. Stored for audit purposes.

Example

curl -X POST https://api.example.com/inventario/categorias \
  -H "Authorization: Bearer <access_token>" \
  -H "Content-Type: application/json" \
  -d '{
    "nombre": "Accesorios",
    "id_user_create": 1
  }'

Response 200 OK

{
  "id": 3,
  "nombre": "Accesorios",
  "estado": true,
  "id_user_create": 1,
  "id_user_update": null,
  "created_at": "2025-01-15T10:30:00.000Z",
  "updated_at": "2025-01-15T10:30:00.000Z"
}

List all active categories

GET /inventario/categorias Returns an array of all categories whose estado is true. Soft-deleted categories (estado = false) are automatically filtered out and will never appear in this list.
Inactive (soft-deleted) categories are excluded from this response. To inspect a deleted category you must query it directly by ID.

Example

curl -X GET https://api.example.com/inventario/categorias \
  -H "Authorization: Bearer <access_token>"

Response 200 OK

[
  {
    "id": 1,
    "nombre": "Cargadores",
    "estado": true,
    "id_user_create": 1,
    "id_user_update": null,
    "created_at": "2025-01-10T08:00:00.000Z",
    "updated_at": "2025-01-10T08:00:00.000Z"
  },
  {
    "id": 3,
    "nombre": "Accesorios",
    "estado": true,
    "id_user_create": 1,
    "id_user_update": null,
    "created_at": "2025-01-15T10:30:00.000Z",
    "updated_at": "2025-01-15T10:30:00.000Z"
  }
]

Get a category by ID

GET /inventario/categorias/:id Retrieves a single category by its numeric primary key, regardless of its estado. Use this endpoint to inspect soft-deleted categories.

Path parameters

id
number
required
The numeric primary key of the category.

Example

curl -X GET https://api.example.com/inventario/categorias/3 \
  -H "Authorization: Bearer <access_token>"

Response 200 OK

{
  "id": 3,
  "nombre": "Accesorios",
  "estado": true,
  "id_user_create": 1,
  "id_user_update": null,
  "created_at": "2025-01-15T10:30:00.000Z",
  "updated_at": "2025-01-15T10:30:00.000Z"
}

Update a category

PATCH /inventario/categorias/:id Partially updates an existing category. All body fields are optional — supply only the fields you want to change. The updated_at timestamp is refreshed automatically.

Path parameters

id
number
required
The numeric primary key of the category to update.

Request body

nombre
string
New category name (max 100 characters). Must remain unique if changed.
id_user_update
number
Numeric ID of the authenticated user performing the update. Stored for audit purposes.

Example

curl -X PATCH https://api.example.com/inventario/categorias/3 \
  -H "Authorization: Bearer <access_token>" \
  -H "Content-Type: application/json" \
  -d '{
    "nombre": "Accesorios Premium",
    "id_user_update": 2
  }'

Response 200 OK

{
  "id": 3,
  "nombre": "Accesorios Premium",
  "estado": true,
  "id_user_create": 1,
  "id_user_update": 2,
  "created_at": "2025-01-15T10:30:00.000Z",
  "updated_at": "2025-01-15T14:05:00.000Z"
}

Delete a category (soft delete)

DELETE /inventario/categorias/:id Soft-deletes a category by setting its estado field to false. The record is not physically removed from the database. The category will no longer appear in GET /inventario/categorias responses, but it remains accessible by ID and continues to satisfy any existing foreign-key relationships.
Soft-deleting a category that still has active products linked to it will hide the category from listings but the products themselves are unaffected. Consider reassigning or soft-deleting associated products before deactivating a category.

Path parameters

id
number
required
The numeric primary key of the category to soft-delete.

Example

curl -X DELETE https://api.example.com/inventario/categorias/3 \
  -H "Authorization: Bearer <access_token>"

Response 200 OK

Returns an empty body with HTTP status 200.

Build docs developers (and LLMs) love