Authentication parameters
V1 signing uses HMAC. Every request signed with V1 must include the following headers:API-KeyHTTP header parameter: your public API key.API-NonceHTTP header parameter: monotonically increasing integer nonce.API-SignHTTP header parameter: HMAC-SHA512 signature of the request.
Setting the API-Key parameter
The value for the API-Key HTTP header parameter is your public API key. Create new keys for V2 signing instead, as described in Authentication.
Setting the API-Nonce parameter
Set API-Nonce to an integer greater than the last value you used with the same API key.
Use a high-resolution timestamp, such as nanoseconds since the Unix epoch, unless your integration already has a stronger monotonic counter.
Don’t use a timer with an arbitrary origin, such as process.hrtime() in Node.js. It resets when the machine restarts, so your next nonce can be lower than the last one you sent.
Setting the API-Sign parameter
The value for the API-Sign HTTP header parameter is an HMAC-SHA512 signature of the request, base64-encoded.
Algorithm steps
- Choose a nonce: generate a monotonically increasing integer.
- Build the nonce payload: concatenate the nonce and the exact request body bytes.
- For requests without a body: use the nonce only.
- For requests with a body: use the exact bytes you send on the wire.
- Hash the nonce payload: generate a SHA-256 digest.
- Build the message: concatenate the URL path, including query string, and the SHA-256 digest.
- Sign: generate HMAC-SHA512 over the message using your base64-decoded secret.
- Encode: base64-encode the signature.
Examples
The following code snippets demonstrate how to generate the signature in Python and JavaScript.Complete request example
Here’s a complete example making an authenticatedGET request to list your webhooks. It reads your credentials from PWS_API_KEY and PWS_API_SECRET, and the API base URL from PWS_BASE_URL. Set PWS_BASE_URL to the sandbox or production base URL, listed in Environments.
401 Unauthorized instead.
Query parameters in signature
When your request includes query parameters, they must be included in the URL path used for signature generation. Use the exact same path string in both the signature and the request URL. The examples in this section and the next one call account-scoped endpoints. They read the account ID fromPWS_ACCOUNT_ID. To find it, see Find your account ID. A user ID won’t work in its place. See Users, accounts, and ownership.
Request body in signature
For requests that send a body (POST, PUT), the body bytes used to compute the signature must match the bytes sent on the wire exactly. Differences in whitespace, key ordering, or encoding will produce a signature mismatch.
The recommended pattern is to serialize the body once and reuse the same string for both signing and the HTTP request: