Authentication

All requests to the Ledig API (except for the open /health endpoint) require authentication using API keys with HMAC signing. This ensures every request is verifiable and secure.


๐Ÿ”‘ API Keys

  • You can generate API keys in the Settings section of your Ledig dashboard.

  • Each key pair consists of:

    • API Key โ†’ Public identifier (x-ledig-key)

    • Secret Key โ†’ Used to generate HMAC signatures (โš ๏ธ never share or hardcode into frontend code)

๐Ÿ‘‰ Generating a new key revokes the previous one and issues a new secret. Always update your integration accordingly.


๐Ÿ“Œ Required Headers

Every authenticated request must include the following headers:

Header
Description

x-ledig-key

Your API key (public identifier)

x-ledig-timestamp

Current UNIX timestamp (in seconds)

x-ledig-signature

HMAC-SHA256 signature generated using your secret key and request payload


๐Ÿงฎ Signature Calculation

The signature is built as follows:

  • timestamp โ†’ The value sent in x-ledig-timestamp

  • HTTP_METHOD โ†’ GET, POST, etc.

  • PATH_WITH_QUERY โ†’ The path including any query string (e.g. /v1/rates?pair=USDT-NGN)

  • BODY โ†’ For POST/PUT requests, the raw request body. For GET, use an empty string.


๐Ÿ“ Sample Payload Debug

When debugging your integration, it helps to log the signed payload string. This is the exact string your system will HMAC-sign.

Example GET request:

Example POST request:

If your signature doesnโ€™t match, first confirm your payload string looks exactly like this.


๐Ÿ“ Example (cURL)


๐Ÿ’ป Example Code

Node.js

Python


โš ๏ธ Best Practices

  • Always use the server side to sign requests (never expose your secret).

  • Ensure your system clock is accurate (we allow a few seconds of drift).

  • Rotate keys periodically and delete unused ones.