This document outlines the procedure for making API calls to attach attribute sets to a product, set its ask-at-sale flag and write its per-product attribute rule overrides via https://easycms.fi/public_api/set_product_attributes/.
pid parameter is MANDATORY for all operationsattributeset_ids works as REPLACE-ALL: the product's attached sets become exactly the posted list, in the posted order; an empty array detaches every set. Omit the key entirely to leave attachments untouchedINVALID_ATTRIBUTE_SET_ID otherwise) — fetch valid ids from get_product_attributesattributeset_id column (the cash register carries one set per product)use_rules writes the product's per-product rule overrides (selection type, max options, default selections, group lock, included-pricing per group) with the same semantics as the CMS Attributes tab: sparse per-field writes, -1 = inherit the set's shared default, and a row that ends fully at inherit is deleted (the rules table stays sparse)use_id in use_rules must belong to one of the product's attached sets — when attributeset_ids is posted in the SAME call, the new list countsPOST only, Content-Type: application/jsonhttps://easycms.fi/public_api/set_product_attributes/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. | Parameter | Type | Description |
|---|---|---|
pid |
integer | Product ID (MANDATORY) |
| Parameter | Type | Description |
|---|---|---|
attributeset_ids |
array of UUIDs (or comma-separated string) | REPLACE-ALL list of attribute-set ids in attachment order. Key present + empty array = detach all. Key absent = leave attachments untouched |
isverpatrib |
1/0 | Ask for attribute values when the product is added to order/invoice lines |
use_rules |
object keyed by use_id (or array of {use_id, ...} objects) |
Per-product rule overrides — each entry object accepts any of the sparse fields below (only posted fields are written). default_value_ids: array of option UUIDs (also {id: true} map or CSV string); [] = this product pre-selects NOTHING; omit = inherit; single-choice groups keep the first id only. max_allowed_options: -1 inherit / >=0 this product's own max. select_type: -1/0 single choice/1 multi select. locked: -1/0/1 — locked group's selections are frozen at the sale for every user and every role (the defaults always apply; a fully locked product shows no picker). included_pricing: -1/0/1 — included-options pricing: the first max_allowed_options selections ring 0, extras charge the option's price (unlocked: the free slots follow the picks; locked: the free set is the pinned defaults capped at the max). Keep max_allowed_options >= the number of default_value_ids — the CMS builder enforces the same invariant. reset: true — drop this product's override row (full inheritance) |
{
"success": true,
"message": "Product attributes updated successfully",
"action": "set_attachments+set_rules+set_flag",
"data": {
"pid": 25327,
"attributeset_ids": ["f37c7663-1a60-4134-ac48-75bd3f27b3e1"],
"attributeset_id": "f37c7663-1a60-4134-ac48-75bd3f27b3e1",
"isverpatrib": 1,
"use_rules": {
"a82a4ace-...": { "default_value_ids": ["c1d0f5aa-..."], "max_allowed_options": 3, "select_type": -1, "locked": 1, "included_pricing": -1 }
}
},
"changes": {
"isverpatrib": { "old": 0, "new": 1 },
"attachments": { "inserted": 1, "deleted": 0, "unchanged": 0 },
"use_rules": { "a82a4ace-...": { "status": "saved", "fields": ["default_value_ids", "max_allowed_options", "locked"] } }
}
}
data.use_rules — the product's stored overrides after the call (-1 / null = inherit the set's shared default); present only when use_rules was postedchanges.use_rules — per use_id: status (saved / reset) and the written fields; reset (or everything back at inherit) deleted the override row| error_code | When |
|---|---|
MISSING_PID / PRODUCT_NOT_FOUND |
pid missing, unknown or deleted |
INVALID_ATTRIBUTESET_IDS |
attributeset_ids is neither array nor CSV string |
INVALID_ATTRIBUTE_SET_ID |
one or more set ids do not exist (list included in message) |
INVALID_BOOLEAN_VALUE |
isverpatrib not 1/0 or true/false |
INVALID_USE_RULES |
use_rules is not an object keyed by use_id (or an array of {use_id, ...} objects) |
INVALID_USE_RULE_USE_ID |
one or more use_ids do not exist (list in message) |
INVALID_USE_RULE_TARGET |
the use row belongs to a set not attached to this product — attach it via attributeset_ids first |
INVALID_DEFAULT_VALUE_ID |
default_value_ids contains unknown option ids (list in message) |
INVALID_RULE_VALUE |
a rule field holds an invalid value (message names the use_id and field) |
RULES_UPGRADE_PENDING |
the account has not upgraded to per-product rules (v3.119) yet, or the locked (v3.128) / included_pricing (v3.129) column is missing |
NO_FIELDS_TO_UPDATE |
none of attributeset_ids, use_rules, isverpatrib posted |
SYNC_FAILED |
diff-save failed — previous state intact |
# Attach two sets (in order) and enable ask-at-sale
curl -X POST 'https://easycms.fi/public_api/set_product_attributes' \
-H 'Authorization1: TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"username": "USERNAME",
"password": "PASSWORD",
"account": "ACCOUNT_ID",
"pid": 25327,
"attributeset_ids": ["f37c7663-1a60-4134-ac48-75bd3f27b3e1", "9c2e08d1-4b77-4a09-9d21-6f0b3e5a7c44"],
"isverpatrib": 1
}'
# Detach every set
curl -X POST 'https://easycms.fi/public_api/set_product_attributes' \
-H 'Authorization1: TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"username": "USERNAME",
"password": "PASSWORD",
"account": "ACCOUNT_ID",
"pid": 25327,
"attributeset_ids": []
}'
# Only flip the ask-at-sale flag (attachments untouched)
curl -X POST 'https://easycms.fi/public_api/set_product_attributes' \
-H 'Authorization1: TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"username": "USERNAME",
"password": "PASSWORD",
"account": "ACCOUNT_ID",
"pid": 25327,
"isverpatrib": 0
}'
# Per-product rule override: lock the toppings group for this product,
# allow/max 3 picks and set its default selections (fetch use_id and
# value ids from get_product_attributes product mode)
curl -X POST 'https://easycms.fi/public_api/set_product_attributes' \
-H 'Authorization1: TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"username": "USERNAME",
"password": "PASSWORD",
"account": "ACCOUNT_ID",
"pid": 25327,
"use_rules": {
"a82a4ace-9c1d-4e2b-8f34-0b1d2c3e4f5a": {
"locked": 1,
"max_allowed_options": 3,
"default_value_ids": ["c1d0f5aa-1111-4111-8111-111111111111", "e9b8d701-2222-4222-8222-222222222222"]
}
}
}'
# Drop one product's override (inherit the set's shared rules again)
curl -X POST 'https://easycms.fi/public_api/set_product_attributes' \
-H 'Authorization1: TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"username": "USERNAME",
"password": "PASSWORD",
"account": "ACCOUNT_ID",
"pid": 25327,
"use_rules": { "a82a4ace-9c1d-4e2b-8f34-0b1d2c3e4f5a": { "reset": true } }
}'
$ch = curl_init('https://easycms.fi/public_api/set_product_attributes');
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,
'attributeset_ids' => ['f37c7663-1a60-4134-ac48-75bd3f27b3e1'],
'isverpatrib' => 1
])
]);
$response = json_decode(curl_exec($ch), true);
// $response['changes']['attachments'] = inserted/deleted/unchanged
const res = await fetch('https://easycms.fi/public_api/set_product_attributes', {
method: 'POST',
headers: { 'Authorization1': 'TOKEN', 'Content-Type': 'application/json' },
body: JSON.stringify({
username: 'USERNAME', password: 'PASSWORD', account: 'ACCOUNT_ID',
pid: 25327,
attributeset_ids: ['f37c7663-1a60-4134-ac48-75bd3f27b3e1'],
isverpatrib: 1
})
});
const data = await res.json();
// data.data.attributeset_ids = final attachment order
val body = """{"username":"USERNAME","password":"PASSWORD",
"account":"ACCOUNT_ID","pid":25327,
"attributeset_ids":["f37c7663-1a60-4134-ac48-75bd3f27b3e1"],
"isverpatrib":1}"""
val req = Request.Builder()
.url("https://easycms.fi/public_api/set_product_attributes")
.header("Authorization1", "TOKEN")
.post(body.toRequestBody("application/json".toMediaType()))
.build()
val data = JSONObject(client.newCall(req).execute().body!!.string())
// data.getJSONObject("data").getJSONArray("attributeset_ids")