Skip to main content

Distribute Products

Triggers the product distribution algorithm to assign warehouse stock to stores based on demand and optimization criteria.

Response

Returns an array of stock assignment objects created by the distribution algorithm.
id
string
required
Unique identifier for the stock assignment (UUID)
storeId
string
required
ID of the store receiving the stock
warehouseId
string
required
ID of the warehouse supplying the stock
productId
string
required
ID of the product being assigned
size
string
required
Size of the product being assigned
quantity
integer
required
Number of units assigned
distanceKm
number
required
Distance in kilometers between warehouse and store

Example Request

curl -X POST http://localhost:8080/api/stock-assignments/distribute

Example Response

[
  {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "storeId": "STORE001",
    "warehouseId": "WH001",
    "productId": "PROD001",
    "size": "M",
    "quantity": 50,
    "distanceKm": 12.5
  },
  {
    "id": "550e8400-e29b-41d4-a716-446655440001",
    "storeId": "STORE002",
    "warehouseId": "WH001",
    "productId": "PROD002",
    "size": "L",
    "quantity": 30,
    "distanceKm": 8.3
  }
]

Get All Assignments

Retrieves stock assignments with optional filtering criteria.

Query Parameters

storeId
string
Filter assignments by store ID
warehouseId
string
Filter assignments by warehouse ID
productId
string
Filter assignments by product ID

Response

Returns an array of stock assignment objects matching the criteria.
id
string
required
Unique identifier for the stock assignment (UUID)
storeId
string
required
ID of the store receiving the stock
warehouseId
string
required
ID of the warehouse supplying the stock
productId
string
required
ID of the product being assigned
size
string
required
Size of the product being assigned
quantity
integer
required
Number of units assigned
distanceKm
number
required
Distance in kilometers between warehouse and store

Example Request

curl -X GET "http://localhost:8080/api/stock-assignments?storeId=STORE001"

Example Response

[
  {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "storeId": "STORE001",
    "warehouseId": "WH001",
    "productId": "PROD001",
    "size": "M",
    "quantity": 50,
    "distanceKm": 12.5
  }
]

Get Assignments By Store

Retrieves all stock assignments for a specific store.

Path Parameters

storeId
string
required
The unique identifier of the store

Response

Returns an array of stock assignment objects for the specified store.

Example Request

curl -X GET http://localhost:8080/api/stock-assignments/stores/STORE001

Example Response

[
  {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "storeId": "STORE001",
    "warehouseId": "WH001",
    "productId": "PROD001",
    "size": "M",
    "quantity": 50,
    "distanceKm": 12.5
  }
]

Get Assignments By Product

Retrieves all stock assignments for a specific product.

Path Parameters

productId
string
required
The unique identifier of the product

Response

Returns an array of stock assignment objects for the specified product.

Example Request

curl -X GET http://localhost:8080/api/stock-assignments/products/PROD001

Example Response

[
  {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "storeId": "STORE001",
    "warehouseId": "WH001",
    "productId": "PROD001",
    "size": "M",
    "quantity": 50,
    "distanceKm": 12.5
  },
  {
    "id": "550e8400-e29b-41d4-a716-446655440002",
    "storeId": "STORE003",
    "warehouseId": "WH002",
    "productId": "PROD001",
    "size": "L",
    "quantity": 40,
    "distanceKm": 15.2
  }
]

Get Assignments By Warehouse

Retrieves all stock assignments from a specific warehouse.

Path Parameters

warehouseId
string
required
The unique identifier of the warehouse

Response

Returns an array of stock assignment objects for the specified warehouse.

Example Request

curl -X GET http://localhost:8080/api/stock-assignments/warehouses/WH001

Example Response

[
  {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "storeId": "STORE001",
    "warehouseId": "WH001",
    "productId": "PROD001",
    "size": "M",
    "quantity": 50,
    "distanceKm": 12.5
  },
  {
    "id": "550e8400-e29b-41d4-a716-446655440001",
    "storeId": "STORE002",
    "warehouseId": "WH001",
    "productId": "PROD002",
    "size": "L",
    "quantity": 30,
    "distanceKm": 8.3
  }
]

Error Responses

Resource Not Found (404)

Returned when the requested store, warehouse, or product ID does not exist.
{
  "error": "Resource not found",
  "message": "Store with ID STORE001 does not exist"
}

Distribution Failed (500)

Returned when the distribution algorithm encounters an error.
{
  "error": "Distribution failed",
  "message": "Unable to complete product distribution due to system error"
}

Build docs developers (and LLMs) love