Generating an API Key
To generate an API Key- Sign into your account with a web browser
- Click on your address in the upper right corner
- Click “API Keys”
- Click Add New API Key
- Name the key
- Select the correct permissions
- Click “Create API Key”
- Record the secret key
IP Whitelisting
It is strongly recommended to whitelist the IP addresses which are allowed to make requests for the given API key. Up to 16 IP addresses can be added per API key. Only IPv4 addresses are supported at this time. The default state with no whitelisted addresses (empty whitelist) is to allow requests from any IP. If there are addresses on the whitelist, then only requests from the whitelisted IPs are allowed. Requests from IPs not on the whitelist will error with code 401 and message:"IP addr x.x.x.x is not allowed for key ondoKeyId_yyyyyyyy".
Making an authenticated REST request
Authenticated REST requests need the following headers:ONDO-KEY-IDThe key id (including the “ondoKeyId_” prefix)ONDO-TIMESTAMPNumber of milliseconds since the Unix epoch, this must be within 30 seconds of the time the request is received.ONDO-SIGNhex representation of SHA256 HMAC of the following four strings concatenated together using the API Secret (including the “ondoApiSecret_” prefix).timestampidentical to the ONDO-TIMESTAMP headermethodHTTP method in uppercaserequestPathfull path and query parameters of the URL, excluding the hostnamebodyrequest body string
Error Codes
Requests made through API key authentication can fail with the following error codes:api_key_not_found— The API key provided could not be found.failed_to_parse_timestamp— The timestamp provided could not be parsed.timestamp_too_far— The timestamp is too far from the server timestamp (more than 30 seconds in the past or future)failed_to_decode_hex_signature— The hex signature could not be decoded.signature_mismatch— There is a mismatch in the signature.key_doesnt_have_scope— The API key does not have the required scope for the endpoint.ip_not_permitted— The IP address making the request is not whitelisted for this API key.
Example in Go
req.URL.RequestURI() contains the query parameters and should be used, whereas req.URL.Path does not.