Orders | Set Order

Order Creation Endpoint

This document provides guidance on using the API to create a new order for a specific customer in the API server's database through the set_order endpoint. This involves two steps: API authentication and order creation.

API ENDPOINT FOR ORDER CREATION

This API call is essential for creating new orders associated with customers in the system.

Order Creation Process

To create an order for a customer, follow the steps below using the set_order API call. The process involves providing credentials for API login and specific details for order creation.

Endpoint and Method

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

Parameters | Payload

For order creation, you need to provide two sets of parameters - one for API authentication and the other for the order details.

API Authentication Parameters

  • 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.

Order Creation Parameters

  • customer_id: The ID of the customer for whom the order is being created.
  • items: A list or array of items to be included in the order, each with details such as item ID, quantity, and price.
  • order_date: The date of the order placement.
  • delivery_details: Information regarding the delivery of the order, including address, delivery date, and any specific instructions.
  • payment_method: The method of payment chosen for this order.
  • additional_notes: Any additional notes or instructions regarding the order.

Handling Responses

After making the POST request, handle the API responses accordingly. The response will typically include confirmation of order creation, an order ID, and any relevant error messages in case of issues.

  • email: Email (String) - The email address associated with the account.
  • customer_password: Customer Password (String) - The password for the customer.
  • customer_id: Customer ID (Integer) - The identifier of the customer (integer).
  • no_vat: No VAT (Integer) - Indicates whether VAT is applicable or not (integer).
  • sale_price_by_net_margin: Sale Price by Net Margin (Integer) - Indicates whether sale price is calculated by net margin (integer).
  • sale_price_by_net_margin_percentage: Sale Price by Net Margin Percentage (Integer) - The percentage for sale price calculation (integer).
  • ignore_customer_pricing: Ignore Customer Pricing (Integer) - Indicates whether customer pricing is ignored (integer).
  • order_date: Order Date (String) - The date of the order.
  • shipping_method: Shipping Method (Integer) - The shipping method identifier (integer).
  • delivery_date: Delivery Date (String) - The date of delivery.
  • shipping_address: Shipping Address (String) - The shipping address.
  • shipping_postal: Shipping Postal (String) - The postal code for shipping.
  • shipping_city_id: Shipping City ID (Integer) - The identifier of the shipping city (integer).
  • shipping_country_id: Shipping Country ID (Integer) - The identifier of the shipping country (integer).
  • discount: Discount (Integer) - The discount amount (integer).
  • paid_date: Paid Date (String) - The date when the payment is made.
  • phone: Phone (String) - The phone number.
  • phone_full: Full Phone (String) - The full phone number including the country code.
  • phone_prefix: Phone Prefix (String) - The phone prefix.
  • admin_id: Admin ID (Integer) - The identifier of the admin user (integer).
  • loading_employee_id: Loading Employee ID (Integer) - The identifier of the loading employee (integer).
  • loading_employee_name: Loading Employee Name (String) - The name of the loading employee.
  • delivery_employee_id: Delivery Employee ID (Integer) - The identifier of the delivery employee (integer).
  • delivery_employee_name: Delivery Employee Name (String) - The name of the delivery employee.
  • payer_details: Payer Details (String) - Details of the payer.
  • payee_details: Payee Details (String) - Details of the payee.
  • note: Note (String) - A note associated with the order.
  • delivery_instructions: Delivery Instructions (String) - Instructions for the delivery.
  • order_by: Order By (String) - The order made by a specific customer.
  • country_id: Country ID (Integer) - The identifier of the country (integer).
  • city_id: City ID (Integer) - The identifier of the city (integer).
  • currency_rate: Currency Rate (Float) - The exchange rate for currency (float).
  • currency_country_id: Currency Country ID (Integer) - The identifier of the currency country (integer).
  • customer_language: Customer Language (String) - The language chosen by the customer.
  • customer_language_id: Customer Language ID (Integer) - The identifier of the customer language (integer).
  • customer_discount: Customer Discount (Integer) - The discount applicable to the customer (integer).
  • order_lines[0][line_type]: Line Type (Integer) - The type of order line (integer).
  • order_lines[0][number]: Line Number (Integer) - The line number (integer).
  • order_lines[0][product_name][fi]: Product Name in Finnish (String) - The product name in Finnish.
  • order_lines[0][product_name][en_gb]: Product Name in English (Great Britain) (String) - The product name in English.
  • order_lines[0][product_name][de]: Product Name in German (String) - The product name in German.
  • order_lines[0][product_name][fa]: Product Name in Persian (String) - The product name in Persian.
  • order_lines[0][pid]: Product ID (Integer) - The identifier of the product (integer).
  • order_lines[0][prdNumber]: Product Number (Integer) - The product number (integer).
  • order_lines[0][stock_type_id]: Stock Type ID (Integer) - The identifier of the stock type (integer).
  • order_lines[0][stock_type_name][fi]: Stock Type Name in Finnish (String) - The stock type name in Finnish.
  • order_lines[0][stock_type_name][en_gb]: Stock Type Name in English (Great Britain) (String) - The stock type name in English.
  • order_lines[0][stock_type_name][de]: Stock Type Name in German (String) - The stock type name in German.
  • order_lines[0][stock_type_name][fa]: Stock Type Name in Persian (String) - The stock type name in Persian.
  • order_lines[0][stock_available]: Stock Available (Float) - The available stock quantity (float).
  • order_lines[0][vat_id]: VAT ID (Integer) - The identifier of VAT for this order line (integer).
  • order_lines[0][vat_percent]: VAT Percentage (Float) - The VAT percentage (float).
  • order_lines[0][unit_price]: Unit Price (Float) - The unit price (float).
  • order_lines[0][unit_price_buy]: Unit Price Buy (Float) - The unit price for buying (float).
  • order_lines[0][customer_pricing_ignored]: Customer Pricing Ignored (Integer) - Indicates whether customer pricing is ignored for this order line (integer).
  • order_lines[0][vat_id_buy]: VAT ID Buy (Integer) - The VAT ID for buying (integer).
  • order_lines[0][quantity]: Quantity (Integer) - The quantity ordered (integer).
  • order_lines[0][weight]: Weight (Integer) - The weight of the product (integer).
  • order_lines[0][weight_type]: Weight Type (String) - The type of weight measurement (String).
  • order_lines[0][location]: Location (String) - The location of the product.
  • order_lines[0][location_id]: Location ID (String) - The identifier of the location.
  • order_lines[0][supplier_id]: Supplier ID (Integer) - The identifier of the supplier (integer).
  • order_lines[0][best_before_date]: Best Before Date (String) - The best before date of the product.
  • order_lines[0][discount]: Discount (Integer) - The discount applicable to this order line (integer).
  • order_lines[0][barcode]: Barcode (String) - The barcode of the product.
  • order_lines[0][barcode_id]: Barcode ID (Integer) - The identifier of the barcode (integer).
  • order_lines[0][barcode_type]: Barcode Type (String) - The type of barcode.
  • order_lines[0][line_note]: Line Note (String) - A note associated with this order line.
  • order_lines[0][category_name]: Category Name (String) - The name of the product category.
  • order_lines[0][customer_pricing_exist]: Customer Pricing Exist (String) - Indicates whether customer pricing information exists for this order line.
  • order_lines[0][stock_available_now]: Stock Available Now (Float) - The available stock quantity at the moment (float).
  • order_lines[0][stock_alert_qty]: Stock Alert Quantity (Integer) - The quantity at which a stock alert is triggered (integer).
  • order_lines[0][stock_alert_bbd]: Stock Alert Best Before Date (Integer) - The best before date for stock alert (integer).
  • order_lines[0][relation_qty_type]: Relation Quantity Type (String) - The type of relation quantity.
  • order_lines[0][box_qty]: Box Quantity (Integer) - The quantity in boxes (integer).
  • order_lines[0][pallet_qty]: Pallet Quantity (Integer) - The quantity in pallets (integer).
  • order_lines[0][pallet_qty_type]: Pallet Quantity Type (String) - The type of pallet quantity.
  • order_lines[0][customer_id]: Customer ID (Integer) - The identifier of the customer associated with this order line (integer).
  • order_lines[0][ignore_customer_pricing]: Ignore Customer Pricing (Integer) - Indicates whether customer pricing is ignored for this order line (integer).
  • order_lines[0][symbol]: Symbol (String) - The symbol associated with the product price.
  • order_lines[0][vat_percent_buy]: VAT Percentage Buy (Float) - The VAT percentage for buying (float).
  • order_lines[0][stock_type_measure]: Stock Type Measure (Integer) - The measurement type of stock (integer).
  • calculate_line_pricing_internally: Calculate Line Pricing Internally (Integer) - Indicates whether line pricing is calculated internally (integer).
  • status: Status (Integer) - The status of the order (integer).
  • payment_status: Payment Status (Integer) - The payment status of the order (integer).



Call Examples in Different Languages


curl -X POST 'https://easycms.fi/public_api/set_order' \
-H 'Authorization1: TOKEN' \
-d 'username=USERNAME&password=PASSWORD&account=ACCOUNT_ID&email=customer@mail.com&customer_password=YOUR_CUSTOMER_PASSWORD&customer_id=361&no_vat=0&sale_price_by_net_margin=0&sale_price_by_net_margin_percentage=0&ignore_customer_pricing=0&order_date=2022-8-04%2019%3A26%3A58&shipping_method=1&delivery_date=2022-8-04%2019%3A26%3A58&shipping_address=&shipping_postal=2550&shipping_city_id=25&shipping_country_id=50&discount=0&paid_date=&phone=44%207004050&phone_full=%2B358447004050&phone_prefix=358&admin_id=163&loading_employee_id=0&loading_employee_name=&delivery_employee_id=0&delivery_employee_name=&payer_details=&payee_details=¬e=DELIVER%20ON%20MONDAY%2008.03.2021!&delivery_instructions=&order_by=API_customer&country_id=40&city_id=1¤cy_rate=1¤cy_country_id=40&customer_language=fi&customer_language_id=1&customer_discount=0&order_lines%5B0%5D%5Bline_type%5D=0&order_lines%5B0%5D%5Bnumber%5D=1&order_lines%5B0%5D%5Bproduct_name%5D%5Bfi%5D=Testi&order_lines%5B0%5D%5Bproduct_name%5D%5Ben_gb%5D=Test&order_lines%5B0%5D%5Bproduct_name%5D%5Bde%5D=Test%20GERMAN&order_lines%5B0%5D%5Bproduct_name%5D%5Bfa%5D=Test%20Persian&order_lines%5B0%5D%5Bpid%5D=4475&order_lines%5B0%5D%5BprdNumber%5D=79050&order_lines%5B0%5D%5Bstock_type_id%5D=40&order_lines%5B0%5D%5Bstock_type_name%5D%5Bfi%5D=kg&order_lines%5B0%5D%5Bstock_type_name%5D%5Ben_gb%5D=kg&order_lines%5B0%5D%5Bstock_type_name%5D%5Bde%5D=kg&order_lines%5B0%5D%5Bstock_type_name%5D%5Bfa%5D=kg&order_lines%5B0%5D%5Bstock_available%5D=0&order_lines%5B0%5D%5Bvat_id%5D=2&order_lines%5B0%5D%5Bvat_percent%5D=14&order_lines%5B0%5D%5Bunit_price%5D=24.474&order_lines%5B0%5D%5Bunit_price_buy%5D=0&order_lines%5B0%5D%5Bcustomer_pricing_ignored%5D=0&order_lines%5B0%5D%5Bvat_id_buy%5D=0&order_lines%5B0%5D%5Bquantity%5D=2&order_lines%5B0%5D%5Bweight%5D=20&order_lines%5B0%5D%5Bweight_type%5D=kg&order_lines%5B0%5D%5Blocation%5D=&order_lines%5B0%5D%5Blocation_id%5D=&order_lines%5B0%5D%5Bsupplier_id%5D=0&order_lines%5B0%5D%5Bbest_before_date%5D=2022-02-15&order_lines%5B0%5D%5Bdiscount%5D=5&order_lines%5B0%5D%5Bbarcode%5D=516738&order_lines%5B0%5D%5Bbarcode_id%5D=6&order_lines%5B0%5D%5Bbarcode_type%5D=&order_lines%5B0%5D%5Bline_note%5D=&order_lines%5B0%5D%5Bcategory_name%5D=&order_lines%5B0%5D%5Bcustomer_pricing_exist%5D=&order_lines%5B0%5D%5Bstock_available_now%5D=141.5&order_lines%5B0%5D%5Bstock_alert_qty%5D=73&order_lines%5B0%5D%5Bstock_alert_bbd%5D=3&order_lines%5B0%5D%5Brelation_qty_type%5D=unit&order_lines%5B0%5D%5Bbox_qty%5D=0&order_lines%5B0%5D%5Bpallet_qty%5D=0&order_lines%5B0%5D%5Bpallet_qty_type%5D=box&order_lines%5B0%5D%5Bcustomer_id%5D=201&order_lines%5B0%5D%5Bignore_customer_pricing%5D=0&order_lines%5B0%5D%5Bsymbol%5D=%E2%82%AC&order_lines%5B0%5D%5Bvat_percent_buy%5D=14&order_lines%5B0%5D%5Bstock_type_measure%5D=1&calculate_line_pricing_internally=1&status=1&payment_status=0'

$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://easycms.fi/public_api/set_order",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_POSTFIELDS => http_build_query([
    'username' => 'USERNAME',
    'password' => 'PASSWORD',
    'account' => 'ACCOUNT_ID',
    'email' => 'customer@mail.com',
    'customer_password' => 'YOUR_CUSTOMER_PASSWORD',
    'customer_id' => '361',
    'no_vat' => '0',
    'sale_price_by_net_margin' => '0',
    'sale_price_by_net_margin_percentage' => '0',
    'ignore_customer_pricing' => '0',
    'order_date' => '2022-8-04 19:26:58',
    'shipping_method' => '1',
    'delivery_date' => '2022-8-04 19:26:58',
    'shipping_address' => '',
    'shipping_postal' => '2550',
    'shipping_city_id' => '25',
    'shipping_country_id' => '50',
    'discount' => '0',
    'paid_date' => '',
    'phone' => '44 7004050',
    'phone_full' => '+358447004050',
    'phone_prefix' => '358',
    'admin_id' => '163',
    'loading_employee_id' => '0',
    'loading_employee_name' => '',
    'delivery_employee_id' => '0',
    'delivery_employee_name' => '',
    'payer_details' => '',
    'payee_details' => '',
    'note' => 'DELIVER ON MONDAY 08.03.2021!',
    'delivery_instructions' => '',
    'order_by' => 'API_customer',
    'country_id' => '40',
    'city_id' => '1',
    'currency_rate' => '1',
    'currency_country_id' => '40',
    'customer_language' => 'fi',
    'customer_language_id' => '1',
    'customer_discount' => '0',
    'order_lines[0][line_type]' => '0',
    'order_lines[0][number]' => '1',
    'order_lines[0][product_name][fi]' => 'Testi',
    'order_lines[0][product_name][en_gb]' => 'Test',
    'order_lines[0][product_name][de]' => 'Test GERMAN',
    'order_lines[0][product_name][fa]' => 'Test Persian',
    'order_lines[0][pid]' => '4475',
    'order_lines[0][prdNumber]' => '79050',
    'order_lines[0][stock_type_id]' => '40',
    'order_lines[0][stock_type_name][fi]' => 'kg',
    'order_lines[0][stock_type_name][en_gb]' => 'kg',
    'order_lines[0][stock_type_name][de]' => 'kg',
    'order_lines[0][stock_type_name][fa]' => 'kg',
    'order_lines[0][stock_available]' => '0',
    'order_lines[0][vat_id]' => '2',
    'order_lines[0][vat_percent]' => '14',
    'order_lines[0][unit_price]' => '24.474',
    'order_lines[0][unit_price_buy]' => '0',
    'order_lines[0][customer_pricing_ignored]' => '0',
    'order_lines[0][vat_id_buy]' => '0',
    'order_lines[0][quantity]' => '2',
    'order_lines[0][weight]' => '20',
    'order_lines[0][weight_type]' => 'kg',
    'order_lines[0][location]' => '',
    'order_lines[0][location_id]' => '',
    'order_lines[0][supplier_id]' => '0',
    'order_lines[0][best_before_date]' => '2022-02-15',
    'order_lines[0][discount]' => '5',
    'order_lines[0][barcode]' => '516738',
    'order_lines[0][barcode_id]' => '6',
    'order_lines[0][barcode_type]' => '',
    'order_lines[0][line_note]' => '',
    'order_lines[0][category_name]' => '',
    'order_lines[0][customer_pricing_exist]' => '',
    'order_lines[0][stock_available_now]' => '141.5',
    'order_lines[0][stock_alert_qty]' => '73',
    'order_lines[0][stock_alert_bbd]' => '3',
    'order_lines[0][relation_qty_type]' => 'unit',
    'order_lines[0][box_qty]' => '0',
    'order_lines[0][pallet_qty]' => '0',
    'order_lines[0][pallet_qty_type]' => 'box',
    'calculate_line_pricing_internally' => '1',
    'status' => '1',
    'payment_status' => '0',
  ]),
  CURLOPT_HTTPHEADER => array("Authorization1: TOKEN"),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;

import requests

url = "https://easycms.fi/public_api/set_order"
headers = {"Authorization1": "TOKEN"}
payload = {
    'username': 'USERNAME',
    'password': 'PASSWORD',
    'account': 'ACCOUNT_ID',
    'email': 'customer@mail.com',
    'customer_password': 'YOUR_CUSTOMER_PASSWORD',
    'customer_id': '361',
    'no_vat': '0',
    'sale_price_by_net_margin': '0',
    'sale_price_by_net_margin_percentage': '0',
    'ignore_customer_pricing': '0',
    'order_date': '2022-8-04 19:26:58',
    'shipping_method': '1',
    'delivery_date': '2022-8-04 19:26:58',
    'shipping_address': '',
    'shipping_postal': '2550',
    'shipping_city_id': '25',
    'shipping_country_id': '50',
    'discount': '0',
    'paid_date': '',
    'phone': '44 7004050',
    'phone_full': '+358447004050',
    'phone_prefix': '358',
    'admin_id': '163',
    'loading_employee_id': '0',
    'loading_employee_name': '',
    'delivery_employee_id': '0',
    'delivery_employee_name': '',
    'payer_details': '',
    'payee_details': '',
    'note': 'DELIVER ON MONDAY 08.03.2021!',
    'delivery_instructions': '',
    'order_by': 'API_customer',
    'country_id': '40',
    'city_id': '1',
    'currency_rate': '1',
    'currency_country_id': '40',
    'customer_language': 'fi',
    'customer_language_id': '1',
    'customer_discount': '0',
    'order_lines[0][line_type]': '0',
    'order_lines[0][number]': '1',
    'order_lines[0][product_name][fi]': 'Testi',
    'order_lines[0][product_name][en_gb]': 'Test',
    'order_lines[0][product_name][de]': 'Test GERMAN',
    'order_lines[0][product_name][fa]': 'Test Persian',
    'order_lines[0][pid]': '4475',
    'order_lines[0][prdNumber]': '79050',
    'order_lines[0][stock_type_id]': '40',
    'order_lines[0][stock_type_name][fi]': 'kg',
    'order_lines[0][stock_type_name][en_gb]': 'kg',
    'order_lines[0][stock_type_name][de]': 'kg',
    'order_lines[0][stock_type_name][fa]': 'kg',
    'order_lines[0][stock_available]': '0',
    'order_lines[0][vat_id]': '2',
    'order_lines[0][vat_percent]': '14',
    'order_lines[0][unit_price]': '24.474',
    'order_lines[0][unit_price_buy]': '0',
    'order_lines[0][customer_pricing_ignored]': '0',
    'order_lines[0][vat_id_buy]': '0',
    'order_lines[0][quantity]': '2',
    'order_lines[0][weight]': '20',
    'order_lines[0][weight_type]': 'kg',
    'order_lines[0][location]': '',
    'order_lines[0][location_id]': '',
    'order_lines[0][supplier_id]': '0',
    'order_lines[0][best_before_date]': '2022-02-15',
    'order_lines[0][discount]': '5',
    'order_lines[0][barcode]': '516738',
    'order_lines[0][barcode_id]': '6',
    'order_lines[0][barcode_type]': '',
    'order_lines[0][line_note]': '',
    'order_lines[0][category_name]': '',
    'order_lines[0][customer_pricing_exist]': '',
    'order_lines[0][stock_available_now]': '141.5',
    'order_lines[0][stock_alert_qty]': '73',
    'order_lines[0][stock_alert_bbd]': '3',
    'order_lines[0][relation_qty_type]': 'unit',
    'order_lines[0][box_qty]': '0',
    'order_lines[0][pallet_qty]': '0',
    'order_lines[0][pallet_qty_type]': 'box',
    'calculate_line_pricing_internally': '1',
    'status': '1',
    'payment_status': '0'
}

