Skip to main content

Create product

Requires ADMIN role
Create a new product in the catalog.
POST /products

Request body

name
string
required
Product name (max 150 characters)
description
string
Product description (max 1000 characters)
brand
string
required
Brand name (max 100 characters)
categoryId
integer
required
ID of the category this product belongs to. Must be a positive integer.
price
number
required
Product price. Must be a non-negative decimal value with up to 2 decimal places.
currency
string
required
ISO 3-letter uppercase currency code (e.g., USD, EUR, GBP)
status
string
required
Product status. Valid values: ACTIVE, INACTIVE, OUT_OF_STOCK, DISCONTINUED
curl -X POST "http://localhost:8083/products" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Premium Wireless Headphones",
    "description": "High-quality noise-canceling headphones with 30-hour battery life",
    "brand": "AudioTech",
    "categoryId": 5,
    "price": 199.99,
    "currency": "USD",
    "status": "ACTIVE"
  }'

Response

id
integer
Unique product identifier
name
string
Product name
description
string
Product description
brand
string
Brand name
categoryId
integer
Category ID
price
number
Product price
currency
string
Currency code
status
string
Product status
createdAt
string
ISO 8601 timestamp of creation
updatedAt
string
ISO 8601 timestamp of last update
deleted
boolean
Whether the product is soft-deleted
{
  "id": 123,
  "name": "Premium Wireless Headphones",
  "description": "High-quality noise-canceling headphones with 30-hour battery life",
  "brand": "AudioTech",
  "categoryId": 5,
  "price": 199.99,
  "currency": "USD",
  "status": "ACTIVE",
  "createdAt": "2026-03-03T12:00:00Z",
  "updatedAt": "2026-03-03T12:00:00Z",
  "deleted": false
}

List products

Retrieve a paginated list of products with optional filters.
GET /products

Query parameters

categoryId
integer
Filter products by category ID
brand
string
Filter products by brand name
status
string
Filter by product status. Valid values: ACTIVE, INACTIVE, OUT_OF_STOCK, DISCONTINUED
page
integer
default:"0"
Page number (zero-indexed)
size
integer
default:"10"
Number of items per page
sort
string
Sort criteria (e.g., name,asc or price,desc)
curl -X GET "http://localhost:8083/products?categoryId=5&status=ACTIVE&page=0&size=10" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Response

content
array
Array of product objects
page
integer
Current page number (zero-indexed)
size
integer
Number of items per page
totalElements
integer
Total number of products matching the filters
totalPages
integer
Total number of pages
last
boolean
Whether this is the last page
{
  "content": [
    {
      "id": 123,
      "name": "Premium Wireless Headphones",
      "description": "High-quality noise-canceling headphones",
      "brand": "AudioTech",
      "categoryId": 5,
      "price": 199.99,
      "currency": "USD",
      "status": "ACTIVE",
      "createdAt": "2026-01-15T10:30:00Z",
      "updatedAt": "2026-02-01T14:20:00Z",
      "deleted": false
    },
    {
      "id": 124,
      "name": "Bluetooth Speaker",
      "description": "Portable waterproof speaker",
      "brand": "AudioTech",
      "categoryId": 5,
      "price": 79.99,
      "currency": "USD",
      "status": "ACTIVE",
      "createdAt": "2026-01-20T09:15:00Z",
      "updatedAt": "2026-01-20T09:15:00Z",
      "deleted": false
    }
  ],
  "page": 0,
  "size": 10,
  "totalElements": 45,
  "totalPages": 5,
  "last": false
}

Get product by ID

Retrieve detailed information about a specific product.
GET /products/{productId}

Path parameters

productId
integer
required
The unique identifier of the product
curl -X GET "http://localhost:8083/products/123" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Response

id
integer
Unique product identifier
name
string
Product name
description
string
Product description
brand
string
Brand name
categoryId
integer
Category ID
price
number
Product price
currency
string
Currency code
status
string
Product status
createdAt
string
ISO 8601 timestamp of creation
updatedAt
string
ISO 8601 timestamp of last update
deleted
boolean
Whether the product is soft-deleted
{
  "id": 123,
  "name": "Premium Wireless Headphones",
  "description": "High-quality noise-canceling headphones with 30-hour battery life",
  "brand": "AudioTech",
  "categoryId": 5,
  "price": 199.99,
  "currency": "USD",
  "status": "ACTIVE",
  "createdAt": "2026-01-15T10:30:00Z",
  "updatedAt": "2026-02-01T14:20:00Z",
  "deleted": false
}

Update product

Requires ADMIN role
Update an existing product’s information.
PUT /products/{productId}

Path parameters

productId
integer
required
The unique identifier of the product to update

Request body

name
string
required
Product name (max 150 characters)
description
string
Product description (max 1000 characters)
brand
string
required
Brand name (max 100 characters)
categoryId
integer
required
ID of the category this product belongs to. Must be a positive integer.
price
number
required
Product price. Must be a non-negative decimal value.
currency
string
required
ISO 3-letter uppercase currency code
status
string
required
Product status. Valid values: ACTIVE, INACTIVE, OUT_OF_STOCK, DISCONTINUED
curl -X PUT "http://localhost:8083/products/123" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Premium Wireless Headphones Pro",
    "description": "Updated model with enhanced features",
    "brand": "AudioTech",
    "categoryId": 5,
    "price": 249.99,
    "currency": "USD",
    "status": "ACTIVE"
  }'

Response

id
integer
Unique product identifier
name
string
Updated product name
description
string
Updated product description
brand
string
Brand name
categoryId
integer
Category ID
price
number
Updated product price
currency
string
Currency code
status
string
Product status
createdAt
string
ISO 8601 timestamp of creation
updatedAt
string
ISO 8601 timestamp of last update
deleted
boolean
Whether the product is soft-deleted
{
  "id": 123,
  "name": "Premium Wireless Headphones Pro",
  "description": "Updated model with enhanced features",
  "brand": "AudioTech",
  "categoryId": 5,
  "price": 249.99,
  "currency": "USD",
  "status": "ACTIVE",
  "createdAt": "2026-01-15T10:30:00Z",
  "updatedAt": "2026-03-03T12:30:00Z",
  "deleted": false
}

Delete product

Requires ADMIN role
Soft delete a product. The product will be marked as deleted but not removed from the database.
DELETE /products/{productId}

Path parameters

productId
integer
required
The unique identifier of the product to delete
curl -X DELETE "http://localhost:8083/products/123" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Response

message
string
Confirmation message
{
  "message": "Product deleted successfully"
}

Search products

Search for products by name or brand using a query string.
GET /products/search

Query parameters

query
string
required
Search term to match against product names and brands
curl -X GET "http://localhost:8083/products/search?query=wireless" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Response

Returns an array of product objects matching the search query.
[
  {
    "id": 123,
    "name": "Premium Wireless Headphones",
    "description": "High-quality noise-canceling headphones",
    "brand": "AudioTech",
    "categoryId": 5,
    "price": 199.99,
    "currency": "USD",
    "status": "ACTIVE",
    "createdAt": "2026-01-15T10:30:00Z",
    "updatedAt": "2026-02-01T14:20:00Z",
    "deleted": false
  },
  {
    "id": 125,
    "name": "Wireless Gaming Mouse",
    "description": "Ergonomic wireless mouse for gaming",
    "brand": "TechGear",
    "categoryId": 8,
    "price": 49.99,
    "currency": "USD",
    "status": "ACTIVE",
    "createdAt": "2026-02-10T11:00:00Z",
    "updatedAt": "2026-02-10T11:00:00Z",
    "deleted": false
  }
]

Build docs developers (and LLMs) love