> For the complete documentation index, see [llms.txt](https://docs.inqud.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.inqud.com/developer/authentication.md). Agents can also search and read this documentation through its [MCP server](https://docs.inqud.com/~gitbook/mcp).

# Authentication

To use the Inqud API you need to get an API id and secret keys.

Following steps explain how to get API token:

1. Sign up or log into Inqud's [app](https://app.inqud.com/).
2. Navigate to[ user settings](https://app.inqud.com/#/profile) and pass KYC process.
3. Ask your personal manager to get access to the API.&#x20;
4. On the same page in the "API tokens" section click "Add API token".
5. Fill in the form on the modal window and click "Create API token".
6. After that you will be provided with "Token Id" and "Token Secret".
7. Now you all set! Please store the keys securely. If the credentials were compormised you can revoke it at any time on the same page.

### API Tokens in action

Every request carries the token id in `X-Token-API-Id` and is authenticated in one of these ways:

* **Secret:** the token secret in `X-Token-API-Secret`. Works with every token.
* **HMAC signature v2:** for tokens created after the API key scopes release (November 2026). New and rotated tokens accept only v2.
* **HMAC signature v1:** for tokens created before. These tokens keep working with v1 and do not accept v2.

A token accepts only its own signature version.

#### Secret

```
X-Token-API-Id      Identifier of the token (starts with TKN-)
X-Token-API-Secret  Token secret
```

#### HMAC signature v2

```
X-Token-API-Id           Identifier of the token (starts with TKN-)
X-Timestamp              Unix time in seconds, within 300 seconds of the server time
X-Salt                   Random string up to 128 characters, new for every request
X-HMAC-SHA256-Signature  Signature, hex
```

Signature = HmacSHA256 with the token secret over the following string, the parts separated by a newline (`\n`):

```
{X-Timestamp}
{HTTP method, upper case}
{request path with its query string exactly as sent, e.g. /v1/user/wallet/balances?currency=USD}
{X-Salt}
{raw request body exactly as sent; empty for a request without a body}
```

A salt is accepted once per token: a repeated salt is rejected.

#### HMAC signature v1 (tokens created before November 2026)

```
X-Token-API-Id           Identifier of the token (starts with TKN-)
X-HMAC-SHA256-Signature  Signature, hex
X-Salt                   Salt (nonce)
```

Signature = HmacSHA256 with the token secret over (request body + salt). For a request without a body use `""` as the body.

#### Python examples

**Secret, GET**

```python
import requests

token_id = 'TKN-6c1296b8-6929-443b-ac06-f732e0e27be1'
token_secret = 'dBajIp3wHnw5euxohPiZvsCEorG3Fhl9gsHl1UIBlsImHjWRdSJdp4Gh6e3y2PNs'

headers = {'X-Token-API-Id': token_id, 'X-Token-API-Secret': token_secret}
response = requests.get('https://api.inqud.com/v1/user/wallet/balances', headers=headers)
print(response.text)
```

**HMAC v2**

```python
import hashlib
import hmac
import json
import secrets
import time

import requests

base_url = 'https://api.inqud.com'
token_id = 'TKN-6c1296b8-6929-443b-ac06-f732e0e27be1'
token_secret = 'dBajIp3wHnw5euxohPiZvsCEorG3Fhl9gsHl1UIBlsImHjWRdSJdp4Gh6e3y2PNs'


def signed_headers(method, path, body=''):
    timestamp = str(int(time.time()))
    salt = secrets.token_hex(32)
    message = f'{timestamp}\n{method}\n{path}\n{salt}\n{body}'
    signature = hmac.new(token_secret.encode('utf-8'), message.encode('utf-8'), hashlib.sha256).hexdigest()
    return {
        'X-Token-API-Id': token_id,
        'X-Timestamp': timestamp,
        'X-Salt': salt,
        'X-HMAC-SHA256-Signature': signature,
    }


# GET: the body is empty
path = '/v1/user/wallet/balances'
response = requests.get(base_url + path, headers=signed_headers('GET', path))

# POST: sign exactly the bytes you send
path = '/v1/user/payments/payout'
body = json.dumps({"amount": 50, "cardNumber": "5555555555554444", "firstName": "John",
                   "lastName": "Doe", "phoneNumber": "+111111111111",
                   "method": "CC_VISAMC", "currency": "USD"})
headers = signed_headers('POST', path, body)
headers['Content-Type'] = 'application/json'
response = requests.post(base_url + path, headers=headers, data=body)
```

**PHP example (HMAC v2)**

```php
<?php

const BASE_URL = 'https://api.inqud.com';
const TOKEN_ID = 'TKN-6c1296b8-6929-443b-ac06-f732e0e27be1';
const TOKEN_SECRET = 'dBajIp3wHnw5euxohPiZvsCEorG3Fhl9gsHl1UIBlsImHjWRdSJdp4Gh6e3y2PNs';

function signedRequest(string $method, string $path, string $body = '')
{
    $timestamp = (string) time();
    $salt = bin2hex(random_bytes(32));
    // "\n" in double quotes is a newline; '\n' in single quotes is not
    $message = $timestamp . "\n" . $method . "\n" . $path . "\n" . $salt . "\n" . $body;
    $signature = hash_hmac('sha256', $message, TOKEN_SECRET);

    $headers = [
        'X-Token-API-Id: ' . TOKEN_ID,
        'X-Timestamp: ' . $timestamp,
        'X-Salt: ' . $salt,
        'X-HMAC-SHA256-Signature: ' . $signature,
    ];
    $ch = curl_init(BASE_URL . $path);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    if ($body !== '') {
        $headers[] = 'Content-Type: application/json';
        curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
    }
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    return curl_exec($ch);
}

// GET: the body is empty
echo signedRequest('GET', '/v1/user/wallet/balances');

// POST: sign exactly the string you send
$body = json_encode([
    'amount' => 50, 'cardNumber' => '5555555555554444', 'firstName' => 'John',
    'lastName' => 'Doe', 'phoneNumber' => '+111111111111',
    'method' => 'CC_VISAMC', 'currency' => 'USD',
]);
echo signedRequest('POST', '/v1/user/payments/payout', $body);
```

**JavaScript example (Node.js 18+, HMAC v2)**

Sign requests on your server only: the token secret must never reach a browser.

```javascript
const crypto = require('crypto');

const baseUrl = 'https://api.inqud.com';
const tokenId = 'TKN-6c1296b8-6929-443b-ac06-f732e0e27be1';
const tokenSecret = 'dBajIp3wHnw5euxohPiZvsCEorG3Fhl9gsHl1UIBlsImHjWRdSJdp4Gh6e3y2PNs';

function signedHeaders(method, path, body = '') {
  const timestamp = String(Math.floor(Date.now() / 1000));
  const salt = crypto.randomBytes(32).toString('hex');
  const message = `${timestamp}\n${method}\n${path}\n${salt}\n${body}`;
  const signature = crypto.createHmac('sha256', tokenSecret).update(message, 'utf8').digest('hex');
  return {
    'X-Token-API-Id': tokenId,
    'X-Timestamp': timestamp,
    'X-Salt': salt,
    'X-HMAC-SHA256-Signature': signature,
  };
}

async function main() {
  // GET: the body is empty
  let path = '/v1/user/wallet/balances';
  let response = await fetch(baseUrl + path, { headers: signedHeaders('GET', path) });
  console.log(await response.text());

  // POST: sign exactly the string you send
  path = '/v1/user/payments/payout';
  const body = JSON.stringify({
    amount: 50, cardNumber: '5555555555554444', firstName: 'John',
    lastName: 'Doe', phoneNumber: '+111111111111',
    method: 'CC_VISAMC', currency: 'USD',
  });
  response = await fetch(baseUrl + path, {
    method: 'POST',
    headers: { ...signedHeaders('POST', path, body), 'Content-Type': 'application/json' },
    body,
  });
  console.log(await response.text());
}

main();
```

The full reference, including scopes of every endpoint, is at [apireference.inqud.com](https://apireference.inqud.com/#section/Authentication/HmacSignatureV2Auth).
