Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/luisllatas-dev/Proyecto_Pasteleria_DonMamino/llms.txt

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

The Order Details API manages the individual line items that make up each bakery order. Each record links a product (id_producto) to an order (id_pedido), capturing both the quantity and the unit price at the moment of purchase. All endpoints on this resource require a valid JWT Bearer token.
Authentication required: All endpoints on this resource require an Authorization: Bearer <token> header. Requests without a valid token will be rejected.
Price snapshot: The precio_unitario field stores the product’s price at the time the order detail was created. This value is independent of any future changes to the product’s current price, preserving an accurate record for invoicing and reporting.

GET /api/detalles-pedido

Returns a list of all order detail records across all orders.
curl --request GET \
  --url http://localhost:3000/api/detalles-pedido \
  --header 'Authorization: Bearer <token>'
Response — 200 OK
[
  {
    "id_detalle": 1,
    "id_pedido": 1,
    "id_producto": 4,
    "cantidad": 2,
    "precio_unitario": "35.00"
  },
  {
    "id_detalle": 2,
    "id_pedido": 1,
    "id_producto": 7,
    "cantidad": 1,
    "precio_unitario": "60.50"
  }
]
id_detalle
number
required
Auto-incremented unique identifier for the order detail record.
id_pedido
number
required
ID of the parent order this line item belongs to. References the Pedidos table.
id_producto
number
required
ID of the product included in this line item. References the Productos table.
cantidad
number
required
Quantity of the product ordered.
precio_unitario
string
required
Unit price of the product at the time of purchase, stored as a decimal (e.g., "35.00").

GET /api/detalles-pedido/:id

Returns a single order detail record by its unique ID.
curl --request GET \
  --url http://localhost:3000/api/detalles-pedido/1 \
  --header 'Authorization: Bearer <token>'
Response — 200 OK
{
  "id_detalle": 1,
  "id_pedido": 1,
  "id_producto": 4,
  "cantidad": 2,
  "precio_unitario": "35.00"
}
Response — 404 Not Found
{
  "message": "Detalle no encontrado"
}

POST /api/detalles-pedido

Creates a new line item record and associates it with an existing order. The precio_unitario must be explicitly provided to capture the price at the time of purchase.
id_pedido
number
required
ID of the order this line item belongs to. Must reference an existing record in the Pedidos table.
id_producto
number
required
ID of the product being ordered. Must reference an existing record in the Productos table.
cantidad
number
required
Quantity of the product being ordered. Must be a positive integer.
precio_unitario
number
required
Unit price of the product at the time of purchase. This value is stored as a snapshot and does not change if the product price is updated later.
curl --request POST \
  --url http://localhost:3000/api/detalles-pedido \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "id_pedido": 2,
    "id_producto": 4,
    "cantidad": 3,
    "precio_unitario": 35.00
  }'
Response — 201 Created
{
  "id": 3,
  "mensaje": "Detalle creado exitosamente"
}
id
number
required
The id_detalle of the newly created order detail record.
mensaje
string
required
Confirmation message.

PUT /api/detalles-pedido/:id

Updates all fields of an existing order detail record. Use this endpoint to correct quantities or price values on a line item.
id
number
required
The unique ID of the order detail record to update.
id_pedido
number
required
ID of the parent order for this line item.
id_producto
number
required
ID of the product for this line item.
cantidad
number
required
Updated quantity of the product.
precio_unitario
number
required
Updated unit price snapshot for this line item.
curl --request PUT \
  --url http://localhost:3000/api/detalles-pedido/3 \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "id_pedido": 2,
    "id_producto": 4,
    "cantidad": 5,
    "precio_unitario": 35.00
  }'
Response — 200 OK
{
  "mensaje": "Detalle actualizado exitosamente"
}
Response — 404 Not Found
{
  "message": "Detalle no encontrado"
}

DELETE /api/detalles-pedido/:id

Permanently deletes an order detail record by ID.
Deletion is permanent and cannot be undone. To remove all line items for an order at once, delete the parent order via DELETE /api/pedidos/:id, which cascades to all associated detail records.
id
number
required
The unique ID of the order detail record to delete.
curl --request DELETE \
  --url http://localhost:3000/api/detalles-pedido/3 \
  --header 'Authorization: Bearer <token>'
Response — 200 OK
{
  "mensaje": "Detalle eliminado exitosamente"
}
Response — 404 Not Found
{
  "message": "Detalle no encontrado"
}

Build docs developers (and LLMs) love