user-keyAPI Authentication

This document describes the authentication mechanism for the CardsPro API using custom HTTP headers with SHA-256-based signatures.

Overview

The CardsPro API uses a signature-based authentication system that requires three custom HTTP headers on every request. This ensures that requests are authenticated and have not been tampered with in transit.

Required HTTP Headers

All API requests must include the following three headers:

Header
Description

CAP-TOKEN

Your API Key

CAP-NONCE

Current timestamp in milliseconds

CAP-SIGN

SHA-256 signature (see calculation below)

Authentication Process

1. Obtain API Credentials

You need two credentials to authenticate:

  • API Key: Your public identifier (sent as CAP-TOKEN)

  • Secret Key: Your private signing key (used to generate CAP-SIGN, never sent directly)

2. Generate the Nonce

Create a nonce using the current timestamp in milliseconds:

const nonce = Date.now().toString();

3. Calculate the Signature

The signature calculation differs based on the HTTP method:

For POST Requests

Components:

  • CAP-NONCE: The timestamp in milliseconds

  • request_body: The JSON or form-encoded request body as a string

  • query_string: The URL query parameters (e.g., param1=value1&param2=value2)

  • secret: Your Secret Key

For GET Requests

Components:

  • CAP-NONCE: The timestamp in milliseconds

  • query_string: The URL query parameters (e.g., param1=value1&param2=value2)

  • secret: Your Secret Key

Note: If there are no query parameters, use an empty string for query_string.

Complete Request Examples

POST Request with Query Parameters

Signature Calculation:

GET Request with Query Parameters

Signature Calculation:

Last updated