Using Signature (Recommended)
If you use one of the supplied SDKs, there is no reason to use the code in the following section as the signature can be generated by calling the generate_signature function.

Overview

To communicate with our system we require a signature on each request to ensure that both parties are who they say they are. To calculate your signature, you will need your partner ID and API Key for Signature, both of which are available on the portal.

API Key for Signature

You can find and generate your an API key here. The key is unique to each environment, so you will need a different key for the sandbox and production environments. You can rotate your API key any time, however your previous key will be immediately disabled.

Partner ID

You will need to know your partner ID, to create the signature. Your partner ID can be viewed when logged into the portal. To calculate your signature you will need to input your partner ID as a string, as explained below
Your partner ID: 85
String Value of your partner ID: "085"

Generating the signature

Follow the steps below to generate your signature
  1. 1.
    Create a timestamp in an ISO date format
  2. 2.
    Create a new hmac-sha256 hash function using Signature API Key.
  3. 3.
    Update the function message with timestamp created in 1, your partner Id, and "sid_request" string
  4. 4.
    Base64 encode the encrypted hash
Example code for creating the signature
Ruby
Node.js
Python
PHP
Java
C#
1
require 'openssl'
2
require 'time'
3
require 'base64'
4
5
timestamp = Time.now.to_s
6
api_key = '<Your Signature API Key>'
7
partner_id = '<Your partner id>'
8
hmac = OpenSSL::HMAC.new(api_key, 'sha256')
9
hmac.update(timestamp) hmac.update(partner_id)
10
hmac.update("sid_request")
11
12
signature = Base64.strict_encode64(hmac.digest())
Copied!
1
let crypto = require('crypto');
2
let timestamp = new Date().toISOString();
3
let api_key = "<Your Signature API Key>";
4
let partner_id = "<Your partner id>";
5
let hmac = crypto.createHmac('sha256', api_key);
6
7
hmac.update(timestamp, 'utf8');
8
hmac.update(partner_id, 'utf8');
9
hmac.update("sid_request", 'utf8');
10
11
let signature = hmac.digest().toString('base64');
Copied!
1
import base64
2
import hashlib
3
import hmac
4
from datetime import datetime
5
6
timestamp = datetime.now().isoformat()
7
partner_id = "<Your partner id>"
8
api_key = "<Your Signature API Key>"
9
hmac_new = hmac.new(api_key.encode("utf-8"), digestmod=hashlib.sha256)
10
hmac_new.update(timestamp.encode("utf-8"))
11
hmac_new.update(str(partner_id).encode("utf-8"))
12
hmac_new.update("sid_request".encode("utf-8"))
13
14
calculated_signature = base64.b64encode(hmac_new.digest()).decode("utf-8")
Copied!
1
$api_key = "<Your Signature API Key>";
2
$partner_id = "<Your partner id>";
3
$timestamp = new DateTime()->getTimestamp();
4
$message = date(DateTimeInterface::ISO8601, $timestamp).$partner_id."sid_request";
5
$signature = base64_encode(hash_hmac('sha256', $message, $api_key, true));
Copied!
1
String apiKey = "<Your Signature API Key>";
2
String partnerId = "<Your partner id>";
3
Long timestamp = System.currentTimeMillis();
4
Mac mac = Mac.getInstance("HmacSHA256");
5
mac.init(new SecretKeySpec(apiKey.getBytes(), "HmacSHA256"));
6
mac.update(new SimpleDateFormat(DATE_TIME_FORMAT).format(timestamp).getBytes(StandardCharsets.UTF_8));
7
mac.update(partnerId.getBytes(StandardCharsets.UTF_8));
8
mac.update("sid_request".getBytes(StandardCharsets.UTF_8));
9
String signature = Base64.getEncoder().encodeToString(mac.doFinal());
Copied!
1
using System;
2
using System.Security.Cryptography;
3
using System.Text;
4
5
namespace csharp_sample
6
{
7
class Program
8
{
9
static void Main(string[] args)
10
{
11
string timeStamp = DateTime.UtcNow.ToString("yyyy-MM-dd'T'HH:mm:ss.fffK", System.Globalization.CultureInfo.InvariantCulture);
12
string apiKey = "<Your Signature API Key>";
13
string partnerID = "<Your partner id>";
14
string data = timeStamp + partnerID + "sid_request";
15
16
UTF8Encoding utf8 = new UTF8Encoding();
17
Byte[] key = utf8.GetBytes(apiKey);
18
Byte[] message = utf8.GetBytes(data);
19
20
HMACSHA256 hash = new HMACSHA256(key);
21
var signature = hash.ComputeHash(message);
22
23
Console.WriteLine(Convert.ToBase64String(signature));
24
25
}
26
}
27
28
}
29
Copied!