Last updated
Last updated
In order to authorize your requests, get a .
Authorization is required:
To verify your request and prove your ownership of the merchant.
To verify notifications (webhooks) that 0xpay sending to your server to verify the authority.
General formula is:
signature = hmacsha256(method + url + body + timestamp, privateKey)
Overall guide to build your signature is described below:
Concatenate HTTP method(POST
, GET
, etc), URL path, request body (or an empty string, if the body is empty), and timestamp in seconds. Let's call resulted string <MESSAGE>
Sign received <MESSAGE>
using algorithm with merchant's <PRIVATE_KEY>
. Let's call resulted hash <SIGNATURE>
To make a valid request, you have to include several headers along with it:
For example, I want to create an address in the BITCOIN network. I have to POST /merchants/addresses
the API endpoint. Here is my payload:
Let's say, that my current timestamp is 1650289480
(in seconds!!!). Lets concatenate parts of our request and we will receive next <MESSAGE>
:
As far as we already generated <SIGNATURE>
, we can make a request.
Body of the webhook is:
Header of the request:
Now you can generate the signature using the formula mentioned above and compare it with the SIGNATURE
we sent you in headers. If signatures match, then the request is original.
Let's build exemplary signatures for each of our requests in order to demonstrate the logic behind this process. In this case, we can equal values for
Then, I will receive <SIGNATURE>
using with the private key
.
Let's assume that you receive some replenishment webhook sent from 0xpay server, that is directed to some domain.com/webhooks/0xpay
endpoint you have specified earlier in the .
So then build the <MESSAGE> mentioned
merchant-id
Copy it from your 0xpay Dashboard -> Merchant Settings section.
signature
<SIGNATURE>
timestamp
<TIMESTAMP>