Customers | Login

Customer Login

This document outlines the use of the get_customer API endpoint for authenticating and logging in a customer using their email and password. It is a crucial tool for verifying customer credentials and accessing their information upon successful login.

Using the get_customer Endpoint

The get_customer endpoint is designed to authenticate a customer's login credentials, including their email and password, to provide access to their account information.

Endpoint and Method

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

Required Parameters | Payload

For successful authentication and data retrieval, the following parameters are mandatory:

  • TOKEN (api_key): Your unique API key for authentication. How to Create API Credentials.
  • username: Your API username.
  • password: Your API password.
  • account: Your API account.
  • email: The customer's email address used for login.
  • customer_password: The customer's password associated with their account.

Optional Parameters

  • no_profile_image: An integer value (0 or 1). Set to 1 to exclude the profile image from the response for a faster response time. This is useful for repetitive login verifications where the profile image is not required.

Purpose of the Endpoint

  • Customer Authentication: To verify the customer's identity by matching the provided email and password with the existing records.
  • Access Customer Information: Upon successful verification, the API returns the customer's account information.

Notes

  • Ensure the accuracy and confidentiality of the customer_password during transmission.
  • The primary parameters required are the email and customer_password for the customer which are usually fetched directly from a login form input.
  • Utilize the no_profile_image parameter for quicker response times in situations where the profile image is not necessary.



Call Examples in Different Languages


curl -X POST 'https://easycms.fi/public_api/get_customer_check' \
-H 'Authorization1: TOKEN' \
-d 'username=USERNAME&password=PASSWORD&account=ACCOUNT_ID&email=customer@mail.com&customer_password=CUSTOMER_PASSWORD'

$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://easycms.fi/public_api/get_customer_check",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_POSTFIELDS => http_build_query([
    'username' => 'USERNAME', 
    'password' => 'PASSWORD', 
    'account' => 'ACCOUNT_ID', 
    'email' => 'customer@mail.com', 
    'customer_password' => 'CUSTOMER_PASSWORD'
  ]),
  CURLOPT_HTTPHEADER => array("Authorization1: TOKEN"),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;

import requests
url = "https://easycms.fi/public_api/get_customer_check"
headers = {"Authorization1": "TOKEN"}
payload = {
  'username': 'USERNAME', 
  'password': 'PASSWORD', 
  'account': 'ACCOUNT_ID', 
  'email': 'customer@mail.com', 
  'customer_password': 'CUSTOMER_PASSWORD'
}
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/get_customer_check"))
    .headers("Authorization1", "TOKEN")
    .POST(HttpRequest.BodyPublishers.ofString("username=USERNAME&password=PASSWORD&account=ACCOUNT_ID&email=customer@mail.com&customer_password=CUSTOMER_PASSWORD"))
    .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: 'CUSTOMER_PASSWORD'
}).toString();
const options = {
  hostname: 'prolasku.fi',
  path: '/public_api/get_customer_check',
  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 [categoryData, setCategoryData] = useState('');
  useEffect(() => {
    const fetchData = async () => {
      try {
        const response = await fetch('https://easycms.fi/public_api/get_customer_check', {
          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: 'CUSTOMER_PASSWORD'
          }).toString()
        });
        const data = await response.text();
        setCategoryData(data);
      } catch (error) {
        console.error(error);
      }
    };
    fetchData();
  }, []);
  return (
{categoryData}
); } export default App;

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

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", "CUSTOMER_PASSWORD")
        .build()

    val request = Request.Builder()
        .url("https://easycms.fi/public_api/get_customer_check")
        .post(formBody)
        .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.Threading.Tasks;
