Skip to main content

Overview

The Inventory API provides comprehensive inventory and materials management including stock tracking, requisitions, material catalog, and warehouse operations. Base Path: /inventarios/

List Materials

Retrieve materials with pagination and filtering.
GET /inventarios/api/materials/
q
string
Search query to match against name, SKU, or description
category
integer
Filter by category ID
ubicacion
integer
Filter by warehouse location ID (only shows materials with stock in that location)
page
integer
default:"1"
Page number for pagination

Response

results
array
Array of material objects (24 per page)
has_next
boolean
Whether there are more pages
num_pages
integer
Total number of pages
current_page
integer
Current page number
fetch('/inventarios/api/materials/?q=bearing&category=5&page=1', {
  credentials: 'same-origin'
})
.then(res => res.json())
.then(data => console.log(data));

List Categories

Retrieve material categories in hierarchical tree structure.
GET /inventarios/api/categories/

Response

results
array
Array of category nodes in tree structure
fetch('/inventarios/api/categories/', {
  credentials: 'same-origin'
})
.then(res => res.json())
.then(data => console.log(data.results));

Material Details

Get Material Stock

Retrieve stock information for a specific material.
GET /inventarios/api/stock/{material_id}/
material_id
integer
required
Material ID

Response

material_id
integer
Material ID
nombre
string
Material name
sku
string
SKU code
stock_total
float
Total stock across all locations
ubicaciones
array
Stock by location
precio_estimado
float
Estimated unit price
unidad_medida
string
Unit of measure

Get Material by SKU

Search for a material by its SKU code (for barcode scanner).
GET /inventarios/api/sku/?sku={sku_code}
sku
string
required
SKU code to search

Response

found
boolean
Whether material was found
material
object
Material details (if found)
fetch('/inventarios/api/sku/?sku=BRG-6205-2RS', {
  credentials: 'same-origin'
})
.then(res => res.json())
.then(data => {
  if (data.found) {
    console.log('Material found:', data.material);
  }
});

Shopping Cart

Add to Cart

Add materials to the requisition cart.
POST /inventarios/cart/add/
material_id
integer
required
Material ID to add
cantidad
float
required
Quantity to request
ubicacion_id
integer
Preferred warehouse location
nota
string
Optional note for this item

Response

status
string
“success” or “error”
message
string
Status message
cart_count
integer
Total items in cart
fetch('/inventarios/cart/add/', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-CSRFToken': csrfToken
  },
  credentials: 'same-origin',
  body: JSON.stringify({
    material_id: 234,
    cantidad: 2,
    nota: 'For pump P-101 maintenance'
  })
});

Remove from Cart

Remove a material from the cart.
POST /inventarios/cart/remove/{material_id}/
material_id
integer
required
Material ID to remove

Get Cart Details

Retrieve current cart contents.
GET /inventarios/cart/detail/

Response

items
array
Array of cart items
total
float
Cart total value

Submit Cart (Checkout)

Create a requisition from cart items.
POST /inventarios/cart/checkout/
justificacion
string
required
Requisition justification/reason
prioridad
string
default:"NORMAL"
Priority level: BAJA, NORMAL, ALTA, URGENTE
fecha_requerida
string
Required date (YYYY-MM-DD)
proyecto_id
integer
Associated project ID
ot_id
integer
Associated work order ID

Response

status
string
“success” or “error”
solicitud_id
integer
Created requisition ID
mensaje
string
Status message
fetch('/inventarios/cart/checkout/', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-CSRFToken': csrfToken
  },
  credentials: 'same-origin',
  body: JSON.stringify({
    justificacion: 'Bearings needed for scheduled pump maintenance',
    prioridad: 'ALTA',
    fecha_requerida: '2024-03-20',
    ot_id: 1523
  })
});

Requisitions

List Requisitions

Search and filter material requisitions.
GET /inventarios/api/solicitudes/search/
q
string
Search query
estado
string
Filter by status: PENDIENTE, APROBADA, EN_PROCESO, DESPACHADA, RECHAZADA
usuario_id
integer
Filter by requesting user
fecha_desde
string
Start date filter (YYYY-MM-DD)
fecha_hasta
string
End date filter (YYYY-MM-DD)

Response

results
array
Array of requisition objects

Get Requisition Items

Retrieve detailed line items for a requisition.
GET /inventarios/api/solicitudes/{pk}/items/
pk
string
required
Requisition ID or code

Response

solicitud
object
Requisition header information
items
array
Array of line items

