Make your first Truework Direct order
The Truework Direct Order API enables you to seamlessly integrate the Truework.js widget directly into your frontend, enabling in-app verifications so that consumers don’t have to leave your application to provide verified employment data.
In this guide, we’ll explore how to set up and test creating a Truework Direct Order. Get ready to dive in and make your first request with ease!
Prerequisites
- Set up a Truework account
- Generate a sandbox API Key and Publishable Key under developer settings from your Truework account
- Notify implementations@truework.com when you are ready to begin implementing to ensure your Publishable Key is properly configured based on your workflow as the Publishable Key controls which verification methods are included in your API request
Integrating with the Truework Direct
Creating a Truework Direct order
To get started and initiate your first verification request, you will Create a Truework Direct order. To call the Truework Direct order endpoint, you will need to make a POST request to the /orders/truework-direct
endpoint. Making this POST request creates an order that will contain zero or more verifications, each containing one verification report per employer.
Example request
The POST request also generates a token that will be used to initialize Truework.js, the consumer-facing widget that will enable the user to complete the verification. The token represents a unique instantiation of the widget, including any preloaded employment information.
Initializing the Truework.js widget
On your backend, create an API endpoint that calls the /orders/truework-direct
endpoint to initialize a Truework.js session. Use the Truework direct session token from the /orders/truework-direct
call to initiate Truework.js.
Add the Truework.js script tag to your application’s HTML page(s). On page load, Truework.js will be available on the global window.Truework object.
Finally, from the front end UI (e.g. button) call the API endpoint you created on your backend and use the returned token to instantiate the Truework Direct flow.
Within the targets object, you may optionally hint to the applicant which companies they should verify or not verify (if you have already verified a company via other means). If you do not know which company the applicant works for and would like them to select it on their own, you may omit the companies
field.
The Truework.js widget will activate when the button is clicked and the user will be guided through each of the verification methods enabled for your workflow. Once the user successfully completes their verification, regardless of method, you will asynchronously receive updates through webhooks and can fetch the related report data when the data is ready.
The verification will automatically move through each of the verification methods from Instant > Credentials > Smart Outreach.
Listening for webhooks
Truework uses webhooks to asynchronously update our partners when a verification is completed. Webhooks are configured under developer settings in the Truework app.
There are two types of webhooks: order completed and verification state change.
Order completed webhook
The order.completed
webhook will be issued when all employer verifications associated with the order have been completed
or canceled
. Once you receive this webhook, you can fetch the order results.
Verification state change webhook
With Smart Outreach verifications, you’ll likely need more granular updates about the data contained within an order. The verification_request.state.change
webhook is issued when a verification request in the order changes state.
States of note include pending-approval
, processing
, action-required
, completed
, and canceled
.
Of interest will mostly be the states completed
and canceled
:
- A
completed
state indicates that new data is now available on the order - A
canceled
state indicates that a verification was not able to be completed, but may have user-provided information and/or documents
If a verification reaches Smart Outreach, it can hit an action-required
state, indicating that more information is required to process the request. Additional information required can be found in the Truework app.
Receiving report data
Once an order.completed
webhook is received, to fetch an order, and all verification reports associated with that order, make a GET request to /orders/{order_id}.
The employment report(s) will be in the verification_requests[].reports
list in the API response.
Moving to production
When your integration is complete (or nearing completion), follow the steps below:
- Generate your production API Key and Publishable Key under developer settings from your Truework account
- Notify implementations@truework.com you are ready to move to production at least three (3) days prior to the target go live date
Questions?
Not a problem, we are here to help! Send your questions to implementations@truework.com.