Routes

Stock


title: Stock

Fetch Stock availability

  • The __invoke method in the StockController handles a GET or POST request to the /stock endpoint.
  • This method retrieves site IDs and product codes from the incoming request using FetchStockRequest.
  • It logs the request details for debugging purposes, including product codes and site IDs.
  • If either product codes or site IDs are missing, the request is aborted, and an empty data response is returned.
  • Depending on the configuration, it either fetches e-commerce stock levels or web stock levels for the specified product codes at the given site IDs.
  • The method returns the stock levels formatted as a StockResource collection.
  • Route::get('/', 'StockController');
  • Route::post('/getStock', 'StockController');

Details

  • Route: /getStock
  • HTTP Request: POST
  • Controller: StockController
  • Method: __invoke

Tested through Postman

  • Endpoint: https://apis.dev.nl.toolstation.dev/ecom/v1/stock/getStock
  • Access Token: Required
  • Request Body:
    {
        "products": ["84728"],
        "sites": ["WW"]
    }
    
  • Response:
    {
        "data": [
            {
                "product_code": "84728",
                "stock_qty": "16",
                "site_id": "WW",
                "is_direct_ship": false
            }
        ]
    }
    

Copyright © 2026