Warehouse Operations

Pending Requisitions for Warehouse

Get requisitions pending dispatch (warehouse view).
GET /inventarios/api/pedidos-pendientes/
ubicacion_id
integer
Filter by warehouse location

Response

requisiciones
array
Array of pending requisitions with stock availability

Get Requisition Details for Warehouse

Retrieve requisition with stock allocation details.
GET /inventarios/api/pedidos/{pk}/detalle/
pk
integer
required
Requisition ID

Response

solicitud
object
Requisition details
items
array
Items with stock availability

Dispatch Requisition

Process and dispatch materials from warehouse.
POST /inventarios/api/pedidos/{pk}/despachar/
pk
integer
required
Requisition ID
items
array
required
Array of dispatch items
notas
string
Dispatch notes

Response

status
string
“success” or “error”
message
string
Status message
movimientos
array
Array of created inventory movement IDs
fetch('/inventarios/api/pedidos/789/despachar/', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-CSRFToken': csrfToken
  },
  credentials: 'same-origin',
  body: JSON.stringify({
    items: [
      {
        item_id: 1001,
        cantidad: 2,
        ubicacion_id: 5
      }
    ],
    notas: 'Dispatched for OT-2024-1523'
  })
});

Quick Operations

Register Quick Movement

Quickly register an inventory movement (for mobile/scanner).
POST /inventarios/api/movimiento-rapido/
material_id
integer
required
Material ID
tipo
string
required
Movement type: ENTRADA, SALIDA, AJUSTE, TRANSFERENCIA
cantidad
float
required
Quantity (positive or negative)
ubicacion_origen_id
integer
Source location (for transfers/exits)
ubicacion_destino_id
integer
Destination location (for transfers/entries)
motivo
string
required
Reason for movement
documento_referencia
string
Reference document (PO, invoice, etc.)

Response

status
string
“success” or “error”
movimiento_id
integer
Created movement ID

Create Material (Quick)

Quickly create a new material from requisition flow.
POST /inventarios/api/material/quick-create/
nombre
string
required
Material name
categoria_id
integer
required
Category ID
unidad_medida_id
integer
required
Unit of measure ID
sku
string
Optional SKU code (auto-generated if omitted)
precio_estimado
float
Estimated unit price
descripcion
string
Material description

Lot Management

Register Incoming Lot

Register a new lot/batch of material.
POST /inventarios/api/ingreso-lote/
material_id
integer
required
Material ID
cantidad
float
required
Incoming quantity
ubicacion_id
integer
required
Warehouse location
numero_lote
string
required
Lot/batch number
fecha_fabricacion
string
Manufacturing date (YYYY-MM-DD)
fecha_vencimiento
string
Expiration date (YYYY-MM-DD)
proveedor
string
Supplier name
costo_unitario
float
Unit cost
documento_referencia
string
Reference document (PO, invoice)

Label Printing

Generate a printable label for a material (barcode/QR code).
POST /inventarios/api/print-label/{material_id}/
material_id
integer
required
Material ID
cantidad
integer
default:"1"
Number of labels to print
include_qr
boolean
default:"true"
Include QR code
include_barcode
boolean
default:"true"
Include barcode (Code 128)

Response

pdf_url
string
URL to download PDF with labels

Generate Label PDF

Generate PDF with multiple labels.
POST /inventarios/etiquetas/generar-pdf/
materials
array
required
Array of material IDs
copies_per_material
integer
default:"1"
Copies of each label
include_price
boolean
default:"false"
Include price on label

Mobile Endpoints

Mobile Order List

Get requisitions for mobile view.
GET /inventarios/mobile/pedidos/

Mobile Order Detail

Get requisition details for mobile.
GET /inventarios/mobile/pedidos/{pk}/
pk
integer
required
Requisition ID

Configuration

Key Settings

# energia/settings.py

# File upload limits
DATA_UPLOAD_MAX_MEMORY_SIZE = 10 * 1024 * 1024  # 10 MB
FILE_UPLOAD_MAX_MEMORY_SIZE = 50 * 1024 * 1024  # 50 MB

# n8n Integration for material requests
N8N_SOLICITUD_WEBHOOK_URL = os.environ.get(
    'N8N_SOLICITUD_WEBHOOK_URL', 
    'http://n8n:5678/webhook/solicitud-material'
)

Next Steps

API Overview

Return to API overview

Authentication

Learn about authentication

Build docs developers (and LLMs) love