class Program
{
    static async Task Main()
    {
        var token = "TOKEN";
        var content = new FormUrlEncodedContent(new[]
        {
            new KeyValuePair("username", "USERNAME"),
            new KeyValuePair("password", "PASSWORD"),
            new KeyValuePair("account", "ACCOUNT_ID"),
            new KeyValuePair("email", "customer@mail.com"),
            new KeyValuePair("customer_password", "CUSTOMER_PASSWORD")
        });
        using (var httpClient = new HttpClient())
        {
            httpClient.DefaultRequestHeaders.Add("Authorization1", token);
            var response = await httpClient.PostAsync("https://easycms.fi/public_api/get_customer_check", content);
            if (response.IsSuccessStatusCode)
            {
                var responseData = await response.Content.ReadAsStringAsync();
                Console.WriteLine(responseData);
            }
            else
            {
                Console.WriteLine($"Error: {response.StatusCode}");
            }
        }
    }
}




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:


# Customer Data API Response Output Object Breakdown

This document details the breakdown of the customer data output object received from the API server. Each field in the JSON response is explained for a comprehensive understanding.

## Fields Overview

The response object includes various fields that provide detailed information about a customer. Here are the descriptions of each field:

### `customer_id`
- **Type:** String
- **Description:** Unique identifier for the customer.
- **Example:** `"361"`

### `parent_id`
- **Type:** Integer
- **Description:** Identifier for the parent entity of the customer, if applicable. Zero often indicates no parent entity.
- **Example:** `0`

### `number`
- **Type:** Integer
- **Description:** A numerical identifier or code for the customer. Often used for internal purposes.
- **Example:** `0`

### `visible`
- **Type:** String
- **Description:** Indicates if the customer is visible in the system. "1" for visible, "0" for not visible.
- **Example:** `"1"`

### `language`
- **Type:** String
- **Description:** Preferred language of the customer, represented by a language code.
- **Example:** `"en_gb"`

### `language_id`
- **Type:** String
- **Description:** Identifier for the customer's preferred language.
- **Example:** `"2"`

### `firstname`
- **Type:** String
- **Description:** Full name of the customer. It has been adapted to include the full name instead of the traditional first name.
- **Example:** `"Full name"`

### `lastname`
- **Type:** String
- **Description:** Trade name of the customer. This field has evolved to represent the customer's trade name.
- **Example:** `"Trade name"`

### `phone_prefix`
- **Type:** String
- **Description:** Country or area code for the primary phone number.
- **Example:** `"358"`

### `phone_full`
- **Type:** String
- **Description:** Full primary phone number including the prefix.
- **Example:** `"0931588830"`

### `phone`
- **Type:** String
- **Description:** Primary phone number without the prefix.
- **Example:** `"0931588830"`

### `phone2_prefix`
- **Type:** String
- **Description:** Country or area code for the secondary phone number.
- **Example:** `"0"`

### `phone2_full`
- **Type:** String
- **Description:** Full secondary phone number including the prefix.
- **Example:** `"0"`

### `phone2`
- **Type:** String
- **Description:** Secondary phone number without the prefix.
- **Example:** `"0"`

### `email`
- **Type:** String
- **Description:** Email address of the customer.
- **Example:** `"customer@mail.com"`

### `company`
- **Type:** String
- **Description:** Name of the company associated with the customer.
- **Example:** `"Company Oy"`

### `business_id`
- **Type:** String
- **Description:** Business identifier or registration number of the company.
- **Example:** `"1234567-8"`

### `address`
- **Type:** String
- **Description:** Primary address of the customer.
- **Example:** `"Tataritsu 26"`

### `address2`
- **Type:** String
- **Description:** Secondary address of the customer.
- **Example:** `"0"`

### `city_id`
- **Type:** String
- **Description:** Identifier for the city associated with the primary address.
- **Example:** `"1"`

### `postal`
- **Type:** String
- **Description:** Postal or ZIP code for the primary address.
- **Example:** `"00510"`

### `state`
- **Type:** Boolean/String
- **Description:** State or region for the primary address. Returns `false` if not applicable.
- **Example:** `false`

### `country_id`
- **Type:** String
- **Description:** Identifier for the country of the primary address.
- **Example:** `"40"`

### `different_shipping_address`
- **Type:** String
- **Description:** Indicates if the shipping address is different from the primary address. "1" for yes, "0" for no.
- **Example:** `"1"`

