set_products API Endpoint

This endpoint allows you to create or update multiple products in a single API call via the Public API.

Endpoint

/public_api/set_products/

Method

POST

Content-Type

application/json

Authentication

  • Header: Authorization1: {API_TOKEN}
  • Body parameters: username, password, account

Request Body Parameters

Parameter Type Required Description
username string Yes API username
password string Yes API password
account string Yes Account domain
products array Yes Array of product objects to create or update

Product Object Structure

Each product object in the products array follows the same structure as the set_product endpoint:

For UPDATE (pid provided):

  • pid: Product ID to update
  • Any product fields to update (only provided fields will be updated)
  • stock_data: Array of stock modifications
  • products_multi: Array of multi-location price/barcode data
  • costs: Array of product cost data (flat associative array)
  • images_add: Array of images to add (base64 encoded)
  • images_delete: Array of image IDs to delete

For CREATE (pid NOT provided):

  • cid: Category ID (required for new products)
  • bid: Brand ID (required for new products)
  • price OR price_gross: Net price or Gross price (required for new products)
  • vatId: VAT ID (required for new products)
  • barcode: Product barcode (auto-generated if not provided)
  • prdNumber: Reference number (auto-generated if not provided)
  • Other product fields (optional)
  • stock_data: Initial stock data (optional)
  • products_multi: Multi-location data (optional)
  • costs: Product cost data (optional)
  • images_add: Images to add (optional)

Response

{
    "status": "success",
    "message": "All products processed successfully",
    "summary": {
        "total": 2,
        "successful": 2,
        "failed": 0
    },
    "results": [
        {
            "index": 0,
            "status": "success",
            "message": "Product created successfully",
            "data": {
                "pid": 123,
                "product": {...}
            },
            "changes": {...}
        },
        {
            "index": 1,
            "status": "success", 
            "message": "Product updated successfully",
            "data": {
                "pid": 124,
                "product": {...}
            },
            "changes": {...}
        }
    ]
}

Examples

Bulk create and update products:

{
    "username": "api_user",
    "password": "api_pass", 
    "account": "myaccount.com",
    "products": [
        {
            "cid": 1,
            "bid": 2, 
            "price": 29.99,
            "vatId": 1,
            "product_name": "New Product 1",
            "description": "Description for product 1"
        },
        {
            "pid": 123,
            "price": 24.99,
            "stockcurrent": [
                {"location_id": 1, "stock": 50}
            ]
        }
    ]
}

Error Responses

When some products fail, the API returns a 207 status code with partial success information:

{
    "status": "partial_success",
    "message": "Some products failed to process",
    "summary": {
        "total": 3,
        "successful": 2, 
        "failed": 1
    },
    "results": [...]
}

Possible error codes for individual products include:

  • MISSING_REQUIRED_FIELDS: When required fields are missing for new product
  • UPDATE_FAILED: When updating the product fails
  • CREATE_FAILED: When creating the product fails
  • INVALID_STOCK_DATA: When stock data is invalid
  • PRODUCT_NOT_FOUND: When updating a product that doesn't exist