> For the complete documentation index, see [llms.txt](https://benpaydex.gitbook.io/benpay-dev-center/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://benpaydex.gitbook.io/benpay-dev-center/rest-api/signature-mechanism.md).

# Signature Mechanism

**Use HMAC SHA256 for parameter signature.**

**Required Configuration Parameters**

Generate [api-key api-secret](/benpay-dev-center/code-demo/generate-api-key-api-secret.md)

```
Test Configuration
api_key AAAAACcVAAABnztMqrATYmlG5XNpNnyY
api_secret 41a2cba262436582f859b1453de08a3c
api_url https://dex-api.benpay.com/

Request Required Headers
API-KEY
API-SIGNATURE-METHOD HmacSHA256  (fixed value)  
API-SIGNATURE-VERSION 1  (fixed value)  
API-TIMESTAMP 1751871801483 (current timestamp in milliseconds) 
API-Signature  (dynamically generated signature)
```

**Signature Steps**

**All parameters are sent via `query string`**

```
Example: Sending a GET request via curl
https://dex-api.benpay.com/v1/contracts/orders/closed?range=202507&offsetId=0&limit=100

payload - Signature Content
Concatenate in order: method host url sorted-params key signature-method version timestamp
GET
dex-api.benpay.com
/v1/contracts/orders/closed
limit=100&offsetId=0&range=202507
API-KEY: AAAAACcVAAABnztMqrATYmlG5XNpNnyY
API-SIGNATURE-METHOD: HmacSHA256
API-SIGNATURE-VERSION: 1
API-TIMESTAMP: 1751876801442 must be included here\n

signature aea0677b6b594b06809ab7b6ecb3255a9aaab391fb7653b43a1c2867d9c6a4d3 payload signature content

Add the above signature as API-Signature in the request header.

Sample curl request
curl -X 'GET' \
  'https://dex-api.benpay.com/v1/contracts/orders/closed?limit=100&offsetId=0&range=202507' \
  -H 'accept: */*' \
  -H 'API-KEY: AAAAACcVAAABnztMqrATYmlG5XNpNnyY' \
  -H 'API-SIGNATURE-METHOD: HmacSHA256' \
  -H 'API-SIGNATURE-VERSION: 1' \
  -H 'API-TIMESTAMP: 1751876801442' \
  -H 'API-Signature: aea0677b6b594b06809ab7b6ecb3255a9aaab391fb7653b43a1c2867d9c6a4d3' \
  -d ''

Response
{"success":true,"data":{"hasMore":false,"nextOffsetId":0,"results":[],"range":"202507"}}
```

**All parameters are sent via `request body`**

```
Example cURL POST request
https://dex-api.benpay.com/v1/contracts/positions/XBTC/settings
body
{"cross":false,"leverage":5}

payload - Signature Content
Concatenate in order: method host url sorted-params key signature-method version timestamp

POST
dex-api.benpay.com
/v1/contracts/positions/XBTC/settings

API-KEY: AAAAACcVAAABnztMqrATYmlG5XNpNnyY
API-SIGNATURE-METHOD: HmacSHA256
API-SIGNATURE-VERSION: 1
API-TIMESTAMP: 1751881676080
{"cross": true, "leverage": 10}

signature 48bb9c5962deac32b5c728d986653e633b5624d025c9c3c419eb3406eb67924d payload signature content

Request headers (must include API-Signature)

Request
curl -X 'POST' \
  'https://dex-api.benpay.com/v1/contracts/positions/XBTC/settings' \
  -H 'accept: */*' \
  -H 'API-KEY: AAAAACcVAAABnztMqrATYmlG5XNpNnyY' \
  -H 'API-SIGNATURE-METHOD: HmacSHA256' \
  -H 'API-SIGNATURE-VERSION: 1' \
  -H 'API-TIMESTAMP: 1751881676080' \
  -H 'API-Signature: 48bb9c5962deac32b5c728d986653e633b5624d025c9c3c419eb3406eb67924d' \
  --data-raw '{"cross":false,"leverage":10}'

Response
{'success': True, 'data': {'id': '10005_900000201', 'userId': 10005, 'symbolId': 900000201, 'riskLimit': {'id': 109, 'initialMarginRate': '0.01', 'maintenanceMarginRate': '0.005', 'marginRateStep': '0.005', 'maxLeverage': 20, 'riskLimitBase': '10', 'riskLimitStep': '5', 'maxRiskLimitSteps': 9, 'maxQuantity': '55', 'createdAt': 1735689600000}, 'cross': True, 'createdAt': 1751336113229, 'updatedAt': 1751881676881, 'entryValue': '0', 'entryPrice': '0', 'margin': '0', 'leverage': 10, 'liquidationPrice': '0', 'direction': 'LONG', 'quantity': '0', 'realizedPNL': '0', 'riskLevel': 0, 'minimumMaintenanceMarginRate': '0.005', 'minQuantity': '0', 'maxQuantity': '10', 'version': 0, 'empty': True}}
```

[Python Demo](/benpay-dev-center/code-demo/send-signed-requests.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://benpaydex.gitbook.io/benpay-dev-center/rest-api/signature-mechanism.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
