Skip to main content
Generate a Token
Use this endpoint to get a business token. Your server signs the request with its API secret and sends its API key in the X-BH-APIKEY header. The response contains a token, which you send in the X-BH-TOKEN header on authenticated requests, and an expireTime.
Before this call can succeed, VelaFi must enable API access on your account and the API key must have an IP whitelist. The request must come from an IP address on that whitelist. See Authentication.

Endpoint

Use https://api-test.velafi.com/v2/token/generate with your sandbox credentials for sandbox testing.

Request Headers

string
required
Your API key.

Query Parameters

integer
required
The current Unix time in milliseconds, for example 1740568725231.
string
required
HMAC-SHA256 of the string timestamp=<timestamp>, keyed with your API secret and encoded as lowercase hex.
Send only timestamp and signature as query parameters. The server verifies the signature against your query string without the signature parameter. With only these two parameters, the signed string is exactly timestamp=<timestamp>.

How to Sign

1

Build the message

Take the current Unix time in milliseconds and build the string timestamp=<ms>, for example timestamp=1740568725231.
2

Compute the HMAC

Compute HMAC-SHA256 of the message, using your API secret as the key.
3

Hex-encode the result

Encode the 32-byte result as a 64-character lowercase hex string. This is the signature.

Response Fields

integer
200 on success. Errors return a negative code; see Errors.
string
SUCCESS on success, otherwise an error message.
object

Examples

Response

Errors

Errors return HTTP status 400 with a negative code:

Using the Token

Send the token in the X-BH-TOKEN header:
Request a new token before expireTime. A call with an expired or unknown token fails with code -1022.