Skip to main content

List Products

Retrieves all products for the authenticated business.

Headers

Authorization
string
required
Bearer token from authentication

Response

[].id
integer
Product ID
[].nombre
string
Product name
[].descripcion
string
Product description
[].precio
float
Product price
[].stock
integer
Available stock quantity
[].empresa_id
integer
Business ID that owns this product
[].categoria_id
integer
Category ID
[].imagen
string
Relative path to product image
[].imagen_url
string
Full URL to product image
[].categoria
object
Category details
[].created_at
string
Creation timestamp
[].updated_at
string
Last update timestamp

Example Request

curl -X GET https://api.beanquick.com/api/empresa/productos \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Accept: application/json"

Example Response

[
  {
    "id": 1,
    "nombre": "Café Americano",
    "descripcion": "Café negro de 12 oz",
    "precio": 15.50,
    "stock": 100,
    "empresa_id": 5,
    "categoria_id": 2,
    "imagen": "productos/cafe-americano.jpg",
    "imagen_url": "https://api.beanquick.com/storage/productos/cafe-americano.jpg",
    "categoria": {
      "id": 2,
      "nombre": "Bebidas Calientes"
    },
    "created_at": "2024-01-15T10:30:00.000000Z",
    "updated_at": "2024-01-20T14:45:00.000000Z"
  }
]

Get Single Product

Retrieves a specific product owned by the authenticated business.

Headers

Authorization
string
required
Bearer token from authentication

Path Parameters

id
integer
required
Product ID

Response

Returns a single product object with the same structure as the list endpoint.

Error Responses

message
string
Error message
  • 404 - Product not found or doesn’t belong to your business
  • 404 - “No tienes una empresa vinculada.” if user has no associated business

Example Request

curl -X GET https://api.beanquick.com/api/empresa/productos/1 \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Accept: application/json"

Create Product

Creates a new product for the authenticated business.

Headers

Authorization
string
required
Bearer token from authentication
Content-Type
string
required
multipart/form-data (required when uploading images)

Body Parameters

nombre
string
required
Product name (max 255 characters)
precio
number
required
Product price (numeric value)
stock
integer
required
Initial stock quantity (minimum 0)
categoria_id
integer
required
Category ID (must exist in categorias table)
descripcion
string
Product description (optional)
imagen
file
Product image (max 2MB, image formats only)

Response

message
string
Success message: “Producto creado con éxito”
producto
object
Created product object with same structure as GET response

Example Request

curl -X POST https://api.beanquick.com/api/empresa/productos \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -F "nombre=Café Latte" \
  -F "precio=18.50" \
  -F "stock=50" \
  -F "categoria_id=2" \
  -F "descripcion=Espresso con leche vaporizada" \
  -F "imagen=@/path/to/latte.jpg"

Example Response

{
  "message": "Producto creado con éxito",
  "producto": {
    "id": 15,
    "nombre": "Café Latte",
    "descripcion": "Espresso con leche vaporizada",
    "precio": 18.50,
    "stock": 50,
    "empresa_id": 5,
    "categoria_id": 2,
    "imagen": "productos/xyz123.jpg",
    "imagen_url": "https://api.beanquick.com/storage/productos/xyz123.jpg",
    "created_at": "2024-03-05T10:30:00.000000Z",
    "updated_at": "2024-03-05T10:30:00.000000Z"
  }
}

Update Product

Updates an existing product owned by the authenticated business.

Headers

Authorization
string
required
Bearer token from authentication
Content-Type
string
multipart/form-data when uploading new image, otherwise application/json

Path Parameters

id
integer
required
Product ID to update

Body Parameters

nombre
string
required
Product name (max 255 characters)
precio
number
required
Product price
stock
integer
required
Stock quantity
categoria_id
integer
required
Category ID (must exist)
descripcion
string
Product description
imagen
file
New product image (replaces existing one)

Response

message
string
“¡Actualizado!”
producto
object
Updated product object

Error Responses

404 Not Found - Product not found or doesn’t belong to your business
{
  "message": "No encontrado"
}

Example Request

curl -X PUT https://api.beanquick.com/api/empresa/productos/15 \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "nombre": "Café Latte Grande",
    "precio": 20.00,
    "stock": 75,
    "categoria_id": 2,
    "descripcion": "Espresso doble con leche vaporizada - 16oz"
  }'

Example Response

{
  "message": "¡Actualizado!",
  "producto": {
    "id": 15,
    "nombre": "Café Latte Grande",
    "descripcion": "Espresso doble con leche vaporizada - 16oz",
    "precio": 20.00,
    "stock": 75,
    "empresa_id": 5,
    "categoria_id": 2,
    "imagen": "productos/xyz123.jpg",
    "imagen_url": "https://api.beanquick.com/storage/productos/xyz123.jpg",
    "created_at": "2024-03-05T10:30:00.000000Z",
    "updated_at": "2024-03-05T15:22:00.000000Z"
  }
}

Delete Product

Deletes a product and its associated image from storage.

Headers

Authorization
string
required
Bearer token from authentication

Path Parameters

id
integer
required
Product ID to delete

Response

message
string
“Producto eliminado correctamente.”

Error Responses

403 Forbidden - Product doesn’t belong to your business
{
  "message": "No autorizado."
}

Example Request

curl -X DELETE https://api.beanquick.com/api/empresa/productos/15 \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Accept: application/json"

Example Response

{
  "message": "Producto eliminado correctamente."
}

Build docs developers (and LLMs) love