Keys and environments
Three credentials
Send each as Authorization: Bearer ….
- A publishable key only identifies the product and its environment, so it’s safe in your page’s source.
- A review token is returned once, in the check’s
review.token. It lets the holder send that review’s quote and read its status, nothing more. - A secret key reads a review’s full outcome, including the decline reason. Store it as you would any server secret.
Create and revoke keys on the portal’s API keys page (an admin can). The portal shows a key in full only once, when it’s created; after that it shows only how the key starts. A key of the wrong kind, a revoked key or another region’s key is refused with 401 invalid_key.
Test and live
Every key belongs to one environment: test or live, the second part of the key.
Both use the same host. Test reviews are kept separate from live ones: a test secret key reads only test reviews, and asking for a review from the other environment gets 404 review_not_found. The outcome’s env field says which environment a review is in.
Allowed websites
Each product has a list of allowed websites for each environment, on its API keys page. Every route except /api/v1/server/* checks the request’s Origin header against the list for the key’s environment (or, for the review token routes, the review’s environment):
- The origin must match exactly: scheme, host and port, with no path. There are no wildcards, so add each address you use, such as
https://www.example.comandhttps://quote.example.com. - Live websites must use https.
- A missing or unlisted origin is refused with
403 origin_not_allowed.
Browsers send Origin for you. From a server, send it yourself, set to one of the product’s allowed websites. Here HUMANAPPROVED_URL is your region’s address:
The secret key route, /api/v1/server/reviews/{reviewId}, needs no Origin and sends no CORS headers: it’s for servers only.
The routes a page calls respond to CORS preflights from any origin, and the real request is then checked against your allowed websites. A key, token or website that’s refused gets a response without CORS headers, so in a browser it shows as a network error. The status and error code are in the browser’s network panel.
Keys and regions
A key works only in the region it was created in. A key sent to another region’s host is refused with invalid_key.
A key from the US portal works only with https://us.humanapproved.com.
The embed works out the host from the key, so you don’t configure one. Leave the embed’s baseUrl option unset.
See Regions and data.