Reference Data | Barcode Types | Set Barcode Types

Setting Product Barcode Types

This document outlines the procedure for making API calls to manage product barcode types data via https://easycms.fi/public_api/set_barcode_types/.

Important Notes

  • All parameters marked as MANDATORY are required
  • This endpoint supports CREATE, UPDATE, and DELETE operations
  • Barcode name and number must be unique

SETTER API ENDPOINT FOR DATA INSERTION

Setter API calls are limited and not available for public API calls, these calls are only available for resellers or certain software providers and developers upon request.


Endpoint and Method

  • Endpoint: https://easycms.fi/public_api/set_barcode_types/
  • Method: POST

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.

CREATE Mode (barcode_id NOT provided)

Parameter Type Required Description
barcode_name string MANDATORY Name of the barcode type (e.g., TYPE_EAN_13)
barcodeNumber integer MANDATORY Numeric identifier for the barcode type
visible integer Optional Visibility flag (1=visible, 0=hidden, default: 1)
parent_id integer Optional Parent barcode type ID (default: 0)

UPDATE Mode (barcode_id provided)

Parameter Type Required Description
barcode_id integer MANDATORY Barcode Type ID to update
barcode_name string Optional New name for the barcode type
barcodeNumber integer Optional New numeric identifier
visible integer Optional New visibility flag
parent_id integer Optional New parent barcode type ID

DELETE Mode

Parameter Type Required Description
barcode_id integer MANDATORY Barcode Type ID to delete
delete integer MANDATORY Set to 1 to delete



Call Examples in Different Languages


# Create new barcode type
curl -X POST 'https://easycms.fi/public_api/set_barcode_types' \
-H 'Authorization1: TOKEN' \
-H 'Content-Type: application/json' \
-d '{
  "username": "USERNAME",
  "password": "PASSWORD",
  "account": "ACCOUNT_ID",
  "barcode_name": "TYPE_QR_CODE",
  "barcodeNumber": 20,
  "visible": 1
}'

# Update existing barcode type
curl -X POST 'https://easycms.fi/public_api/set_barcode_types' \
-H 'Authorization1: TOKEN' \
-H 'Content-Type: application/json' \
-d '{
  "username": "USERNAME",
  "password": "PASSWORD",
  "account": "ACCOUNT_ID",
  "barcode_id": 1,
  "visible": 0
}'

# Delete barcode type
curl -X POST 'https://easycms.fi/public_api/set_barcode_types' \
-H 'Authorization1: TOKEN' \
-H 'Content-Type: application/json' \
-d '{
  "username": "USERNAME",
  "password": "PASSWORD",
  "account": "ACCOUNT_ID",
  "barcode_id": 20,
  "delete": 1
}'

$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://easycms.fi/public_api/set_barcode_types",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_POSTFIELDS => json_encode([
    'username' => 'USERNAME', 
    'password' => 'PASSWORD', 
    'account' => 'ACCOUNT_ID',
    'barcode_name' => 'TYPE_QR_CODE',
    'barcodeNumber' => 20,
    'visible' => 1
  ]),
  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_barcode_types"
headers = {
    "Authorization1": "TOKEN",
    "Content-Type": "application/json"
}
payload = {
    'username': 'USERNAME', 
    'password': 'PASSWORD', 
    'account': 'ACCOUNT_ID',
    'barcode_name': 'TYPE_QR_CODE',
    'barcodeNumber': 20,
    'visible': 1
}
response = requests.post(url, headers=headers, data=json.dumps(payload))
print(response.text)

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

HttpClient client = HttpClient.newHttpClient();
String jsonPayload = """
    {
        "username": "USERNAME",
        "password": "PASSWORD",
        "account": "ACCOUNT_ID",
        "barcode_name": "TYPE_QR_CODE",
        "barcodeNumber": 20,
        "visible": 1
    }
    """;
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://easycms.fi/public_api/set_barcode_types"))
    .headers("Authorization1", "TOKEN", "Content-Type", "application/json")
    .POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
    .build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());

