Skip to main content
Version: Beaver (1.4.0)

Create Acceptance Records

Record user acceptance of document packets using the ToughClicks REST API.

Endpoint​

POST /api/v1/client/{clientId}/accept

Request​

Path Parameters​

ParameterTypeRequiredDescription
clientIdstringYesYour unique client identifier

Headers​

HeaderValueRequired
acceptapplication/jsonYes
content-typeapplication/jsonYes

Request Body​

{
"displayMethod": "group",
"signerIdentifier": "string",
"signerEmailAddress": "string",
"packetId": "string",
"applicationContext": {},
"customData": {},
"dynamicData": {}
}

Body Parameters​

ParameterTypeRequiredDescription
displayMethodstringYesHow the terms were displayed: group, individual, or scroll
packetIdstringYesThe ID of the packet being accepted
applicationContextobjectYesContext about the acceptance environment
signerIdentifierstringNoUnique identifier for the user (email, user ID, wallet address, etc.)
signerEmailAddressstringNoEmail address of the signer
customDataobjectNoCustom data to help identify the signer (max 1KB, immutable after acceptance)
dynamicDataobjectNoDynamic values if using tokens in agreements

Display Method Values​

  • group - All documents displayed with a single checkbox
  • individual - Each document has its own checkbox
  • scroll - User was required to scroll through the terms

Application Context​

The applicationContext object is required and can include any relevant information about the acceptance environment:

{
"deviceType": "mobile",
"screenSize": "375x667",
"referrer": "https://example.com/signup",
"pageTitle": "Sign Up - Example App",
"url": "https://example.com/accept-terms",
"timezone": "America/New_York",
"browserVersion": "Chrome 120.0.0",
"operatingSystem": "iOS",
"operatingSystemVersion": "17.2.1"
}

Custom Data​

Custom data allows you to attach additional information to acceptance records. This information helps identify the signer and verify their identity if the acceptance is ever challenged.

Store any additional metadata with the acceptance (up to 1KB limit):

{
"customerId": "cust_12345",
"subscriptionTier": "premium",
"referralSource": "email-campaign",
"accountType": "business"
}
warning
  • Custom data has a 1KB size limit
  • Custom data is immutable after acceptance is created

Dynamic Data​

If your agreements use dynamic tokens, provide the values here:

{
"userName": "John Doe",
"accountType": "Premium",
"expirationDate": "2025-12-31"
}
info

Learn more about dynamic tokens in the Dynamic Contracts guide.

Response​

Success Response​

Status Code: 200 OK

{
"entities": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"created": "2025-10-04T12:34:56Z",
"modified": "2025-10-04T12:34:56Z",
"deleted": null,
"ipAddress": "192.168.1.1",
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
"displayMethod": "group",
"user": "user@example.com",
"signerIdentifier": "user@example.com",
"signerEmailAddress": "user@example.com",
"applicationContext": {
"deviceType": "desktop",
"browserVersion": "Chrome 120.0.0"
},
"customData": {
"orderId": "12345"
},
"versionId": "v1.0",
"version": {
"id": "v1.0",
"versionNumber": "1.0",
"contents": "<h1>Terms of Service</h1>..."
},
"packetId": "3646a13b-cbd1-482c-9947-460cb74a71f2",
"pdfUrl": "https://cdn.toughclicks.com/acceptances/550e8400-e29b-41d4-a716-446655440000.pdf"
}
],
"totalEntities": 1
}

Response Fields​

FieldTypeDescription
entitiesarrayArray of acceptance record objects
totalEntitiesnumberTotal number of acceptance records created

Acceptance Entity Object​

FieldTypeDescription
idstringUnique identifier for the acceptance record
createdstringISO 8601 timestamp when record was created
modifiedstringISO 8601 timestamp when record was last modified
deletedstring | nullISO 8601 timestamp when record was deleted, or null if active
ipAddressstringIP address of the user at time of acceptance
userAgentstringUser agent string of the browser/client
displayMethodstringHow the terms were displayed
userstring(Deprecated) Legacy user identifier field
signerIdentifierstringUnique identifier for the user
signerEmailAddressstringEmail address of the signer
applicationContextobjectContext data provided in the request
customDataobjectCustom data provided in the request
versionIdstringID of the document version that was accepted
versionobjectFull version object of the accepted document
packetIdstringID of the packet that was accepted
pdfUrlstringURL to download a PDF certificate of the acceptance

Error Response​

Status Code: 400 Bad Request

{
"error": "Validation Error",
"message": "applicationContext is required"
}

Status Code: 404 Not Found

{
"error": "Not Found",
"message": "Packet not found for the given client"
}

Examples​

Basic Acceptance​

curl --request POST \
--url https://api.toughclicks.com/api/v1/client/477951a5-069b-401f-ab7f-32db486d5741/accept \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{
"displayMethod": "group",
"signerIdentifier": "user@example.com",
"packetId": "3646a13b-cbd1-482c-9947-460cb74a71f2",
"applicationContext": {
"source": "web-app"
}
}'

With Email and Context​

