PXM Products/
PXM Product Variations/
PXM Product Variation Modifiers API/
Create a Modifier

Create a Modifier

POST Create a Modifier

https://api.moltin.com/pcm/variations/:variationId/options/:optionId/modifiers

  • Ensure that an option ID is provided in the request to create modifier for the option.
  • Modifier values can only contain A-Z, a-z, 0 to 9, -, and _. No spaces or special characters are allowed.

Use one of the following for modifier types and corresponding values:

  • commodity_type : Provide physical or digital
  • status: Provide live or draft.
  • description_append : Provide a value to append with the description.
  • description_prepend: Provide a value to prepend with the description.
  • description_equals : Provide a value for the description.
  • name_append: Provide a value to append with the name.
  • name_prepend: Provide a value to prepend with the name.
  • name_equals : Provide a value for the name.
  • sku_append: Provide a value to append with the SKU.
  • sku_prepend: Provide a value to prepend with the SKU.
  • sku_equals : Provide a value for the SKU.
  • slug_append: Provide a value to append with the slug.
  • slug_prepend: Provide a value to prepend with the slug.
  • slug_equals : Provide a value for the slug.

You need not provide values for slug_builder and sku_builder. These modifier use seek and set. The string provided for set replaces all the strings that match the value provided in seek. For example, if you set "seek":"{color}" and "set":"red", all strings that match "{color}" are replaced with red. For more information, see the Modifiers section.

Parameters

Path parameters

NameRequiredTypeDescription
optionIdRequiredstringThe ID of the option for which you want to provide a modifier.

Headers

NameRequiredTypeDescription
AuthorizationRequiredstringThe Bearer token required to get access to the API.

Body

NameRequiredTypeDescription
typeRequiredstringThe type of resource object. You must use product-variation-modifier.
attributes.typeRequiredstringThe type of the modifier.
attributes.valueRequired for non-builder modifiersstringThe value of the modifier type.
seekRequired for builder modifiersstringThe sub-string to find and replace enclosed in curly brackets for slug_builder and sku_builder.
setRequired for builder modifiersstringThe value to replace matches the seek string for slug_builder and sku_builder.

Request example

curl -X POST https://api.moltin.com/pcm/variations/:variationId/options/:optionId/modifiers
     -H "Authorization: Bearer XXXX" \
     -H "Content-Type: application/json" \
     -d $'{
        "data": {
          "type": "product-variation-modifier",
          "attributes": {
              "seek": "{color}",
              "set": "red",
              "type": "slug_builder"
            }
        }
    }'

This request creates a product variation modifier with the attributes that are defined in the body as in the following response:

Response example

201 Created

{
    "data": {
        "type": "product-variation-modifier",
        "id": "310e10f1-9bb9-4bdd-99ec-b9b0e4d54d5d",
        "attributes": {
            "seek": "{color}",
            "set": "red",
            "type": "slug_builder"
        }
    }
}

Was this helpful?

Previous
Get a Modifier

Learn

Docs