4WS Suite
Home
API Reference
  • Data mangement API
  • Documents API
Home
API Reference
  • Data mangement API
  • Documents API
Fourwayshop
  1. Barcode
  • 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
        GET
      • Generate missing barcodes
        POST
      • Generate missing barcode for SKU
        POST
      • Insert barcode
        POST
      • Delete barcode
        DELETE
    • 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
      • Get stock
  • 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. Barcode

Insert barcode

POST
/api/v1/products/{ITEM_CODE}/barcodes
Last modified:2025-02-07 14:45:20

Insert Barcode for Specific SKU#

This API allows the insertion of a barcode for a specific SKU identified by product {ITEM_CODE}, along with details such as the barcode type and dimension levels from dimension_level1 to dimension_level5. If the barcode is successfully inserted, the API returns the generated internal code (prog_id) and the barcode itself.
Products and dimensions
For more detail about Products ad dimensions please refeare to use case Product dimensions.

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 specified ITEM_CODE must correspond to an existing product in the system.
The provided dimensions (dimension_level1, dimension_level2, etc.) must uniquely identify the SKU for which the barcode is being added.
The barcode must be unique for each SKU; attempts to insert an already-existing barcode will result in an error.

Main Success Scenario#

1.
The client sends a POST request with a valid ITEM_CODE, barcode_type, dimensions, and the barcode itself.
2.
The API verifies the SKU details and checks if the barcode is unique.
3.
If validation is successful, the barcode is inserted, and the API returns a success response with the prog_id and barcode information.

Alternate Flows#

1.
Barcode Already Exists (400)
If the barcode already exists in the system, the API returns a 400 error indicating a unique constraint violation.
Response:
{
  "message": "Unique constraint error, this barcode 8050200058081 already exists"
}
2.
Product or SKU Not Found (404)
If the ITEM_CODE or specified dimensions do not match any existing SKU, the API returns a 404 error.
Response:
{
  "message": "Product not found with item_code: {{item_code}}"
}

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#


Request

Authorization
Provide your bearer token in the
Authorization
header when making requests to protected resources.
Example:
Authorization: Bearer ********************
Path Params

Body Params application/json

Example
{
    "barcode_type": "EAN13",
    "dimension_level1": "1",
    "dimension_level2": "Y4",
    "barcode": "8050200058081"
}   

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/products//barcodes' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "barcode_type": "EAN13",
    "dimension_level1": "1",
    "dimension_level2": "Y4",
    "barcode": "8050200058081"
}'

Responses

🟢200Success
application/json
Body

Example
{
    "success": true,
    "barcode": {
        "prog_id": 2334598,
        "barcode": "3314254119515"
    }
}
🟠422Error - barcode exists
🟠401Authentication failed
🟠403Operation not allowed
🟠422Unique constraint error
Modified at 2025-02-07 14:45:20
Previous
Generate missing barcode for SKU
Next
Delete barcode
Built with