
API Key and Vendor Details: You'll need a secret VENDOR_API_KEY (a string) and VENDOR_NUMBER (a string identifying your account)
Cryptographic Libraries: Most programming languages have built-in or standard libraries for SHA-256 hashing and HMAC:
JavaScript/Node.js: crypto module.
Python: hashlib and hmac modules.
Java: java.security and javax.crypto.
Other languages (e.g., C#, Go, Ruby) have equivalents—adapt as needed.
JSON Handling: Ensure your environment can serialize objects to JSON strings without extra whitespace.
Best Practices:
Store the API key securely.
Never commit secrets to version control.
Use UTF-8 encoding for all string operations.
Create a JSON object with the structure required by the endpoint.
Serialize the object to a JSON string. Ensure consistent formatting (e.g., no unnecessary spaces or sorting changes) to avoid signature mismatches.
Take the raw API key string.
Encode it as UTF-8 bytes.
Apply SHA-256 hashing to produce a 32-byte (256-bit) digest. This digest acts as a derived secret key for the HMAC, enhancing security.
Use the SHA-256 digest from Step 2 as the secret key.
Use the JSON string from Step 1 as the message.
Compute the HMAC-SHA256, which produces another 32-byte digest.
Convert this digest to a lowercase hexadecimal string (64 characters).
Use the hexadecimal string as the value for the Authorization header in your HTTP request (e.g., Authorization: <hex_string>).
Send the request with the exact JSON body used for signing. Any mismatch will invalidate the signature.