response = requests.post(url, headers=headers, data=payload)
print(response.text)

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://easycms.fi/public_api/set_order"))
    .headers("Authorization1", "TOKEN")
    .POST(HttpRequest.BodyPublishers.ofString("username=USERNAME&password=PASSWORD&account=ACCOUNT_ID&email=customer@mail.com&customer_password=YOUR_CUSTOMER_PASSWORD&customer_id=361&no_vat=0&sale_price_by_net_margin=0&sale_price_by_net_margin_percentage=0&ignore_customer_pricing=0&order_date=2022-8-04 19:26:58&shipping_method=1&delivery_date=2022-8-04 19:26:58&shipping_address=&shipping_postal=2550&shipping_city_id=25&shipping_country_id=50&discount=0&paid_date=&phone=44 7004050&phone_full=+358447004050&phone_prefix=358&admin_id=163&loading_employee_id=0&loading_employee_name=&delivery_employee_id=0&delivery_employee_name=&payer_details=&payee_details=¬e=DELIVER ON MONDAY 08.03.2021!&delivery_instructions=&order_by=API_customer&country_id=40&city_id=1¤cy_rate=1¤cy_country_id=40&customer_language=fi&customer_language_id=1&customer_discount=0&order_lines[0][line_type]=0&order_lines[0][number]=1&order_lines[0][product_name][fi]=Testi&order_lines[0][product_name][en_gb]=Test&order_lines[0][product_name][de]=Test GERMAN&order_lines[0][product_name][fa]=Test Persian&order_lines[0][pid]=4475&order_lines[0][prdNumber]=79050&order_lines[0][stock_type_id]=40&order_lines[0][stock_type_name][fi]=kg&order_lines[0][stock_type_name][en_gb]=kg&order_lines[0][stock_type_name][de]=kg&order_lines[0][stock_type_name][fa]=kg&order_lines[0][stock_available]=0&order_lines[0][vat_id]=2&order_lines[0][vat_percent]=14&order_lines[0][unit_price]=24.474&order_lines[0][unit_price_buy]=0&order_lines[0][customer_pricing_ignored]=0&order_lines[0][vat_id_buy]=0&order_lines[0][quantity]=2&order_lines[0][weight]=20&order_lines[0][weight_type]=kg&order_lines[0][location]=&order_lines[0][location_id]=&order_lines[0][supplier_id]=0&order_lines[0][best_before_date]=2022-02-15&order_lines[0][discount]=5&order_lines[0][barcode]=516738&order_lines[0][barcode_id]=6&order_lines[0][barcode_type]=&order_lines[0][line_note]=&order_lines[0][category_name]=&order_lines[0][customer_pricing_exist]=&order_lines[0][stock_available_now]=141.5&order_lines[0][stock_alert_qty]=73&order_lines[0][stock_alert_bbd]=3&order_lines[0][relation_qty_type]=unit&order_lines[0][box_qty]=0&order_lines[0][pallet_qty]=0&order_lines[0][pallet_qty_type]=box&calculate_line_pricing_internally=1&status=1&payment_status=0"))
    .build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
        

