-
Notifications
You must be signed in to change notification settings - Fork 19
API Documentation (v2)
⚠️ Note: This article is intended for HelloSign Embedded v2. If you are using an older version of HelloSign Embedded, please refer to the documentation on our website.
new HelloSign([options])
Create a new HelloSign Embedded client instance in order to embed a signature request into your webapp. In most cases, only one instance of HelloSign should exist per application. Any options specified when instantiating a new HelloSign Embedded client instance will be used as the config base when calling client.open()
.
Note: It should not be necessary to create a new client instance every time you want to call client.open()
.
-
classNames
ObjectAn enum of class names used by HelloSign Embedded.
-
events
ObjectAn enum of events emitted by a HelloSign Embedded client instance.
-
locales
ObjectAn enum of locale codes supported by HelloSign.
-
messages
ObjectAn enum of window event message types sent by the HelloSign app.
-
version
stringThe current version of HelloSign Embedded.
-
element
HTMLElementThe base element for HelloSign Embedded (if it is in the DOM).
-
isOpen
booleanWhether or not HelloSign Embedded is open.
-
isReady
booleanWhether or not the HelloSign app has initialized and is ready for signing.
-
options
Object (optional)See Type: Options.
-
Instantiate a new HelloSign Embedded client.
const client = new HelloSign();
-
Instantiate a new HelloSign Embedded client with options.
const client = new HelloSign({ clientId: 'Your client ID', debug: true, locale: HelloSign.locales.ZH_CN });
A HelloSign Embedded client
instance has the following public methods:
client.open(url[, options])
Opens the HelloSign Embedded signature request window with the given URL. The provided URL can either be a signature sign_url
, a signature request template edit_url
, or a claim_url
. See the HelloSign API documentation for more information. Options specified here will be merged with options specified when the client was instantiated (if any).
Emits open
.
-
url
stringThe url to open with HelloSign Embedded.
-
options
Object (optional)See Type: Options.
-
Open the
signUrl
in the HelloSign Embedded client.client.open(signUrl);
-
Open the
signUrl
in the HelloSign Embedded client with options.client.open(signUrl, { allowCancel: false, debug: true, locale: HelloSign.locales.ZH_CN });
client.close()
Closes the HelloSign Embedded signature request window if it is open.
Emits close
.
client.close();
Inherited from tiny-emitter
. Documentation can be found here.
-
Log when the signature request has been signed.
client.on('sign', (data) => { console.log('The signature request was signed!'); });
-
Log when the signature request has been reassigned.
client.on('reassign', (data) => { console.log(`The signature request was reassigned to ${data.email}`); });
Inherited from tiny-emitter
. Documentation can be found here.
-
Only once log when the signature request has been signed.
client.once('sign', (data) => { console.log('The signature request was signed!'); });
-
Only once log when the signature request has been reassigned.
client.once('reassign', (data) => { console.log(`The signature request was reassigned to ${data.email}`); });
Inherited from tiny-emitter
. Documentation can be found here.
-
Unsubscribe a single
sign
event listener.const handleSign = (data) => { console.log('The signature request was signed!'); }; client.off('sign', handleSign);
-
Unsubscribe all
sign
event listeners.client.off('sign');
A HelloSign Embedded client
instance emits the following events:
Emitted when the signature request or template was canceled by the user by either pressing the close button or selecting "close" from the "⋮" dropdown list.
client.on('cancel', () => {
console.log('The signature request was canceled');
});
Emitted when the HelloSign Embedded window has closed.
client.on('close', () => {
console.log('The signature request window was closed');
});
Emitted when the user has finished the template creation flow and it has been sent to HelloSign for processing. Note: the template might not be ready to use immediately. Before using a newly-created template, it is recommended that you first use the HelloSign SDK to determine the status of the template.
-
templateId
stringThe template ID.
-
templateInfo
Object-
title
stringThe signature request template title.
-
message
stringThe signature request template message.
-
signerRoles
SignerRole[]The signature request template signer roles. See Type: SignerRole.
-
ccRoles
string[]The signature request template CC roles.
-
client.on('createTemplate', (data) => {
console.log(`The signature request template "${data.templateInfo.title}" was created!`);
});
Emitted when the user declines the signature request by selecting "decline" from the "⋮" dropdown list (if allow_decline=1
).
-
signatureId
stringThe signature ID.
-
reason
stringThe reason given by the user why the signature request was declined.
client.on('decline', (data) => {
console.log(`The signature request was declined because "${data.reason}"`);
});
Emitted when the HelloSign app encounters an error.
-
signatureId
stringThe signature ID.
-
code
stringOne of the following error codes:
-
network_error
- Lost connectivity -
credentials_required
- Login required -
verify_email
- Verify email step for template links -
not_found
- Resource not found -
signer_choice
- Must specify which signer they are -
no_valid_signature_types
- No signature type allowed due to settings -
server_error
- Generic server error -
access_code_required
- Must enter access code -
access_code_invalid
- Access code entered is invalid -
access_code_blocked
- Invalid access code entered too many times -
nothing_to_sign
- Nothing to signer or already signer -
bad_request
- Invalid request parameter(s) -
bad_method
- Unexpected HTTP method -
unknown
- Unknown exception
-
client.on('error', (data) => {
console.log(`Something went wrong! Please try again. Error code: ${data.code}`);
client.close();
});
Emitted when the user has finished the embedded template or signature request flow without cancelling. However, the user may have declined or reassigned the signature request.
client.on('finish', () => {
console.log('The signature request was finished');
});
Emitted when HelloSign Embedded has received a cross-origin window message from the HelloSign app.
-
type
stringThe window event message type. See
HelloSign.messages
. -
payload
?ObjectData relevant to the window message event, if applicable. Not all window message events will contain a payload.
client.on('message', (data) => {
if (data.type === HelloSign.messages.USER_SIGN_REQUEST) {
console.log('The signature request was signed');
}
});
Emitted when the HelloSign Embedded window has opened.
-
url
stringThe original URL.
-
iFrameUrl
stringThe final URL that will be embedded into the iFrame.
client.on('open', (data) => {
console.log(`The signature request was opened with ${data.iFrameUrl}`);
});
Emitted when the HelloSign app embedded in the iFrame has initialized and the signature request is ready.
Note: Embedded signing only.
-
signatureId
stringThe signature ID.
client.on('ready', (data) => {
console.log(`The app has initialized the signature request (id: ${data.signatureId})');
});
Emitted when the user reassigns the signature request by selecting "reassign" from the "⋮" dropdown list (if allow_reassign=1
).
-
signatureId
stringThe signature ID.
-
name
stringThe name of the reassignee.
-
email
stringThe email of the reassignee.
-
reason
stringThe reason given by the user why the signature request was reassigned.
client.on('reassign', (data) => {
console.log(`The signature request was reassigned to ${data.email} because "${data.reason}"`);
});
Emitted when the user sends the signature request.
-
signatureRequestId
stringThe signature request ID.
-
signatureRequestInfo
Object-
title
stringThe signature request title.
-
message
stringThe signature request message.
-
signatures
Signature[]The signature request signatures. See Type: Signature.
-
ccEmailAddresses
string[]The signature request CC emails.
-
client.on('send', (data) => {
console.log(`The signature request was sent! (request id: ${data.signatureRequestId}`);
});
Emitted when the user signs the signature request.
-
signatureId
stringThe signature ID.
client.on('sign', (data) => {
console.log(`The signature request was signed! (id: ${data.signatureId})`);
});
-
signer_name
stringThe signer's name.
-
signer_email_address
stringThe signer's email address. This is the email where the signature request will be sent to.
-
order
?numberThe signer's position within a signature request. If there are multiple signers assigned to a signature request and order is enforced, all signers will be given a place in line. May be
null
.
-
name
stringThe role name.
-
order
numberThe role order.
-
allowCancel
booleanHistory
Version Changes v2.0.1 Honored in embedded signing. Whether or not to allow the user to cancel the signature request by showing a close button.
Default:
true
-
clientId
stringThe client ID for your API app.
Note: This must be specified in at least one place: either when instantiating a new HelloSign Embedded client, or in the
options
ofclient.open()
. -
container
HTMLElementAn HTML element in the DOM which the embedded signature request iFrame will be appended to. By default, HelloSign Embedded will open in a modal.
-
debug
booleanWhether or not to display debug information in the console from the HelloSign app.
Default:
false
-
hideHeader
booleanWhether or not to hide the signature request header. Only honored for customers with embedded branding.
Default:
false
-
locale
stringHistory
Version Changes v2.9.0 The default value was removed. In older versions of HelloSign Embedded, if no locale
was specified, then HelloSign Embedded would default toen-US
. This was removed so that that web app can be used to determine an appropriate locale based on the user's default browser settings.The code for the language to use in the embedded request. Use
HelloSign.locales
to view an enumerable of supported locale codes. If this option is omitted, then the HelloSign web app will attempt to use the language defined by the user's default browser settings. If the language is not supported, then the web app will fall back to English.Note: Czech (
cs-CZ
) is only supported in Embedded Signing. -
redirectTo
stringA URL pointing to where to redirect to after the embedded signature request has been completed by the user.
-
requestingEmail
stringThe email of the account issuing the signature request.
Note: This option is only necessary for Me and Others type signature requests. If it is required, either specify when instantiating a new HelloSign Embedded client, or in the
options
ofclient.open()
. -
skipDomainVerification
booleanWhether or not to skip domain verification. Useful for testing signature requests on developer domains that don't match the API app's domain (like
localhost
).Note: Only honored if the signature request was created via the API with
test_mode=1
.Default:
false
-
testMode
booleanHistory
Version Changes v2.2.0 Added. Alias of
skipDomainVerification
. -
timeout
numberHow long (in milliseconds) to wait for the HelloSign app to initialize before aborting.
Default:
30000
(30 seconds) -
whiteLabeling
ObjectAn object used to customize the signer experience for premium users with white-labeling capabilities. White labeling options can be found here.
-
allowViewportOverride
booleanHistory
Version Changes v2.11.0 Added. Allows HelloSign Embedded to override the viewport meta tag, if there is one, to improve behavior on small screens.
Default:
false
Having trouble? Let us know!
Welcome!
Below you will find links to the API documentation, frequently asked questions, and other useful tidbits.
Find something incorrect or missing? Shoot us an email or create an issue.
Having trouble? Let us know!