### `shipping_address`
- **Type:** String
- **Description:** Shipping address, if different from the primary address.
- **Example:** `"Tataritsu 26"`

### `shipping_postal`
- **Type:** String
- **Description:** Postal or ZIP code for the shipping address.
- **Example:** `"00510"`

### `shipping_city_id`
- **Type:** String
- **Description:** Identifier for the city of the shipping address.
- **Example:** `"1"`

### `shipping_country_id`
- **Type:** String
- **Description:** Identifier for the country of the shipping address.
- **Example:** `"40"`

### `shipping_state`
- **Type:** String
- **Description:** State or region for the shipping address.
- **Example:** `"0"`

### `delivery_contact_person`
- **Type:** String
- **Description:** Name of the contact person for delivery purposes.
- **Example:** `"Delivery person's name"`

### `phone3_prefix`
- **Type:** String
- **Description:** Country or area code for an alternative phone number.
- **Example:** `"358"`

### `phone3`
- **Type:** String
- **Description:** Alternative phone number without the prefix.
- **Example:** `"0"`

### `phone3_full`
- **Type:** String
- **Description:** Full alternative phone number including the prefix.
- **Example:** `"0"`

### `ordering_email`
- **Type:** String
- **Description:** Email address for ordering purposes.
- **Example:** `"ordering@mail.com"`

### `ordering_phone_prefix`
- **Type:** String
- **Description:** Country or area code for the ordering phone number.
- **Example:** `"0"`

### `ordering_phone`
- **Type:** String
- **Description:** Ordering phone number without the prefix.
- **Example:** `"0931588830"`

### `ordering_phone_full`
- **Type:** String
- **Description:** Full ordering phone number including the prefix.
- **Example:** `"0931588830"`

### `billing_email`
- **Type:** String
- **Description:** Email address for billing purposes.
- **Example:** `"billing@mail.com"`

### `billing_phone_prefix`
- **Type:** String
- **Description:** Country or area code for the billing phone number.
- **Example:** `"0"`

### `billing_phone`
- **Type:** String
- **Description:** Billing phone number without the prefix.
- **Example:** `"0931588830"`

### `billing_phone_full`
- **Type:** String
- **Description:** Full billing phone number including the prefix.
- **Example:** `"0931588830"`

### `newsletter`
- **Type:** Integer
- **Description:** Indicates if the customer is subscribed to newsletters. "1" for subscribed, "0" for not subscribed.
- **Example:** `0`

### `agreement`
- **Type:** String
- **Description:** Indicates if the customer has agreed to terms, conditions, or agreements. "1" for agreed, "0" for not agreed.
- **Example:** `"0"`

### `login_ip`
- **Type:** Array
- **Description:** List of IP addresses used by the customer for login. Empty if not available.
- **Example:** `[]`

### `vouchers_used`
- **Type:** Array
- **Description:** List of voucher codes used by the customer. Empty if not available.
- **Example:** `[]`

### `registration_date`
- **Type:** String
- **Description:** Date and time when the customer registered.
- **Example:** `"2024-01-01 12:14:22"`

### `maxdebt`
- **Type:** Integer
- **Description:** Maximum debt limit for the customer. "0" often indicates no limit or not applicable.
- **Example:** `0`

### `fax`
- **Type:** String
- **Description:** Fax number of the customer. "0" often indicates no fax number.
- **Example:** `"0"`

### `notes`
- **Type:** String
- **Description:** Notes or comments about the customer.
- **Example:** `"WooCommerce website signup"`

### `curdebt`
- **Type:** Integer
- **Description:** Current debt amount of the customer, if applicable. "0" often indicates no debt.
- **Example:** `0`

### `isvip`
- **Type:** Integer
- **Description:** Indicates if the customer is classified as a VIP. "1" for yes, "0" for no.
- **Example:** `0`

### `discount`
- **Type:** Integer
- **Description:** Discount rate (in percentage) applicable to the customer.
- **Example:** `30`