const https = require('https');
const data = new URLSearchParams({
  username: 'USERNAME',
  password: 'PASSWORD',
  account: 'ACCOUNT_ID',
  email: 'customer@mail.com',
  customer_password: 'YOUR_CUSTOMER_PASSWORD',
  customer_id: '361',
  no_vat: '0',
  sale_price_by_net_margin: '0',
  sale_price_by_net_margin_percentage: '0',
  ignore_customer_pricing: '0',
  order_date: '2022-8-04 19:26:58',
  shipping_method: '1',
  delivery_date: '2022-8-04 19:26:58',
  shipping_address: '',
  shipping_postal: '2550',
  shipping_city_id: '25',
  shipping_country_id: '50',
  discount: '0',
  paid_date: '',
  phone: '44 7004050',
  phone_full: '+358447004050',
  phone_prefix: '358',
  admin_id: '163',
  loading_employee_id: '0',
  loading_employee_name: '',
  delivery_employee_id: '0',
  delivery_employee_name: '',
  payer_details: '',
  payee_details: '',
  note: 'DELIVER ON MONDAY 08.03.2021!',
  delivery_instructions: '',
  order_by: 'API_customer',
  country_id: '40',
  city_id: '1',
  currency_rate: '1',
  currency_country_id: '40',
  customer_language: 'fi',
  customer_language_id: '1',
  customer_discount: '0',
  'order_lines[0][line_type]': '0',
  'order_lines[0][number]': '1',
  'order_lines[0][product_name][fi]': 'Testi',
  'order_lines[0][product_name][en_gb]': 'Test',
  'order_lines[0][product_name][de]': 'Test GERMAN',
  'order_lines[0][product_name][fa]': 'Test Persian',
  'order_lines[0][pid]': '4475',
  'order_lines[0][prdNumber]': '79050',
  'order_lines[0][stock_type_id]': '40',
  'order_lines[0][stock_type_name][fi]': 'kg',
  'order_lines[0][stock_type_name][en_gb]': 'kg',
  'order_lines[0][stock_type_name][de]': 'kg',
  'order_lines[0][stock_type_name][fa]': 'kg',
  'order_lines[0][stock_available]': '0',
  'order_lines[0][vat_id]': '2',
  'order_lines[0][vat_percent]': '14',
  'order_lines[0][unit_price]': '24.474',
  'order_lines[0][unit_price_buy]': '0',
  'order_lines[0][customer_pricing_ignored]': '0',
  'order_lines[0][vat_id_buy]': '0',
  'order_lines[0][quantity]': '2',
  'order_lines[0][weight]': '20',
  'order_lines[0][weight_type]': 'kg',
  'order_lines[0][location]': '',
  'order_lines[0][location_id]': '',
  'order_lines[0][supplier_id]': '0',
  'order_lines[0][best_before_date]': '2022-02-15',
  'order_lines[0][discount]': '5',
  'order_lines[0][barcode]': '516738',
  'order_lines[0][barcode_id]': '6',
  'order_lines[0][barcode_type]': '',
  'order_lines[0][line_note]': '',
  'order_lines[0][category_name]': '',
  'order_lines[0][customer_pricing_exist]': '',
  'order_lines[0][stock_available_now]': '141.5',
  'order_lines[0][stock_alert_qty]': '73',
  'order_lines[0][stock_alert_bbd]': '3',
  'order_lines[0][relation_qty_type]': 'unit',
  'order_lines[0][box_qty]': '0',
  'order_lines[0][pallet_qty]': '0',
  'order_lines[0][pallet_qty_type]': 'box',
  'calculate_line_pricing_internally': '1',
  'status': '1',
  'payment_status': '0',
});

const options = {
  hostname: 'prolasku.fi',
  path: '/public_api/set_order',
  method: 'POST',
  headers: {
    'Authorization1': 'TOKEN',
    'Content-Type': 'application/x-www-form-urlencoded',
    'Content-Length': data.length
  }
};

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(data);
req.end();
        

