Create an Option Combination

Endpoint Overview

Option combinations allow you to track inventory for specific combinations of product options. This endpoint enables you to create new option combinations for your products.

POST /api/combinations/

Creates a new option combination for a specific product.

Request Parameters

Pass the following parameters in the HTTP request body according to your specified Content-Type:

Parameter Type Required Description
product_id* integer Yes The unique identifier of the product that the option combination is associated with.
amount integer No How many items of this combination are in stock. Only appears in the Administration panel if the product is tracked with options.
position integer No The lower this number, the higher the option combination appears on the list in the Administration panel.
combination object No The options and variants that comprise the combination. The object keys are option IDs and values are variant IDs.
Note: The options you specify in the combination should be available for the product and should have inventory=Y.
Important: You can't set image_pairs or product_code with the POST request. These can only be set with a subsequent PUT request.

Example Request

{
  "product_id": "4",
  "combination": {
    "24": "74",
    "25": "80",
    "26": "86"
  },
  "amount": "34",
  "position": "10"
}

This request creates a new option combination for the product with product_id=4. This combination consists of:

  • Variant 74 of option 24
  • Variant 80 of option 25
  • Variant 86 of option 26

There are 34 items of this particular combination in stock, and it will appear at position 10 in the admin interface list.

Response Format

Success Response (201 Created)

{
  "combination_hash": "2822626827"
}

Error Response (400 Bad Request)

Returned when the option combination couldn't be created due to invalid parameters or other issues.

Implementation Notes

When creating option combinations, consider the following best practices:

Tip: Option combinations are particularly useful for products with multiple configurable features that affect inventory, such as clothing with different size and color combinations.