### `payment_period`
- **Type:** Integer
- **Description:** Payment period term for the customer, typically expressed in days.
- **Example:** `"14"`

### `available_payment_methods`
- **Type:** Array
- **Description:** List of available payment methods for the customer. "0" can indicate default or unspecified method.
- **Example:** `["0"]`
- **List of available Payment Methods** You can fetch a list of available payment methods available using end point [/get_payment_methods](get_payment_methods.php).

### `note`
- **Type:** String
- **Description:** Additional note regarding the customer.
- **Example:** `"WooCommerce website signup"`

### `website`
- **Type:** String
- **Description:** Website associated with the customer or their company.
- **Example:** `"www.customerdomain.tld"`

### `identifier`
- **Type:** String
- **Description:** An e-invoice unique identifier for the customer, often used for internal invoicing. "" can indicate a default or unspecified value.
- **Example:** `"0"`

### `intermediator`
- **Type:** String
- **Description:** An e-invoice intermediator or agent involved with the customer's e-invoicing. "" can signify no intermediator.
- **Example:** `"0"`

### `crcustomer_id`
- **Type:** String
- **Description:** A unique customer relationship identifier, possibly used for linking with external systems such as cashregisters.
- **Example:** `"b9c61156-0156-443b-9b33-c958f876faab"`

### `image`
- **Type:** String
- **Description:** Link or reference to the customer's image. "null" indicates no image is associated.
- **Example:** `"null"`

### `firebase_token`
- **Type:** String
- **Description:** Firebase token associated with the customer's mobile app notifications, typically for push notifications or authentication purposes.
- **Example:** `"0"`

    

{
    "INFO": {
        "start": 0,
        "limit": 50,
        "count": 1,
        "total_count": 1,
        "tip": ""
    },
    "OUTPUT": {
        "customer_id": "361",
        "parent_id": 0,
        "number": 0,
        "visible": 1,
        "language": "en_gb",
        "language_id": "2",
        "firstname": "Testi asiakas",
        "lastname": "Tatar Cafe",
        "phone_prefix": "358",
        "phone_full": "0931588830",
        "phone": "0931588830",
        "phone2_prefix": "0",
        "phone2_full": "0",
        "phone2": "0",
        "email": "customer@mail.com",
        "password": null,
        "company": "Tatar Oy",
        "business_id": "1234567-8",
        "address": "Tataritsu 26",
        "address2": "0",
        "city_id": "1",
        "postal": "00510",
        "state": false,
        "country_id": "40",
        "different_shipping_address": 1,
        "shipping_address": "Tataritsu 26",
        "shipping_postal": "00510",
        "shipping_city_id": "1",
        "shipping_country_id": "40",
        "shipping_state": "0",
        "delivery_contact_person": "",
        "phone3_prefix": "358",
        "phone3": "0",
        "phone3_full": "0",
        "ordering_email": "customer@mail.com",
        "ordering_phone_prefix": "0",
        "ordering_phone": "0931588830",
        "ordering_phone_full": "0931588830",
        "billing_email": "customer@mail.com",
        "billing_phone_prefix": "0",
        "billing_phone": "0931588830",
        "billing_phone_full": "0931588830",
        "newsletter": 0,
        "agreement": "0",
        "login_ip": [],
        "vouchers_used": [],
        "registration_date": "2022-03-17 12:14:22",
        "maxdebt": 0,
        "fax": "0",
        "notes": "WooCommerce website signup",
        "curdebt": 0,
        "isvip": 0,
        "discount": 30,
        "payment_period": "14",
        "available_payment_methods": [
            "0"
        ],
        "note": "WooCommerce website signup",
        "website": "12345",
        "identifier": "0",
        "intermediator": "0",
        "crcustomer_id": "b9c61156-0156-443b-9b33-c958f876faab",
        "image": "null",
        "firebase_token": "0",
        "admin_id": 163,
        "response_type": "success",
        "message": "customer data returned 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.
  • 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 50 rows per query: Exceeded maximum limit of 50 rows per query.