The ClickTerm Web SDK uses Promises to communicate results. The show() and showAcceptedContent() methods return promises that resolve on success and reject on error.
Show result
When ClicktermDialog.show() resolves:
ClicktermDialog . show ({
endUserId: "user-123" ,
clickwrapTemplateId: "YOUR_TEMPLATE_ID" ,
}). then (( result ) => {
// result.clicktermSignature — the Signature to send to your backend
console . log ( "Signature:" , result . clicktermSignature );
}). catch (( error ) => {
// SDK or network error
console . error ( "Error:" , error );
});
Possible outcomes
Outcome What happens User accepts Promise resolves with a Signature — send it to your backend User declines Promise resolves with a Signature — verify it to record the decline User already accepted Promise resolves with null Signature — no dialog was shown Error Promise rejects with an error message
A null Signature means the user has already accepted the latest major version.
No action is needed on your part.
Error handling
Errors are returned via the Promise .catch() handler:
ClicktermDialog . show ({
endUserId: "user-123" ,
clickwrapTemplateId: "YOUR_TEMPLATE_ID" ,
}). catch (( error ) => {
// Handle error — e.g., SDK not initialized, network issue, template not found
console . error ( "Clickwrap error:" , error );
});
Common error scenarios:
Error Cause SDK not initialized ClicktermClient.initialize() was not calledTemplate not found Template is disabled or has no effective version Network error Cannot reach the ClickTerm API
Using async/await
example.js (JavaScript)
example.ts (TypeScript)
try {
const result = await ClicktermDialog . show ({
endUserId: "user-123" ,
clickwrapTemplateId: "YOUR_TEMPLATE_ID" ,
});
if ( result . clicktermSignature ) {
// Send to backend for verification
await verifySignature ( result . clicktermSignature );
} else {
// User already accepted — no action needed
}
} catch ( error ) {
console . error ( "Clickwrap error:" , error );
}