Inventory & Products | Products | Auxiliaries | Set Product Auxiliaries

Setting Product Auxiliaries

This document outlines the procedure for making API calls to manage a product's auxiliary flag and auxiliary-product assignments via https://easycms.fi/public_api/set_product_auxiliaries/.

Important Notes

  • All parameters marked as MANDATORY are required
  • The pid parameter is MANDATORY for all operations
  • MUTUAL EXCLUSION: a product is EITHER an auxiliary (is_auxiliary = 1) OR a carrier of auxiliaries — never both. The flag wins: turning is_auxiliary on clears every assignment; posting assignments forces the flag off
  • aux_products works as REPLACE-ALL: assignments become exactly the posted list; an empty array removes all assignments. Omit the key entirely to leave assignments untouched
  • Every posted product id must exist and be non-deleted (AUXILIARY_PRODUCT_NOT_FOUND otherwise); products not flagged is_auxiliary = 1 are accepted but reported in non_auxiliary_pids (the CMS picker only lists flagged ones)
  • Assignments are diff-saved: unchanged pairs are not rewritten
  • Like every public-api product setter this writes the CMS database only — no cash-register push happens here
  • POST only, Content-Type: application/json

Endpoint and Method

  • Endpoint: https://easycms.fi/public_api/set_product_auxiliaries/
  • Method: POST only
  • Content-Type: application/json

Parameters | Payload

  • TOKEN (api_key): Your unique API key for authentication. How to Create API Credentials.
  • username: Your login username.
  • password: Your login password.
  • account: Your specific account ID.

Required Parameters (for all operations)

Parameter Type Description
pid integer Product ID (MANDATORY)

Optional Parameters (at least one required)

Parameter Type Description
is_auxiliary 1/0 Mark THIS product as an auxiliary (companion) product — excluded from the normal catalog, offered under carriers
aux_products array of integers (or comma-separated string) REPLACE-ALL list of auxiliary product ids offered under this carrier. Key present + empty array = remove all. Key absent = untouched



Successful Response

{
  "success": true,
  "message": "Product auxiliaries updated successfully",
  "action": "set_assignments+set_flag",
  "data": {
    "pid": 25327,
    "is_auxiliary": 0,
    "aux_products": [25344, 25345]
  },
  "changes": {
    "is_auxiliary": { "old": 1, "new": 0 },
    "assignments": { "inserted": 2, "deleted": 0, "unchanged": 0 }
  }
}

Errors

error_code When
MISSING_PID / PRODUCT_NOT_FOUND pid missing, unknown or deleted
INVALID_AUX_PRODUCTS aux_products is neither array nor CSV string
AUXILIARY_PRODUCT_NOT_FOUND one or more posted ids are unknown or deleted (list in message)
INVALID_BOOLEAN_VALUE is_auxiliary not 1/0 or true/false
NO_FIELDS_TO_UPDATE neither is_auxiliary nor aux_products posted
SYNC_FAILED diff-save failed — previous state intact



Call Examples in Different Languages


# Offer two add-ons under a product
curl -X POST 'https://easycms.fi/public_api/set_product_auxiliaries' \
-H 'Authorization1: TOKEN' \
-H 'Content-Type: application/json' \
-d '{
  "username": "USERNAME",
  "password": "PASSWORD",
  "account": "ACCOUNT_ID",
  "pid": 25327,
  "aux_products": [25344, 25345]
}'

# Mark a product itself as an auxiliary (clears its own assignments, if any)
curl -X POST 'https://easycms.fi/public_api/set_product_auxiliaries' \
-H 'Authorization1: TOKEN' \
-H 'Content-Type: application/json' \
-d '{
  "username": "USERNAME",
  "password": "PASSWORD",
  "account": "ACCOUNT_ID",
  "pid": 25344,
  "is_auxiliary": 1
}'

# Remove every assignment from a carrier
curl -X POST 'https://easycms.fi/public_api/set_product_auxiliaries' \
-H 'Authorization1: TOKEN' \
-H 'Content-Type: application/json' \
-d '{
  "username": "USERNAME",
  "password": "PASSWORD",
  "account": "ACCOUNT_ID",
  "pid": 25327,
  "aux_products": []
}'

$ch = curl_init('https://easycms.fi/public_api/set_product_auxiliaries');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => ['Authorization1: TOKEN', 'Content-Type: application/json'],
    CURLOPT_POSTFIELDS => json_encode([
        'username' => 'USERNAME',
        'password' => 'PASSWORD',
        'account'  => 'ACCOUNT_ID',
        'pid'      => 25327,
        'aux_products' => [25344, 25345]
    ])
]);
$response = json_decode(curl_exec($ch), true);
// $response['data']['aux_products'] = final assignment list

const res = await fetch('https://easycms.fi/public_api/set_product_auxiliaries', {
  method: 'POST',
  headers: { 'Authorization1': 'TOKEN', 'Content-Type': 'application/json' },
  body: JSON.stringify({
    username: 'USERNAME', password: 'PASSWORD', account: 'ACCOUNT_ID',
    pid: 25327,
    aux_products: [25344, 25345]
  })
});
const data = await res.json();
// data.changes.assignments = { inserted, deleted, unchanged }

val body = """{"username":"USERNAME","password":"PASSWORD",
  "account":"ACCOUNT_ID","pid":25327,
  "aux_products":[25344,25345]}"""
val req = Request.Builder()
    .url("https://easycms.fi/public_api/set_product_auxiliaries")
    .header("Authorization1", "TOKEN")
    .post(body.toRequestBody("application/json".toMediaType()))
    .build()
val data = JSONObject(client.newCall(req).execute().body!!.string())
// data.getJSONObject("data").getJSONArray("aux_products")