import React, { useEffect, useState } from 'react';
function App() {
  const [responseText, setResponseText] = useState('');
  useEffect(() => {
    const fetchData = async () => {
      try {
        const response = await fetch('https://easycms.fi/public_api/set_order', {
          method: 'POST',
          headers: {
            'Authorization1': 'TOKEN',
            'Content-Type': 'application/x-www-form-urlencoded',
          },
          body: new URLSearchParams({
            username: 'USERNAME',
            password: 'PASSWORD',
            account: 'ACCOUNT_ID',
            email: 'customer@mail.com',
            customer_password: 'YOUR_CUSTOMER_PASSWORD',
            customer_id: '361',
            no_vat: '0',
            sale_price_by_net_margin: '0',
            sale_price_by_net_margin_percentage: '0',
            ignore_customer_pricing: '0',
            order_date: '2022-8-04 19:26:58',
            shipping_method: '1',
            delivery_date: '2022-8-04 19:26:58',
            shipping_address: '',
            shipping_postal: '2550',
            shipping_city_id: '25',
            shipping_country_id: '50',
            discount: '0',
            paid_date: '',
            phone: '44 7004050',
            phone_full: '+358447004050',
            phone_prefix: '358',
            admin_id: '163',
            loading_employee_id: '0',
            loading_employee_name: '',
            delivery_employee_id: '0',
            delivery_employee_name: '',
            payer_details: '',
            payee_details: '',
            note: 'DELIVER ON MONDAY 08.03.2021!',
            delivery_instructions: '',
            order_by: 'API_customer',
            country_id: '40',
            city_id: '1',
            currency_rate: '1',
            currency_country_id: '40',
            customer_language: 'fi',
            customer_language_id: '1',
            customer_discount: '0',
            'order_lines[0][line_type]': '0',
            'order_lines[0][number]': '1',
            'order_lines[0][product_name][fi]': 'Testi',
            'order_lines[0][product_name][en_gb]': 'Test',
            'order_lines[0][product_name][de]': 'Test GERMAN',
            'order_lines[0][product_name][fa]': 'Test Persian',
            'order_lines[0][pid]': '4475',
            'order_lines[0][prdNumber]': '79050',
            'order_lines[0][stock_type_id]': '40',
            'order_lines[0][stock_type_name][fi]': 'kg',
            'order_lines[0][stock_type_name][en_gb]': 'kg',
            'order_lines[0][stock_type_name][de]': 'kg',
            'order_lines[0][stock_type_name][fa]': 'kg',
            'order_lines[0][stock_available]': '0',
            'order_lines[0][vat_id]': '2',
            'order_lines[0][vat_percent]': '14',
            'order_lines[0][unit_price]': '24.474',
            'order_lines[0][unit_price_buy]': '0',
            'order_lines[0][customer_pricing_ignored]': '0',
            'order_lines[0][vat_id_buy]': '0',
            'order_lines[0][quantity]': '2',
            'order_lines[0][weight]': '20',
            'order_lines[0][weight_type]': 'kg',
            'order_lines[0][location]': '',
            'order_lines[0][location_id]': '',
            'order_lines[0][supplier_id]': '0',
            'order_lines[0][best_before_date]': '2022-02-15',
            'order_lines[0][discount]': '5',
            'order_lines[0][barcode]': '516738',
            'order_lines[0][barcode_id]': '6',
            'order_lines[0][barcode_type]': '',
            'order_lines[0][line_note]': '',
            'order_lines[0][category_name]': '',
            'order_lines[0][customer_pricing_exist]': '',
            'order_lines[0][stock_available_now]': '141.5',
            'order_lines[0][stock_alert_qty]': '73',
            'order_lines[0][stock_alert_bbd]': '3',
            'order_lines[0][relation_qty_type]': 'unit',
            'order_lines[0][box_qty]': '0',
            'order_lines[0][pallet_qty]': '0',
            'order_lines[0][pallet_qty_type]': 'box',
            'calculate_line_pricing_internally': '1',
            'status': '1',
            'payment_status': '0',
          }).toString(),
        });
        const data = await response.text();
        setResponseText(data);
      } catch (error) {
        console.error(error);
      }
    };
    fetchData();
  }, []);
  return (
      {responseText};
  );
}
export default App;
        

// Kotlin example requires using a third-party library like OkHttp for POST requests with a body
import okhttp3.OkHttpClient
import okhttp3.FormBody
import okhttp3.Request
import java.io.IOException

fun main() {
    val client = OkHttpClient()

    val formBody = FormBody.Builder()
        .add("username", "USERNAME")
        .add("password", "PASSWORD")
        .add("account", "ACCOUNT_ID")
        .add("email", "customer@mail.com")
        .add("customer_password", "YOUR_CUSTOMER_PASSWORD")
        .add("customer_id", "361")
        .add("no_vat", "0")
        .add("sale_price_by_net_margin", "0")
        .add("sale_price_by_net_margin_percentage", "0")
        .add("ignore_customer_pricing", "0")
        .add("order_date", "2022-8-04 19:26:58")
        .add("shipping_method", "1")
        .add("delivery_date", "2022-8-04 19:26:58")
        // Add the rest of the payload here
        .build()

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

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

// C# code to make a POST request to the set_order endpoint
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        using (var httpClient = new HttpClient())
        {
            var url = "https://easycms.fi/public_api/set_order";

            var payload = new Dictionary
            {
                {"username", "USERNAME"},
                {"password", "PASSWORD"},
                {"account", "ACCOUNT_ID"},
                {"email", "customer@mail.com"},
                {"customer_password", "YOUR_CUSTOMER_PASSWORD"},
                {"customer_id", "361"},
                {"no_vat", "0"},
                {"sale_price_by_net_margin", "0"},
                {"sale_price_by_net_margin_percentage", "0"},
                {"ignore_customer_pricing", "0"},
                {"order_date", "2022-8-04 19:26:58"},
                {"shipping_method", "1"},
                {"delivery_date", "2022-8-04 19:26:58"},
                // Add the rest of the payload here
            };

            var content = new FormUrlEncodedContent(payload);
            content.Headers.Add("Authorization1", "TOKEN");

            var response = await httpClient.PostAsync(url, content);
            var responseBody = await response.Content.ReadAsStringAsync();
            Console.WriteLine(responseBody);
        }
    }
}




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:


