4WS Suite
Home
API Reference
  • Data mangement API
  • Documents API
Home
API Reference
  • Data mangement API
  • Documents API
Fourwayshop
  1. Stock
  • Login
    • login
      POST
  • Product
    • Brand
      • Get All Brands
      • Get A Brand
      • Insert brand
      • Update brand
    • Season
      • Get All Seasons
      • Get A Season
      • Insert season
      • Update season
    • Attribute
      • Get All Attribute Types
      • Get Attribute Type
      • Get Attribute
      • Insert attribute
      • Update attribute
    • Hierarchy
      • Insert hierarchy
      • Update hierarchy
    • Dimension groups
      • Insert dimension group
      • Update dimension group
    • Dimension
      • Insert dimension
      • Update dimension
      • Delete dimension
    • Product
      • Get products
      • Get product
      • Get product grouping
      • Get SKU's barcodes
      • Get product stock
      • Insert product
      • Update product
    • Activate dimensions on products
      • Insert active dimensions
      • Delete active dimensions
    • Barcode
      • Get SKU from barcode
      • Generate missing barcodes
      • Generate missing barcode for SKU
      • Insert barcode
      • Delete barcode
    • Prices
      • Get product prices
    • Price dimension groupings
      • Get Dimension Price Grouping
      • Get All Dimension Price Grouping
      • Insert dimension grouping
      • Update dimension grouping
      • Delete dimension grouping
    • Assortment
      • insert product assortment
      • delete product assortment
    • Image
      • Get images
      • Add image
      • Replace image
      • Delete image
    • Supplier
      • Get Item suppliers
      • Insert item supplier
      • Delete item supplier
      • Update item supplier
    • Custom category
      • Get Custom code
      • Insert Custom code
      • Update Custom code
    • Vat
      • Vat types
        • Get VAT type
        • Get VAT types
      • VATs
        • Get VATs
        • Get VATs by type
        • Get VAT
      • Vat rates
        • Get VAT rates
        • Get single VAT rates
    • Stock
      • Insert stock
        POST
      • Get stock
        GET
  • Price lists
    • Get price lists
      GET
    • Get price lists by type
      GET
    • Get price list
      GET
    • Get prices from price list
      GET
    • Get entities from price lists
      GET
    • Insert Price List
      POST
    • Insert Product Price
      POST
    • Insert Entity On Price Lists
      POST
    • Update price list
      PATCH
    • Delete all product prices
      DELETE
    • Delete single product price
      DELETE
    • Delete entity from a price lists
      DELETE
  • Supplier
    • Supplier contacts
    • Supplier addresses
    • Get Suppliers
    • Get A Specific Supplier
    • Insert supplier
    • Update supplier
  • Entities
    • Get entities
    • Get entity
    • Insert entity
    • Update entity
  • Miscellaneous
    • Get requests rate limits
  • Catalog
    • Get Catalogs details
    • Get Catalog details by Code
    • Get products by Catalog Code
  • Export
    • Get bulk CSV Export
  1. Stock

Insert stock

POST
/api/v1/stocks
Last modified:2025-04-08 12:12:29
Available from release:3.1.2

Insert Product Stock in a Store or Warehouse#

This API allows the insertion of product stock for a specific store or warehouse. The stock can be specified using either the product's barcode or its SKU details.

Actors#

API Client: The system or user initiating the request.
4ws.trade: The backend system that processes the request.

Preconditions#

The external system must have the necessary permissions and access to the document creation service, please refer to Authentication.
The entity_code must correspond to a valid store or warehouse in the system.
The item_code must exist in the product catalog.
For barcode-based stock entry, the barcode and item_code combination must match an existing product.
For SKU-based stock entry, the dimension_level1 and dimension_level2 values must match the product's composition and dimensions.

Main Success Scenario#

The API client sends a request to insert stock using the correct payload.
Request Example
The 4ws.trade API returns a success response with success: true.
If a callback URL is provided, 4ws.suite sends the result to the specified endpoint after processing.
A successful request returns the following response:
Response Example
To verify if the request has been processed correctly, you can include the callback parameter in the body, specifying the URL of an endpoint to receive the processing result. The callback response will depend on the data provided in the request. For example, if stock is inserted successfully, a message similar to the following will be sent to the callback:
Callback Response Example

Alternate Flows#

Authentication Error: If the client does not provide valid credentials, an error response is returned.
Error Example
Invalid entity_code: If the entity_code is not found, the API returns HTTP 422 with the following error:
Error Example
Invalid item_code: If the item_code does not exist, the API returns HTTP 422 with the following error:
Error Example
Invalid barcode: If the barcode does not exist, the API returns HTTP 422 with the following error:
Error Example
Invalid SKU Combination: If the SKU details do not match the product's composition and dimensions, the API returns HTTP 422 with the following error:
Error Example
Rate Limiting: If the API rate limits are exceeded, the client must respect the retry interval indicated in the response headers Rate Limits.

Sequence Diagram#

Best Practices
Please refer to Best Practices for Error Handling in External System for best practices on implementation.

Code Examples in Node.js#

Example Request:

Request

Body Params application/json

Example
{
    "entity_code": 0,
    "quantity_stock": 0,
    "quantity_available": 0,
    "barcode": "string",
    "item_code": "string",
    "dimension_level1": "string",
    "dimension_level2": "string",
    "dimension_level3": "string",
    "dimension_level4": "string",
    "dimension_level5": "string",
    "callback": "string"
}

Request Code Samples

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
Request Request Example
Shell
JavaScript
Java
Swift
curl --location --request POST '/api/v1/stocks' \
--header 'Content-Type: application/json' \
--data-raw '{
    "entity_code": 0,
    "quantity_stock": 0,
    "quantity_available": 0,
    "barcode": "string",
    "item_code": "string",
    "dimension_level1": "string",
    "dimension_level2": "string",
    "dimension_level3": "string",
    "dimension_level4": "string",
    "dimension_level5": "string",
    "callback": "string"
}'

Responses

🟢200OK
application/json
Body

Example
{
    "success": true,
    "message": "operation enqueued"
}
🟠422Invalid SKU
🟠422Invalid Entity code
Modified at 2025-04-08 12:12:29
Previous
Get single VAT rates
Next
Get stock
Built with