curl --request POST \
--url https://api.toughclicks.com/api/v1/client/477951a5-069b-401f-ab7f-32db486d5741/accept \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{
"displayMethod": "individual",
"signerIdentifier": "uuid-12345",
"signerEmailAddress": "user@example.com",
"packetId": "3646a13b-cbd1-482c-9947-460cb74a71f2",
"applicationContext": {
"deviceType": "desktop",
"browserVersion": "Chrome 120.0.0",
"operatingSystem": "macOS",
"referrer": "https://example.com/signup"
}
}'

With Custom and Dynamic Data​

curl --request POST \
--url https://api.toughclicks.com/api/v1/client/477951a5-069b-401f-ab7f-32db486d5741/accept \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{
"displayMethod": "scroll",
"signerIdentifier": "user@example.com",
"packetId": "3646a13b-cbd1-482c-9947-460cb74a71f2",
"applicationContext": {
"platform": "web"
},
"customData": {
"orderId": "12345",
"subscriptionTier": "premium"
},
"dynamicData": {
"userName": "John Doe",
"accountType": "Premium"
}
}'

JavaScript Example​

async function createAcceptance(clientId, packetId, userEmail) {
const response = await fetch(
`https://api.toughclicks.com/api/v1/client/${clientId}/accept`,
{
method: 'POST',
headers: {
'accept': 'application/json',
'content-type': 'application/json'
},
body: JSON.stringify({
displayMethod: 'group',
signerIdentifier: userEmail,
signerEmailAddress: userEmail,
packetId: packetId,
applicationContext: {
deviceType: navigator.platform,
browserVersion: navigator.userAgent,
url: window.location.href,
referrer: document.referrer
}
})
}
);

const data = await response.json();

if (response.ok) {
console.log('Acceptance created:', data.entities[0].id);
console.log('PDF URL:', data.entities[0].pdfUrl);
return data;
} else {
console.error('Error:', data.message);
throw new Error(data.message);
}
}

// Usage
const result = await createAcceptance(
'477951a5-069b-401f-ab7f-32db486d5741',
'3646a13b-cbd1-482c-9947-460cb74a71f2',
'user@example.com'
);

console.log(`Created ${result.totalEntities} acceptance record(s)`);

Python Example​

import requests
import json

def create_acceptance(client_id, packet_id, user_email):
url = f"https://api.toughclicks.com/api/v1/client/{client_id}/accept"

payload = {
"displayMethod": "group",
"signerIdentifier": user_email,
"signerEmailAddress": user_email,
"packetId": packet_id,
"applicationContext": {
"deviceType": "server",
"platform": "Python API"
}
}

headers = {
"accept": "application/json",
"content-type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

if response.status_code == 200:
data = response.json()
acceptance_id = data['entities'][0]['id']
pdf_url = data['entities'][0]['pdfUrl']
print(f"Acceptance created: {acceptance_id}")
print(f"PDF URL: {pdf_url}")
return data
else:
print(f"Error: {response.json()['message']}")
raise Exception(response.json()['message'])

# Usage
result = create_acceptance(
'477951a5-069b-401f-ab7f-32db486d5741',
'3646a13b-cbd1-482c-9947-460cb74a71f2',
'user@example.com'
)
print(f"Total entities created: {result['totalEntities']}")

Best Practices​

Always Provide applicationContext​

The applicationContext parameter is required. At minimum, provide a simple object:

{
applicationContext: {
source: "web-app"
}
}

For better compliance tracking, include comprehensive context:

{
applicationContext: {
deviceType: navigator.platform,
browserVersion: navigator.userAgent,
url: window.location.href,
referrer: document.referrer,
screenSize: `${window.screen.width}x${window.screen.height}`,
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
}
}

Use Meaningful Signer Identifiers​

Choose identifiers that will be useful for searching and managing agreements:

  • Email addresses - Best for user-facing applications
  • User IDs - Good for internal systems
  • UUIDs - Use with signerEmailAddress for searchability

Store Relevant Custom Data​

Use customData to link acceptances to your business logic:

  • Order IDs
  • Subscription tiers
  • Campaign identifiers
  • User segments

Save the PDF URL​

The response includes a pdfUrl field that provides a downloadable PDF certificate of the acceptance. Store this URL if you need to provide users with proof of acceptance later:

const result = await createAcceptance(clientId, packetId, email);
const pdfUrl = result.entities[0].pdfUrl;

// Store pdfUrl in your database for later retrieval
await db.users.update(userId, { lastAcceptancePdfUrl: pdfUrl });

Handle Errors Gracefully​

Always check the response status and handle errors appropriately:

try {
const acceptance = await createAcceptance(clientId, packetId, email);
// Proceed with user flow
} catch (error) {
// Show error message to user
// Log error for debugging
// Don't proceed until acceptance is recorded
}

Common Issues​

Missing applicationContext​

The applicationContext field is required. Ensure you always include it, even if it's just a simple object with one property.

Error:

{
"error": "Validation Error",
"message": "applicationContext is required"
}

Fix:

{
applicationContext: { source: "web" } // Minimum required
}

Invalid Packet ID​

Verify the packet ID exists for your client and is published.

Multiple Acceptance Records​

The API creates one acceptance record per document in the packet. The totalEntities field indicates how many records were created. This is normal behavior.

Understanding the Response​

The response returns an entities array because packets can contain multiple documents, and the API creates one acceptance record per document. Check totalEntities to see how many records were created.

Next Steps​