{
    "INFO": {
        "start": 0,
        "limit": 50,
        "count": 1,
        "total_count": 1,
        "tip": "",
        "extra": "Get a list of required order_keys as well as required order_line_keys from the API provider"
    },
    "OUTPUT": {
        "id": "1152",
        "cr_receipt": false,
        "cr_ticket_number": [],
        "merged_to": [],
        "invoice_id": 0,
        "reference": "170519226212404",
        "total": 53.01,
        "no_vat": 0,
        "sale_price_by_net_margin": 0,
        "sale_price_by_net_margin_percentage": 0,
        "ignore_customer_pricing": 0,
        "order_date": "2024-01-14 02:31:02",
        "shipping_method": "1",
        "delivery_date": "2024-01-17 02:31:02",
        "shipping_address": false,
        "shipping_postal": "2550",
        "shipping_city_id": "25",
        "shipping_country_id": "50",
        "discount": 0,
        "paid_date": false,
        "phone": "44 7004050",
        "phone_full": "358447004050",
        "phone_prefix": "358",
        "email": "daniel@swh.fi",
        "admin_id": "2",
        "customer_id": "361",
        "loading_employee_id": 0,
        "loading_employee_name": false,
        "delivery_employee_id": 0,
        "delivery_employee_name": false,
        "payer_details": "

Tatar Oy
Tatar Oy
Tataritsu 26
00510, Helsinki, Suomi

", "payee_details": 0, "title": "order", "note": "DELIVER ON MONDAY 08.03.2021!", "admin_note": "", "delivery_instructions": false, "order_by": "API_customer", "order_sms_error": 0, "order_sms_delivery_status": false, "status": "1", "link_id": "236a8db65444d95c8963dd700b41fd9a", "country_id": "40", "city_id": "1", "currency_rate": 1, "currency_country_id": "40", "customer_language": "fi", "customer_language_id": "1", "customer_discount": 0, "qr_code": false, "notification_id": 0, "order_sent_data": null, "delivery_note_sent_data": null, "sales_margin": [], "net_profit": 0, "gross_profit": 0, "deleted": 0, "order_lines": [ { "order_line_id": "6938", "line_type": 0, "id": "1152", "original_id": 0, "number": "1", "product_title": false, "product_name": { "fi": "Testi", "en_gb": "Test", "de": "Test GERMAN", "fa": "Test Persian" }, "ML_product_name": "Testi", "pid": "4475", "prdNumber": "79050", "stock_type_id": "40", "stock_type_name": { "fi": "kg", "en_gb": "kg", "de": "kg", "fa": "kg" }, "ML_stock_type_name": "kg", "stock_available": 0, "stock_type_measure": "1", "vat_id": "2", "vat_percent": 14, "vat_account": "3001", "unit_price": 24.474, "unit_price_buy": 0, "customer_pricing_ignored": 0, "vat_id_buy": 0, "vat_percent_buy": 14, "vat_account_buy": "0", "quantity": 2, "weight": 20, "weight_type": "kg", "location": "location_1-shelf_1", "location_id": "13-84", "supplier_id": 0, "best_before_date": "2022-02-15", "discount": 5, "barcode": "516738", "barcode_id": "6", "barcode_type": false, "line_note": false, "deleted": 0, "category_name": [], "ML_category_name": "Nimetön", "customer_pricing_exist": false, "stock_available_now": 0, "stock_alert_qty": 0, "stock_alert_bbd": false, "relation_qty_type": false, "box_qty": 0, "pallet_qty": 0, "pallet_qty_type": false, "customer_id": "361", "ignore_customer_pricing": 0, "UNIT_NET_PRICE_BEFORE_DISCOUNT": 24.474, "UNIT_NET_PRICE_AFTER_DISCOUNT": 23.25, "UNIT_GROSS_PRICE_BEFORE_DISCOUNT": 27.9, "UNIT_GROSS_PRICE_AFTER_DISCOUNT": 26.5, "LINE_NET_PRICE_BEFORE_DISCOUNT": 48.948, "LINE_NET_PRICE_AFTER_DISCOUNT": 46.501, "LINE_GROSS_PRICE_BEFORE_DISCOUNT": 55.8, "LINE_GROSS_PRICE_AFTER_DISCOUNT": 53.01, "symbol": "€" } ], "response_type": "success", "message": "order_was_set_successfully" } }

Error Handling

Here are the possible error messages and their meanings:

  • UN-AUTHORIZED - _user_name_password_is_set_but_wrong_value!: Incorrect username or password.
  • email_is_not_valid: Incorrect email format or email does not exist or email server not responding based on API server's email verification module.
  • this_account_does_not_exist_or_your_credentials_do_not_match_this_account: The account doesn't exist or mismatched credentials.
  • UN-AUTHORIZED - header is set but the header value is not correct!: Incorrect authorization header value.
  • Maximum query size is 1 rows per query: Exceeded maximum limit of 1 rows per query.