Skip to main content

Raw Materials

The Raw Materials API allows you to manage ingredients and raw materials used in product recipes. You can create, read, update, and delete raw materials, search by name, and retrieve them formatted for select dropdowns.

Endpoints

POST /api/pos/materiaprima

Create a new raw material in the system.
unidad_medida
string
required
Unit of measurement (max 10 characters)
descripcion
string
required
Raw material description (max 60 characters)
costo
number
required
Cost per unit (must be numeric)
cantidad
integer
required
Available quantity (must be integer)
prioridad
string
required
Priority level: ‘L’ (Low) or ‘F’ (Fast/High)

Response

mp_codigo
string
Generated raw material code
message
string
Success message
cURL
curl -X POST "http://localhost:3000/api/pos/materiaprima" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "unidad_medida": "KG",
    "descripcion": "Mozzarella Cheese",
    "costo": 8.50,
    "cantidad": 100,
    "prioridad": "F"
  }'
{
  "mp_codigo": "MP001",
  "message": "Materia prima creada exitosamente"
}

GET /api/pos/materiaprima

Get all raw materials with pagination.
page
number
Page number for pagination (default: 1)

Response

page
number
Current page number
limit
number
Number of items per page
count
number
Total count of raw materials
data
array
Array of raw material objects
cURL
curl -X GET "http://localhost:3000/api/pos/materiaprima?page=1" \
  -H "Authorization: Bearer YOUR_TOKEN"
{
  "page": 1,
  "limit": 20,
  "count": 75,
  "data": [
    {
      "mp_codigo": "MP001",
      "descripcion": "Mozzarella Cheese",
      "unidad_medida": "KG",
      "costo": 8.50,
      "cantidad": 100,
      "prioridad": "F"
    },
    {
      "mp_codigo": "MP002",
      "descripcion": "Tomato Sauce",
      "unidad_medida": "LT",
      "costo": 3.20,
      "cantidad": 50,
      "prioridad": "L"
    }
  ]
}

GET /api/pos/materiaprima/search

Search raw materials by description.
name
string
required
Description to search for
page
number
Page number for pagination (default: 1)

Response

page
number
Current page number
limit
number
Number of items per page
count
number
Total count of matching raw materials
data
array
Array of matching raw material objects
cURL
curl -X GET "http://localhost:3000/api/pos/materiaprima/search?name=Cheese&page=1" \
  -H "Authorization: Bearer YOUR_TOKEN"
{
  "page": 1,
  "limit": 20,
  "count": 3,
  "data": [
    {
      "mp_codigo": "MP001",
      "descripcion": "Mozzarella Cheese",
      "unidad_medida": "KG",
      "costo": 8.50,
      "cantidad": 100
    }
  ]
}

GET /api/pos/materiaprima/type

Get raw materials formatted for select dropdowns.

Response

data
array
Array of simplified raw material objects for dropdowns
cURL
curl -X GET "http://localhost:3000/api/pos/materiaprima/type" \
  -H "Authorization: Bearer YOUR_TOKEN"
[
  {
    "value": "MP001",
    "label": "Mozzarella Cheese (KG)"
  },
  {
    "value": "MP002",
    "label": "Tomato Sauce (LT)"
  }
]

GET /api/pos/materiaprima/:id

Get a specific raw material by ID.
id
string
required
Raw material code/ID

Response

raw_material
object
Raw material object with all details
cURL
curl -X GET "http://localhost:3000/api/pos/materiaprima/MP001" \
  -H "Authorization: Bearer YOUR_TOKEN"
{
  "mp_codigo": "MP001",
  "descripcion": "Mozzarella Cheese",
  "unidad_medida": "KG",
  "costo": 8.50,
  "cantidad": 100,
  "prioridad": "F"
}

PUT /api/pos/materiaprima/:id

Update an existing raw material.
id
string
required
Raw material code/ID to update
unidad_medida
string
Unit of measurement (max 10 characters)
descripcion
string
Raw material description (max 60 characters)
costo
number
Cost per unit (must be numeric)
cantidad
integer
Available quantity (must be integer)
prioridad
string
Priority level: ‘L’ (Low) or ‘F’ (Fast/High)

Response

message
string
Success message
cURL
curl -X PUT "http://localhost:3000/api/pos/materiaprima/MP001" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "costo": 9.00,
    "cantidad": 150
  }'
{
  "message": "Materia prima actualizada exitosamente"
}

DELETE /api/pos/materiaprima/:id

Delete a raw material by ID.
id
string
required
Raw material code/ID to delete

Response

Returns 204 No Content on success.
cURL
curl -X DELETE "http://localhost:3000/api/pos/materiaprima/MP001" \
  -H "Authorization: Bearer YOUR_TOKEN"

Build docs developers (and LLMs) love