This document outlines the procedure for making API calls to manage tag-to-product assignments from https://easycms.fi/public_api/set_product_tags_relations/. This endpoint supports adding, replacing, deleting specific, and deleting all tag relations for a product.
The pid (Product ID) parameter is MANDATORY for all operations. Only a single product ID is allowed per request. The tag_ids parameter must be an array of integers (except for delete_all operation).
Manage which tags are assigned to a specific product. The endpoint supports four operations based on the flags provided.
https://easycms.fi/public_api/set_product_tags_relations/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.pid: Product ID (MANDATORY) - A single integer. Must be a valid, non-deleted product ID.| Parameter | Type | Default | Description |
|---|---|---|---|
tag_ids |
Array of integers | - | Tag IDs to assign/remove. Required for add, replace, and delete operations. |
replace |
Integer | 0 | Set to 1 to replace all existing tags with the provided tag_ids. |
delete |
Integer | 0 | Set to 1 to remove specific tag_ids from the product. |
delete_all |
Integer | 0 | Set to 1 to remove ALL tag relations from the product. |
| Operation | Parameters | Description |
|---|---|---|
| Add (default) | pid + tag_ids |
Assign tags to a product. Skips duplicates. |
| Replace | pid + tag_ids + replace=1 |
Remove all existing tags, then assign the provided ones. |
| Delete | pid + tag_ids + delete=1 |
Remove specific tag assignments from the product. |
| Delete All | pid + delete_all=1 |
Remove all tag assignments from the product. |
# Add tags to a product
curl -X POST 'https://easycms.fi/public_api/set_product_tags_relations' \
-H 'Authorization1: TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"username": "USERNAME",
"password": "PASSWORD",
"account": "ACCOUNT_ID",
"pid": 12345,
"tag_ids": [1, 3, 5]
}'
# Replace all tags on a product
curl -X POST 'https://easycms.fi/public_api/set_product_tags_relations' \
-H 'Authorization1: TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"username": "USERNAME",
"password": "PASSWORD",
"account": "ACCOUNT_ID",
"pid": 12345,
"tag_ids": [2, 4],
"replace": 1
}'
# Delete specific tags from a product
curl -X POST 'https://easycms.fi/public_api/set_product_tags_relations' \
-H 'Authorization1: TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"username": "USERNAME",
"password": "PASSWORD",
"account": "ACCOUNT_ID",
"pid": 12345,
"tag_ids": [1, 5],
"delete": 1
}'
# Delete all tags from a product
curl -X POST 'https://easycms.fi/public_api/set_product_tags_relations' \
-H 'Authorization1: TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"username": "USERNAME",
"password": "PASSWORD",
"account": "ACCOUNT_ID",
"pid": 12345,
"delete_all": 1
}'
$curl = curl_init();
$data = [
'username' => 'USERNAME',
'password' => 'PASSWORD',
'account' => 'ACCOUNT_ID',
'pid' => 12345,
'tag_ids' => [1, 3, 5]
];
curl_setopt_array($curl, array(
CURLOPT_URL => "https://easycms.fi/public_api/set_product_tags_relations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => array(
"Authorization1: TOKEN",
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
import json
url = "https://easycms.fi/public_api/set_product_tags_relations"
headers = {
"Authorization1": "TOKEN",
"Content-Type": "application/json"
}
# Add tags
payload = {
'username': 'USERNAME',
'password': 'PASSWORD',
'account': 'ACCOUNT_ID',
'pid': 12345,
'tag_ids': [1, 3, 5]
}
response = requests.post(url, headers=headers, data=json.dumps(payload))
print(response.text)
# Replace all tags
payload = {
'username': 'USERNAME',
'password': 'PASSWORD',
'account': 'ACCOUNT_ID',
'pid': 12345,
'tag_ids': [2, 4],
'replace': 1
}
response = requests.post(url, headers=headers, data=json.dumps(payload))
print(response.text)
# Delete specific tags
payload = {
'username': 'USERNAME',
'password': 'PASSWORD',
'account': 'ACCOUNT_ID',
'pid': 12345,
'tag_ids': [1, 5],
'delete': 1
}
response = requests.post(url, headers=headers, data=json.dumps(payload))
print(response.text)
# Delete all tags
payload = {
'username': 'USERNAME',
'password': 'PASSWORD',
'account': 'ACCOUNT_ID',
'pid': 12345,
'delete_all': 1
}
response = requests.post(url, headers=headers, data=json.dumps(payload))
print(response.text)
HttpClient client = HttpClient.newHttpClient();
String jsonBody = "{\"username\":\"USERNAME\",\"password\":\"PASSWORD\",\"account\":\"ACCOUNT_ID\",\"pid\":12345,\"tag_ids\":[1,3,5]}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://easycms.fi/public_api/set_product_tags_relations"))
.headers("Authorization1", "TOKEN", "Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonBody))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
const https = require('https');
const data = JSON.stringify({
username: 'USERNAME',
password: 'PASSWORD',
account: 'ACCOUNT_ID',
pid: 12345,
tag_ids: [1, 3, 5]
});
const options = {
hostname: 'easycms.fi',
path: '/public_api/set_product_tags_relations',
method: 'POST',
headers: {
'Authorization1': 'TOKEN',
'Content-Type': 'application/json',
'Content-Length': data.length
}
};
const req = https.request(options, (res) => {
let responseData = '';
res.on('data', (chunk) => { responseData += chunk; });
res.on('end', () => { console.log(responseData); });
});
req.on('error', (e) => { console.error(e); });
req.write(data);
req.end();
import React, { useState } from 'react';
function ManageTags() {
const [response, setResponse] = useState('');
const addTags = async () => {
try {
const res = await fetch('https://easycms.fi/public_api/set_product_tags_relations', {
method: 'POST',
headers: {
'Authorization1': 'TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
username: 'USERNAME',
password: 'PASSWORD',
account: 'ACCOUNT_ID',
pid: 12345,
tag_ids: [1, 3, 5]
})
});
const data = await res.json();
setResponse(JSON.stringify(data, null, 2));
} catch (error) {
console.error(error);
}
};
return (
<div>
<button onClick={addTags}>Add Tags</button>
<pre>{response}</pre>
</div>
);
}
export default ManageTags;
import okhttp3.OkHttpClient
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.Request
fun main() {
val client = OkHttpClient()
val json = """
{
"username": "USERNAME",
"password": "PASSWORD",
"account": "ACCOUNT_ID",
"pid": 12345,
"tag_ids": [1, 3, 5]
}
""".trimIndent()
val body = json.toRequestBody("application/json".toMediaType())
val request = Request.Builder()
.url("https://easycms.fi/public_api/set_product_tags_relations")
.post(body)
.addHeader("Authorization1", "TOKEN")
.build()
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) throw IOException("Unexpected code $response")
println(response.body?.string())
}
}
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
var token = "TOKEN";
var payload = new {
username = "USERNAME",
password = "PASSWORD",
account = "ACCOUNT_ID",
pid = 12345,
tag_ids = new[] { 1, 3, 5 }
};
var json = JsonSerializer.Serialize(payload);
var content = new StringContent(json, Encoding.UTF8, "application/json");
using (var httpClient = new HttpClient())
{
httpClient.DefaultRequestHeaders.Add("Authorization1", token);
var response = await httpClient.PostAsync("https://easycms.fi/public_api/set_product_tags_relations", content);
if (response.IsSuccessStatusCode)
{
var responseData = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseData);
}
else
{
Console.WriteLine($"Error: {response.StatusCode}");
}
}
}
}
When you make a request to the endpoint, you receive a JSON response containing various keys and values. Here's an explanation of the response keys and their meanings:
- `start`: The starting index for pagination. Default is 0.
- `limit`: The maximum number of records returned. Default is 50.
- `pid`: The product ID that was operated on.
- `count`: The number of tag relations currently assigned to the product after the operation.
- `total_count`: The total number of tag relations currently assigned to the product.
- `docs`: URL to this documentation page.
#### OUTPUT object:
- `response_type`: Response status - "success" or "error".
- `message`: Status message describing the result of the operation.
- `tags`: Array of currently assigned tags for the product (after the operation).
- `id`: The internal ID of the tag relation record.
- `pid`: The product ID.
- `products_tags_id`: The unique identifier for the tag.
- `products_tags_name`: An object containing tag names in different languages.
- `visible`: Visibility status of the tag.
- `image_name`: The filename of the image associated with the tag.
#### changes object:
- **Add operation:**
- `added`: Array of tag IDs that were successfully added.
- `skipped_duplicates`: Array of tag IDs that already existed and were skipped.
- **Replace operation:**
- `replaced`: Boolean indicating a replace operation was performed.
- `old_deleted`: Number of previous relations that were removed.
- `added`: Array of tag IDs that were added.
- **Delete operation:**
- `deleted`: Number of tag relations that were removed.
- `tag_ids_processed`: Array of tag IDs that were processed for deletion.
- **Delete All operation:**
- `deleted_all`: Number of tag relations that were removed.
#### Add Tags Response Example:
{
"INFO": {
"start": 0,
"limit": 50,
"count": 3,
"total_count": 3,
"pid": 12345,
"docs": "https://cms.helpostikotisivut.fi/DOCUMENTATION/bt5/set_product_tags_relations"
},
"OUTPUT": {
"response_type": "success",
"message": "Tag relations added successfully",
"tags": [
{
"id": "15",
"pid": "12345",
"products_tags_id": "1",
"products_tags_name": {
"fi_FI": "Uutuus",
"en_GB": "New",
"sv_SE": "Nyhet"
},
"visible": "1",
"image_name": "new-icon.png"
},
{
"id": "23",
"pid": "12345",
"products_tags_id": "3",
"products_tags_name": {
"fi_FI": "Alennus",
"en_GB": "Discount",
"sv_SE": "Rabatt"
},
"visible": "1",
"image_name": "discount-icon.png"
},
{
"id": "24",
"pid": "12345",
"products_tags_id": "5",
"products_tags_name": {
"fi_FI": "Suosittu",
"en_GB": "Popular",
"sv_SE": "Popul\u00e4r"
},
"visible": "1",
"image_name": "popular-icon.png"
}
]
},
"changes": {
"added": [1, 3, 5],
"skipped_duplicates": []
}
}
#### Replace Tags Response Example:
{
"INFO": {
"start": 0,
"limit": 50,
"count": 2,
"total_count": 2,
"pid": 12345,
"docs": "https://cms.helpostikotisivut.fi/DOCUMENTATION/bt5/set_product_tags_relations"
},
"OUTPUT": {
"response_type": "success",
"message": "Tag relations replaced successfully",
"tags": [
{
"id": "25",
"pid": "12345",
"products_tags_id": "2",
"products_tags_name": {
"fi_FI": "Tarjous",
"en_GB": "Sale",
"sv_SE": "Rea"
},
"visible": "1",
"image_name": null
},
{
"id": "26",
"pid": "12345",
"products_tags_id": "4",
"products_tags_name": {
"fi_FI": "Varattu",
"en_GB": "Reserved",
"sv_SE": "Reserverad"
},
"visible": "1",
"image_name": null
}
]
},
"changes": {
"replaced": true,
"old_deleted": 3,
"added": [2, 4]
}
}
#### Delete Specific Tags Response Example:
{
"INFO": {
"start": 0,
"limit": 50,
"count": 1,
"total_count": 1,
"pid": 12345,
"docs": "https://cms.helpostikotisivut.fi/DOCUMENTATION/bt5/set_product_tags_relations"
},
"OUTPUT": {
"response_type": "success",
"message": "Tag relations deleted successfully",
"tags": [
{
"id": "26",
"pid": "12345",
"products_tags_id": "4",
"products_tags_name": {
"fi_FI": "Varattu",
"en_GB": "Reserved",
"sv_SE": "Reserverad"
},
"visible": "1",
"image_name": null
}
]
},
"changes": {
"deleted": 1,
"tag_ids_processed": [2]
}
}
#### Delete All Tags Response Example:
{
"INFO": {
"start": 0,
"limit": 50,
"pid": 12345,
"docs": "https://cms.helpostikotisivut.fi/DOCUMENTATION/bt5/set_product_tags_relations"
},
"OUTPUT": {
"response_type": "success",
"message": "All tag relations deleted successfully",
"tags": []
},
"changes": {
"deleted_all": 1
}
}
Here are the possible error messages and their meanings:
| Error Code | HTTP Status | Description |
|---|---|---|
pid_parameter_is_required |
400 | The pid parameter is required |
pid_must_be_a_single_integer_arrays_are_not_allowed |
400 | Only a single integer pid is accepted, arrays are not allowed |
pid_must_be_a_valid_positive_integer |
400 | The pid must be a valid positive integer greater than 0 |
product_not_found |
404 | The product with the specified pid does not exist or has been deleted |
tag_ids_must_be_a_non_empty_array_of_integers |
400 | tag_ids must be a non-empty array of positive integers |
tag_ids_must_contain_valid_positive_integers |
400 | tag_ids contains invalid (non-positive) values |
following_tag_ids_do_not_exist |
400 | One or more tag IDs do not exist in the system |
UN-AUTHORIZED |
401 | Incorrect username or password |
this_account_does_not_exist_or_your_credentials_do_not_match_this_account |
401 | The account doesn't exist or mismatched credentials |
{
"INFO": {
"start": 0,
"limit": 50,
"count": 0,
"total_count": 0
},
"OUTPUT": {
"response_type": "error",
"message": "product_not_found"
}
}
{
"INFO": {
"start": 0,
"limit": 50,
"count": 0,
"total_count": 0
},
"OUTPUT": {
"response_type": "error",
"message": "following_tag_ids_do_not_exist",
"nonexistent_tag_ids": [99, 100]
}
}
POST /set_product_tags_relations
Body: { "pid": 12345, "tag_ids": [1, 3, 5] }
POST /set_product_tags_relations
Body: { "pid": 12345, "tag_ids": [2, 4], "replace": 1 }
POST /set_product_tags_relations
Body: { "pid": 12345, "tag_ids": [1, 5], "delete": 1 }
POST /set_product_tags_relations
Body: { "pid": 12345, "delete_all": 1 }
Use this endpoint together with get_product_tags_relations to manage product tags:
// 1. Get current tags
const currentTags = await getProductTagsRelations({ pid: 12345 });
// 2. Add new tags
await setProductTagsRelations({
pid: 12345,
tag_ids: [1, 3, 5]
});
// 3. Replace all tags
await setProductTagsRelations({
pid: 12345,
tag_ids: [2, 4],
replace: 1
});
// 4. Remove specific tags
await setProductTagsRelations({
pid: 12345,
tag_ids: [2],
delete: 1
});
// 5. Remove all tags
await setProductTagsRelations({
pid: 12345,
delete_all: 1
});