Implementing the API
Pre-Requisites
Make sure that you have configured a clientId
and packetId
. See Managing Clients and Managing Packets for more details.
For testing purposes, feel free to use the following:
ClientId: 477951a5-069b-401f-ab7f-32db486d5741 PacketId: 3646a13b-cbd1-482c-9947-460cb74a71f2
Environments
ToughClicks provides access to our staging environment for testing your integration. The URLs are as follows:
- Staging -
https://api.stage.toughclicks.com/api/v1/...
- Production -
https://api.toughclicks.com/api/v1/...
Step 1 - Render the UI
Start by making a request to GET your packet details.
Endpoint Documentation: GET Packet by Id
curl --request GET \
--url https://api.toughclicks.com/api/v1/client/{clientId}/packet/{packetId} \
--header 'accept: application/json'
This will return all the information you need to render the interface for the Signer to accept Terms. This will include display names, URLs to the latest version, the HTML contents of the latest version, and more.
Once the Signer has accepted the Terms, it is now time to create the Acceptancerecords.
Step 2 - Create Acceptance Records
It is now time to create the acceptance records.
Endpoint Documentation: POST Acceptance
curl --request POST \
--url https://api.toughclicks.com/api/v1/client/{clientId}/accept \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"displayMethod": "group",
"signerIdentifier": "string",
"signerEmailAddress": "string",
"packetId": "{packetId}",
"applicationContext": {},
"dynamicData": {}
}
'
That method requests some very important pieces of information:
SignerIdentifier
: this can be any unique identifier for the user. It can be an email, a user id, a crypto wallet, or anything else unique.SignerEmailAddress
: this is an optional field. If you are setting a UUID in the signerIdentifier field, we recommend setting the signer's email here to make it easier to Find and Download Agreements in the ToughClicks dashboard.Display Method
: this should either begroup
if you displayed all the documents with a single checkbox orindividual
if you displayed a checkbox per document. If you are forcing the user to scroll through the terms, this can be set toscroll
.Application Context
: This can be any valid JSON object that provides the context of the interface. Often this includes device type, screen size, referrer, page title, url, timezone, browser/app version, operating system, operating system version, etc. If you are implementing in a mobile app, you can provide any relevant information to the device and experience.Custom Data
: This can be any valid JSON object that you want us to store along with the acceptance record.Dynamic Data
: If you are using tokens in your agreements, you will need to include the Dynamic Data you used when you requested the packet. See Dynamic Contracts for more information.
Once this endpoint returns a success response, you can allow the user to proceed.
On subsequent sessions (Optional)
On subsequent sessions, you may want to verify if a user has agreed to the most recent version of the terms. If they have not, you may ask them to accept the latest version.
API Endpoint: Verify User's Acceptance
curl --request GET \
--url https://api.toughclicks.com/api/v1/client/{clientId}/packet/{packetId}/verify/{signerIdentifier} \
--header 'accept: application/json'
The response includes each document's latestVersion
and latestAgreement
which represents the latest version a user has agreed to.
We have also included a convenience field call userCompliant
which is false if there has been a major version release since the user's most recent agreement.
If you want the user to accept the latest terms, go back up to Step 1 and get the packet information, render the ui, then go to Step 2 and create a new acceptance record.