API Authentication

To authenticate with the UI API, you must generate a JSON Web Token (JWT) and pass the partner_id.

How to generate a JWT token?

To generate a JWT token, you can use the code snippets provided below in Python, Java, or Ruby:

import jwt

secret = 'your-api-key'
user_info = {
    'member_id': 'Unique-ID',
    # REQUIRED: Pass members unique identifier in this field when the user is Logged in.
    'exp': 1635862400,  # REQUIRED: Epoch timestamp (seconds), after which the token will expire

encoded_jwt = jwt.encode(user_info, secret, algorithm='HS256')
import io.jsonwebtoken.*;
import java.util.*;
import org.json.*;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.*;

public class JWTApplication {

    public static void main(String[] args) throws IOException {
        String jwtToken = "";
        String secret = "your_api_key";
        Claims claims = Jwts.claims();
        Duration duration = Duration.from(ChronoUnit.HOURS.getDuration());
        long epoch = System.currentTimeMillis() / 1000;
        long validityInSeconds = 3600;
        long exp = epoch + validityInSeconds;
        String userInfo = "{\"member_id\" : \"Unique-ID\"}"; // Added a semicolon here
        Map<String, Object> mapping = new ObjectMapper().readValue(userInfo, HashMap.class);
        for (String key : mapping.keySet()) {
            claims.put(key, mapping.get(key));
        claims.put("exp", exp);
        jwtToken = Jwts.builder().setClaims(claims)
                .signWith(SignatureAlgorithm.HS256, Base64.getEncoder().encodeToString(secret.getBytes()))
require 'jwt'

secret = 'your-api-key'
user_info = {
  'member_id' => 'Unique-ID',
  'exp' => 1635862400, # REQUIRED: Epoch timestamp (seconds), after which the token will expire

encoded_jwt = JWT.encode(user_info, secret, 'HS256')
puts encoded_jwt

Where can I find the partner_id?

You can locate the partner_id by navigating to "General >> Settings >> Store Settings."

store settings

Pass JWT and Partner ID in the API

Once you have obtained the JWT and partner ID, you need to include this data when making API requests.