Skip to main content
POST
/
api
/
v1
/
products
Create Product
curl --request POST \
  --url https://api.example.com/api/v1/products/ \
  --header 'Content-Type: application/json' \
  --data '
{
  "sku": "<string>",
  "name": "<string>",
  "description": "<string>",
  "category": "<string>",
  "unit_measure": "<string>",
  "unit_value": 123,
  "is_perishable": true,
  "expiration_date": "<string>",
  "suggested_price": 123
}
'
{
  "id": "<string>",
  "sku": "<string>",
  "name": "<string>",
  "category": "<string>",
  "unit_measure": "<string>",
  "unit_value": 123,
  "is_perishable": true,
  "expiration_date": "<string>",
  "suggested_price": 123,
  "error": "<string>"
}

Authorization

Required roles: admin, gestor

Request Body

sku
string
required
Stock Keeping Unit - must be unique across all products
name
string
required
Product name
description
string
Detailed description of the product
category
string
required
Product category (e.g., “Electronics”, “Food”, “Clothing”)
unit_measure
string
required
Unit of measurement (e.g., “kg”, “liters”, “units”, “boxes”)
unit_value
number
default:"1.0"
Value per unit for fractional quantities
is_perishable
boolean
default:"false"
Whether the product has an expiration date
expiration_date
string
Expiration date for perishable products (ISO format or string)
suggested_price
number
default:"0"
Recommended selling price for the product

Response

id
string
Generated UUID for the product
sku
string
Stock Keeping Unit
name
string
Product name
category
string
Product category
unit_measure
string
Unit of measurement
unit_value
number
Value per unit
is_perishable
boolean
Perishable status
expiration_date
string
Expiration date if applicable
suggested_price
number
Recommended selling price

Example Request

curl -X POST https://api.example.com/api/v1/products/ \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "sku": "PROD-001",
    "name": "Organic Apples",
    "description": "Fresh organic apples from local farms",
    "category": "Fruits",
    "unit_measure": "kg",
    "unit_value": 1.0,
    "is_perishable": true,
    "expiration_date": "2026-03-15",
    "suggested_price": 4.99
  }'

Example Response

{
  "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "sku": "PROD-001",
  "name": "Organic Apples",
  "category": "Fruits",
  "unit_measure": "kg",
  "unit_value": 1.0,
  "is_perishable": true,
  "expiration_date": "2026-03-15",
  "suggested_price": 4.99
}

Error Responses

error
string
Error message describing what went wrong

400 Bad Request

Returned when required fields are missing:
{
  "error": "Missing required fields"
}

401 Unauthorized

Returned when authentication token is invalid or missing.

403 Forbidden

Returned when the authenticated user lacks required role (admin or gestor).

Build docs developers (and LLMs) love