Skip to main content
Orders are the central object in SmartLogix. When you create an order, the platform automatically validates that the requested product has enough stock before accepting it. Orders move through a defined lifecycle from pending submission through to final delivery or cancellation, giving your team a clear picture of every transaction at any point in time.

Order types

SmartLogix supports two order types, which determine how the order is handled downstream:

NACIONAL

Domestic orders within the same country. Standard processing with no additional documentation requirements.

INTERNACIONAL

Cross-border orders. The observaciones field on international orders automatically receives a customs handling note at creation time.

Order lifecycle

Every order starts as PENDIENTE and moves forward as your team processes it. Orders can also be cancelled at any stage.
PENDIENTE → APROBADO → EN_ENVIO → ENTREGADO

           CANCELADO
StatusMeaning
PENDIENTEOrder submitted, awaiting approval
APROBADOOrder approved and in processing
EN_ENVIOShipment created and in progress
ENTREGADOOrder delivered to the destination
CANCELADOOrder cancelled at any stage

Create an order

Send a POST request to /api/pedidos. The productoId and cantidad fields are used to validate stock before the order is accepted.

NACIONAL order

curl -X POST http://localhost:8080/api/pedidos \
  -H "Authorization: Bearer <your-token>" \
  -H "Content-Type: application/json" \
  -d '{
    "userId": 1,
    "userEmail": "user@example.com",
    "clienteNombre": "Empresa ABC",
    "total": 129.90,
    "tipoPedido": "NACIONAL",
    "destino": "Santiago, Chile",
    "productoId": 1,
    "cantidad": 10
  }'

INTERNACIONAL order

curl -X POST http://localhost:8080/api/pedidos \
  -H "Authorization: Bearer <your-token>" \
  -H "Content-Type: application/json" \
  -d '{
    "userId": 1,
    "userEmail": "user@example.com",
    "clienteNombre": "Empresa XYZ",
    "total": 499.00,
    "tipoPedido": "INTERNACIONAL",
    "destino": "Buenos Aires, Argentina",
    "productoId": 3,
    "cantidad": 5
  }'
A 201 Created response returns the full order object. The initial status is always PENDIENTE.

Required fields

FieldTypeDescription
userIdintegerID of the user placing the order
userEmailstringEmail address of the user
clienteNombrestringName of the end customer
totalnumberOrder total value
tipoPedidostringNACIONAL or INTERNACIONAL
destinostringDestination city or country
productoIdintegerID of the product being ordered
cantidadintegerQuantity of units requested

Stock validation and circuit breaker

When you submit an order, the order service calls the inventory service to confirm that stockActual >= cantidad for the given product. If stock is insufficient, the order is rejected with an error response.
SmartLogix uses a circuit breaker pattern on the stock validation call. If the inventory service is unavailable or the circuit is open due to repeated failures, the order is rejected immediately rather than being accepted with unverified stock. This is a deliberate fail-safe — it prevents overselling when stock data cannot be confirmed. Once the inventory service recovers, new orders will be accepted normally.

List and filter orders

Retrieve all orders with GET /api/pedidos. The dashboard groups orders by status — you can apply the same filter in your own integrations by inspecting the status field in the response array.
curl http://localhost:8080/api/pedidos \
  -H "Authorization: Bearer <your-token>"
Retrieve a single order by its ID:
curl http://localhost:8080/api/pedidos/42 \
  -H "Authorization: Bearer <your-token>"

Endpoint reference

MethodPathDescription
GET/api/pedidosList all orders
POST/api/pedidosCreate a new order
GET/api/pedidos/{id}Get an order by ID