Authentication
The Monnet API uses a Keyed-hash message authentication codes (HMAC) as authentication mechanism to authenticate every single HTTP requests. HMAC is a mechanism for message authentication using cryptographic hash functions.
Every Merchant ID is provided with a pairs of keys. These keys are access credentials composed of alphanumeric characters that authorize the use of specific functionalities of our API.
It is required to use UTF-8 encoding to avoid calculation errors.
Below, we describe the components required to authenticate requests:
Required Variables
Merchant ID: A unique identifier assigned to the merchant using our API. You should provide your assigned Merchant ID when making every single API request.
API Key: An API key that identifies the associated API secret. You must include this key in the header of your requests using the "monnet-api-key" field.
API Secret: An API key Secret associated with the API Key. You must use this value as an input for the HMAC algorithm.
Timestamp: A timestamp generated by the merchant for each request. This timestamp must be included in the API endpoint URL as a query string parameter.
HTTP Method: The HTTP method of the request.
Hashed Body: The body of the request hashed using the alghoritm SHA-256.
Signature: The HMAC result. The signature must be included in the API endpoint URL as a query string parameter.
How to generate the signature
The signature generation is an important step to ensure the authenticity and integrity of requests in our API. There are two important parts of the signature generation:
How to construct the signature content
Extract the HTTP Method of your request.
Extract the resource path of the endpoint that you are sending the request.
Generate a Timestamp, include it in the request as a query parameter. The timestamp is a value that needs to be generated for each request. It should be in a format that includes the date and time information.
Extract the body of your request and execute the SHA-256 on it.
Concatenate all the parameters adding ':' as separator.
How to sign/hash
Calculate the Signature using HMAC-SHA256. The HMAC-SHA256 receives two parameters:
Message: Use the calculated content in the last step.
Secret Passphrase: Use the API Secret.
Include the calculated signature as a query parameter of your request.
Add API Key to Header
Add the API Key as part of the header with the name "monnet-api-key".
Examples
In this section we are going to provide an example of how to calculate the signature:
Variables
API Key
SoSSp+5M4GrYfngfSE78lC2BzvUYQ0k8+i/iHg+bp54=
API Secret
P5yjICOFoE0kmJVMALeBRmoxuWXz0BJKuoSaIXEHTgE=
Merchant ID
22
Example Create Payout:
Request Information
Hash the body using alghoritm SHA-256
Content to Sign
Signed Content
Request with Signature and Header
Example of a Get Payout:
Request Information
Hash the body using alghoritm SHA-256
Content to Sign
Signed Content
Request with Signature and Header
Make sure to follow these security considerations
Keep your keys and Merchant IDs secure. Do not share these values with unauthorized individuals.
Use HTTPS for all API requests to ensure communication security.
Generate a new timestamp for each request to avoid reusing previous requests.
Last updated