const https = require('https');

const payload = JSON.stringify({
  username: 'USERNAME', 
  password: 'PASSWORD', 
  account: 'ACCOUNT_ID',
  barcode_name: 'TYPE_QR_CODE',
  barcodeNumber: 20,
  visible: 1
});

const options = {
  hostname: 'easycms.fi',
  path: '/public_api/set_barcode_types',
  method: 'POST',
  headers: {
    'Authorization1': 'TOKEN',
    'Content-Type': 'application/json',
    'Content-Length': Buffer.byteLength(payload)
  }
};

const req = https.request(options, (res) => {
  let data = '';
  res.on('data', (chunk) => { data += chunk; });
  res.on('end', () => { console.log(data); });
});
req.on('error', (e) => { console.error(e); });
req.write(payload);
req.end();

import okhttp3.OkHttpClient
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.Request
import okhttp3.RequestBody.Companion.toRequestBody

fun main() {
    val client = OkHttpClient()

    val jsonPayload = """
        {
            "username": "USERNAME",
            "password": "PASSWORD",
            "account": "ACCOUNT_ID",
            "barcode_name": "TYPE_QR_CODE",
            "barcodeNumber": 20,
            "visible": 1
        }
    """.trimIndent()

    val requestBody = jsonPayload.toRequestBody("application/json".toMediaType())

    val request = Request.Builder()
        .url("https://easycms.fi/public_api/set_barcode_types")
        .post(requestBody)
        .addHeader("Authorization1", "TOKEN")
        .build()

    client.newCall(request).execute().use { response ->
        if (!response.isSuccessful) throw IOException("Unexpected code $response")
        println(response.body?.string())
    }
}




Handling Endpoint Results

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:


{
  "status": "success",
  "message": "Barcode type created successfully",
  "data": {
    "barcode_id": "21",
    "barcode_name": "TYPE_QR_CODE",
    "barcodeNumber": "20",
    "visible": "1",
    "parent_id": "0"
  },
  "changes": []
}
    

{
  "status": "success",
  "message": "Barcode type updated successfully",
  "data": {
    "barcode_id": "1",
    "barcode_name": "TYPE_CODE_39",
    "barcodeNumber": "1",
    "visible": "0",
    "parent_id": "0"
  },
  "changes": {
    "visible": {"old": "1", "new": "0"}
  }
}
    

{
  "status": "success",
  "message": "Barcode type deleted successfully",
  "data": {
    "deleted_barcode_id": 21
  },
  "changes": []
}
    

Error Handling

Here are the possible error messages and their meanings:

Error Code HTTP Status Description
MISSING_BARCODE_ID 400 The barcode_id parameter is required for deletion
MISSING_REQUIRED_FIELDS 400 Missing required fields for creation
NO_FIELDS_TO_UPDATE 400 No valid fields provided for update
DUPLICATE_BARCODE_NAME 400 A barcode type with this name already exists
DUPLICATE_BARCODE_NUMBER 400 A barcode type with this number already exists
BARCODE_TYPE_NOT_FOUND 404 Barcode type with the specified barcode_id does not exist
DELETE_FAILED 500 Failed to delete barcode type
UPDATE_FAILED 500 Failed to update barcode type
CREATE_FAILED 500 Failed to create barcode type
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

Error Response Example

{
  "status": "error",
  "error_code": "DUPLICATE_BARCODE_NAME",
  "message": "A barcode type with this name already exists"
}

Best Practices

  1. Use descriptive names - Name barcode types clearly (e.g., TYPE_EAN_13, TYPE_QR_CODE)
  2. Check for duplicates - Ensure barcode_name and barcodeNumber are unique before creating
  3. Use visibility flag - Hide unused barcode types instead of deleting them
  4. Hierarchical structure - Use parent_id for sub-types if needed

Related Endpoints