Skip to main content
POST
/
api
/
pedidos
Create Order
curl --request POST \
  --url https://api.example.com/api/pedidos
Creates a new order with line items. The order reference is auto-generated.

Authentication

Requires JWT token in the Authorization header.
Authorization: Bearer YOUR_JWT_TOKEN

Request Body

Send a PedidoDetalleDTO object with order details. The pedido_id, referencia, fechaPedido, and calculated fields are auto-generated.
{
  "usuario": {
    "usuario_id": 5
  },
  "estado": "PENDIENTE",
  "detalles": [
    {
      "producto": {
        "producto_id": 10
      },
      "cantidad": 2,
      "precioUnitario": 49.99
    },
    {
      "producto": {
        "producto_id": 15
      },
      "cantidad": 1,
      "precioUnitario": 129.99
    }
  ]
}

Request Fields

FieldTypeRequiredDescription
usuario.usuario_idLongYesID of the user placing the order
estadoStringYesInitial order status (typically “PENDIENTE”)
detallesArrayYesArray of order line items (at least one required)
detalles[].producto.producto_idLongYesProduct ID
detalles[].cantidadIntegerYesQuantity to order
detalles[].precioUnitarioBigDecimalYesUnit price

EstadoPedido Values

  • PENDIENTE - Order pending
  • PAGADO - Order paid
  • ENVIADO - Order shipped
  • ENTREGADO - Order delivered
  • CANCELADO - Order cancelled

Response

Returns the created order with auto-generated fields populated.

Response Body

{
  "pedido_id": 42,
  "referencia": "ORD-2026-042",
  "usuario": {
    "usuario_id": 5,
    "username": "john_doe",
    "email": {
      "address": "[email protected]"
    }
  },
  "fechaPedido": "2026-03-11T14:22:35",
  "estado": "PENDIENTE",
  "detalles": [
    {
      "detalle_id": 101,
      "producto": {
        "producto_id": 10,
        "nombre": "BILLY Bookcase",
        "precioCantidad": 49.99,
        "precioMoneda": "USD",
        "es_destacado": false
      },
      "cantidad": 2,
      "precioUnitario": 49.99,
      "subtotal": 99.98
    },
    {
      "detalle_id": 102,
      "producto": {
        "producto_id": 15,
        "nombre": "MALM Dresser",
        "precioCantidad": 129.99,
        "precioMoneda": "USD",
        "es_destacado": true
      },
      "cantidad": 1,
      "precioUnitario": 129.99,
      "subtotal": 129.99
    }
  ],
  "total": 229.97
}

Example Request

curl -X POST "https://api.iquea.com/api/pedidos" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "usuario": {
      "usuario_id": 5
    },
    "estado": "PENDIENTE",
    "detalles": [
      {
        "producto": {
          "producto_id": 10
        },
        "cantidad": 2,
        "precioUnitario": 49.99
      }
    ]
  }'

Status Codes

CodeDescription
201Created - Order successfully created
400Bad request - Invalid order data
401Unauthorized - Invalid or missing token
404Not found - User or product not found
500Internal server error

Build docs developers (and LLMs) love