This endpoint creates new stock types (units of measure) or updates existing ones through https://easycms.fi/public_api/set_stock_types/. Stock types describe how a product is stocked and sold (e.g. piece, kilogram, package).
https://easycms.fi/public_api/set_stock_types/application/json
Authorization1: {API_TOKEN}username, password, account
stock_type_id)| Parameter | Type | Required | Description |
|---|---|---|---|
| username | string | Yes | API username |
| password | string | Yes | API password |
| account | string | Yes | Account domain |
| stock_type_name | string | object | Yes | Type name. A plain string is stored as en_GB; or pass a {lang: name} object |
| stock_type_number | integer | No | Sorting number. Defaults to MAX + 1 |
| stock_alert_qty | integer | No | Low-stock alert threshold (default 10) |
| parent_id | integer | No | Parent stock type ID (default 0) |
| visible | integer | No | 1 = visible (default), 0 = hidden |
| default_value | integer | No | 1 marks this as the account's default stock type (clears the flag on all others) |
stock_type_id)| Parameter | Type | Required | Description |
|---|---|---|---|
| username | string | Yes | API username |
| password | string | Yes | API password |
| account | string | Yes | Account domain |
| stock_type_id | integer | Yes | Stock type ID to update |
| stock_type_name | string | object | No | New name (string or {lang: name} object) |
| stock_type_number | integer | No | New sorting number |
| stock_alert_qty | integer | No | New alert threshold |
| parent_id | integer | No | Parent stock type ID |
| visible | integer | No | 1 = visible, 0 = hidden |
| default_value | integer | No | 1 marks as default (clears the flag on all others) |
Only the fields you provide are updated. cruom_id is reserved for the cash-register sync and is ignored.
stock_type_number (MAX+1 when omitted), inserts the stock type, and returns the new stock_type_id.stock_type_id exists, applies only the provided fields, and returns the refreshed row plus a changes summary (old → new per field).default_value: 1 clears the flag from every other stock type first — the same rule the admin UI applies.
{
"status": "success",
"message": "Stock type created successfully",
"data": {
"stock_type_id": 9,
"stock_type": {
"stock_type_id": "9",
"cruom_id": null,
"stock_type_number": "9",
"stock_type_name": "a:1:{s:5:\"en_GB\";s:4:\"Kilo\";}",
"stock_alert_qty": "10",
"parent_id": "0",
"visible": "1",
"default_value": "0"
}
},
"changes": {
"stock_type_created": {
"stock_type_id": 9,
"stock_type_number": 9,
"default_value": 0
}
}
}
Update responses carry message: "Stock type updated successfully" and a changes.stock_type object with old/new values per updated field.
| HTTP Code | Error Code | Description |
|---|---|---|
| 400 | MISSING_REQUIRED_FIELDS | stock_type_name missing on create |
| 400 | NOTHING_TO_UPDATE | No valid stock type fields provided on update |
| 404 | STOCK_TYPE_NOT_FOUND | stock_type_id does not exist |
| 500 | CREATE_FAILED / UPDATE_FAILED | Database write failed |
curl -X POST "https://easycms.fi/public_api/set_stock_types/" \
-H "Content-Type: application/json" \
-H "Authorization1: YOUR_API_TOKEN" \
-d '{
"username": "your_username",
"password": "your_password",
"account": "your_account",
"stock_type_name": {"en_GB": "Kilogram", "fi": "Kilogramma"},
"stock_alert_qty": 5
}'
curl -X POST "https://easycms.fi/public_api/set_stock_types/" \
-H "Content-Type: application/json" \
-H "Authorization1: YOUR_API_TOKEN" \
-d '{
"username": "your_username",
"password": "your_password",
"account": "your_account",
"stock_type_id": 9,
"default_value": 1
}'