Embedded Templates

Embedded templates allow your users to create and edit templates on your site in an iFrame. Templates are used to share frequently-used documents and send them for signatures.

Preliminary

Before you start doing anything, make sure the following steps have been done:

1. Create an account if you don't already have one and retrieve your API key from the settings page. You must have a Silver or Gold plan to use Embedded Signing in production mode. Otherwise, you can only use it in test mode.

2. Create an API app (login required)

NOTE: The API app domain name specifies where the iFrame can be opened. Embedded Signing will only be possible on pages from this domain and its subdomains.
Creating a template

Allowing your site users to create a template involves first creating a template draft. This draft will be displayed on your site in an embedded iFrame, allowing the user to edit and finalize the template. Note that templates created via the embedded template process will only be accessible through the API.

1. Create a template draft by POSTing an API request to https://api.hellosign.com/v3/template/create_embedded_draft with the following parameters:

2. Retrieve the edit_url from the API response, which will be a JSON object like the one below. Be sure to also store the 'template_id' for future referencing of the completed template. skip_signer_roles=1 is an optional parameter you can append which will not allow the person editing the template to add or change the signer roles that have already been defined.

{
  "template" : {
    "template_id" : "abcdef1234567890abcdef1234567890",
    "edit_url" : "https://app.hellosign.com/editor/...",
    "expires_at" : "123456790"
  }
}

3. Render the page for the user. This page should include HelloSign's embedded.js file, which gives the page access to the HelloSign.open() javascript function. During page rendering, output a call to this function and provide the edit URL and your client ID like so:

HelloSign.init('YOUR_CLIENT_ID'); 
HelloSign.open({ url: 'EDIT_URL_RECEIVED_FROM_API_REQUEST' });

4. The embedded iFrame will be displayed and the user will be walked through the process of editing and finalizing the template for future use.

5. An optional message listener function can be provided to the HelloSign.open() function that will allow you to handle events from the embedded iFrame, including cancellation and success. This is useful for managing the state of templates on your back end. For example:

HelloSign.open({
    url: "",
    messageListener: function(eventData) {
        l("Got message data: " + JSON.stringify(eventData));
        if (eventData.event == HelloSign.EVENT_TEMPLATE_CREATED) {
          // template created
        } else if (eventData.event === HelloSign.EVENT_CANCELED) {
          // template cancelled
        }
    }
});
Pre-defined merge fields

By creating a template draft with merge fields, you are essentially telling your users, "The app can supply this information for you when you use the completed template to send a signature request."

This can be useful if, for example, your app stores contact information. If a user sends a signature request to one of the contacts in your system, you can pre-populate the signature request with contact details prior to sending. It's necessary to provide these details as 'merge fields' during the template creation because it indicates where the data should be placed within the document when sending the signature request.

As explained in the Creating a template section, merge fields are specified during the template draft creation API request as a JSON array. Each merge field must have a unique name, and this is enforced by the API.

When the user is presented with the template draft editor, they are allowed to place these merge fields in the document. Merge fields appear to the user as standard Textbox and Checkbox fields. When one of these fields is placed on the document, the context menu will display the app as an option for the data source (in the "Who fills this out?" dropdown list), and the names of any pre-defined merge fields are listed in the dropdown underneath "What text goes here?".

Once the template is saved, the data to populate these merge fields can be specified in the API call to create a signature request. This not only saves the user time, but also ensures better data accuracy. To populate the merge fields, simply execute a /signature_request/send_with_template and use the custom_fields parameter, or supply the same parameter when creating an embedded draft for previewing (see Previewing a signature request below).

Editing a template

Once a template has been created, you can also open an embedded iFrame that allows your site users to edit it. Note that only templates created via the embedded template process are available to be edited with this endpoint.

1. Make a GET or POST request to https://api.hellosign.com/v3/embedded/edit_url/[:template_id]. A POST request is required if merge_fields or cc_roles are being changed.

2. merge_fields is an optional parameter which can be supplied here to edit which available fields the user editing the template has access to place. Fields already placed on the document will not be removed, but will default to empty if no custom field is supplied for them.
cc_roles is an optional parameter that can also be supplied to update the CC roles for the template.

skip_signer_roles=1 is an optional parameter you can append which will not allow the person editing the template to add or change the signer roles that have already been defined.
skip_subject_message=1 is an optional parameter you can append which will not allow the person editing the template to change the subject and/or message which has already been provided.

3. Retrieve the edit_url from the API response, which will be a JSON object like the one below. This URL will be used in the same manner as the edit_url retrieved for the template draft creation.

{
  "embedded" : {
    "edit_url" : "https://app.hellosign.com/editor/...",
    "expires_at" : "123456790"
  }
}

4. Render the page for the user. This page should include HelloSign's embedded.js file, which gives the page access to the HelloSign.open() javascript function. During page rendering, output a call to this function and provide the edit URL and your client ID like so:

HelloSign.init('YOUR_CLIENT_ID'); 
HelloSign.open({ url: 'EDIT_URL_RECEIVED_FROM_API_REQUEST' });

5. The embedded iFrame will be displayed and the user will be walked through the process of editing and finalizing the template.

Previewing a signature request

When your site user needs to send a signature request based on a template, you will need to create an embedded signature request draft. This draft can be opened in an embedded iFrame to allow the user to preview the request prior to sending. Creating the signature request draft for previewing is also a perfect opportunity to populate any pre-defined merge fields that might have been added by the user during the template creation process.

1. Create the embedded template draft by making a POST request to https://api.hellosign.com/v3/unclaimed_draft/create_embedded_with_template with the following parameters:

2. Retrieve the claim_url from the API response, which will be a JSON object like the one below. This URL will be used in the same manner as the edit_url for template creation and editing to display the preview to the user.

{
  "unclaimed_draft": {
    "claim_url": "https://app.hellosign.com/editor/embeddedRequest?cached_params_token=2f42ca09a50345af9ef8720f5b001f27",
    "signing_redirect_url": null,
    "test_mode": true,
    "signature_request_id": "340e9843ac552b5170ee9c374d67e312f53ca129",
    "requesting_redirect_url": null
  }
}

3. Render the page for the user. This page should include HelloSign's embedded.js file, which gives the page access to the HelloSign.open() javascript function. During page rendering, output a call to this function and provide the edit URL and your client ID like so:

HelloSign.init('YOUR_CLIENT_ID'); 
HelloSign.open({ url: 'EDIT_URL_RECEIVED_FROM_API_REQUEST' });

4. The embedded iFrame will be displayed and the user will be given an opportunity to preview and make edits to the signature request prior to sending. Any custom_fields parameters supplied to the draft creation API request will be added to the document as well and these fields can also be edited and moved by the user. The user can then send the signature request by clicking "Continue".

What is the App Approval Process for Embedded Flows

In order to ensure that your integration adheres to eSignature regulations and best practices, we require a quick app review.

NOTE You will still be able to use your app in test mode until it gets approved. Only live/production activity requires approval.

1. Review our user identification requirements before adding Embedded Workflows into your website:

  • - User Profiles:
    If your platform has a user profile, your users must be authenticated on your website before they may create templates, sign documents, or request signatures.
    We also require that your users have previously confirmed ownership of the email address used to identify them to HelloSign. In practice, verifying email ownership means that when a user signs up for an account on your website, they should receive an email containing a unique link back to your site. When followed, your application can record the action, thus verifying the user's ownership of the email address. It is also important to recheck a user’s email if it’s allowed to be changed.
  • - Applications that do not have a user profile:
    If your application does not have a user profile concept, typically unique links are sent to the signer’s email address directly. The email usually includes a URL with a token that’s tied to the signer and signature request. When the signer clicks the link in the email, your app records the action, thus verifying the signer’s identity.
  • - In-Person signing:
    In-Person signing is a way of verifying your signer’s identity and allowing them to sign in person. We recommend creating a documented process such as uploading a picture of a driver's license or documenting a driver license number along with the signed document.
  • - If your workflow doesn’t fit, contact us and we will talk through it...

2. Email us at apisupport@hellosign.com to schedule an app review once your integration is complete and ready for production use.

3. Demonstrate your completed integration via screenshare (using a Google Hangout or Skype) by walking us through user account creation, email confirmation, and/or login on your website. We will also review your HelloSign integration as a whole to ensure proper functionality/to answer any questions that you may have. A review typically takes less than 30 minutes.

That's it! We’ll immediately approve your app (or make suggestions) after the review.

Additional notes
Domain restriction

When the iFrame is loaded, it will verify the domain of the parent window and ensure it matches the domain name of the API App specified by the client ID. If the domain does not match, the page won't be loaded.

You can disable domain restriction for easeier development:

HelloSign.open({
  ...
  skipDomainVerification: true,
  ...
});

See the documentation for HelloSign.open() for more information.

HTTPS Required

The host page must be served over HTTPS. The HelloSign iFrame is also loaded over HTTPS, and due to browser security restrictions it will not be able to communicate with the parent window if it is not HTTPS. This communication is required to enable features such as iFrame callbacks and closing the iFrame.

To make development easier, the page will still load if the parent window is served over HTTP, however an alert will be displayed to notify you of this requirement. Switch to HTTPS to prevent this alert from being displayed.

Redirection

If a redirect url is specified, the iFrame will redirect users to it after they sign or decline to sign. Data from the EVENT_SIGNED event will be appended to the url query string.

Signature links

Signature URLs are only valid for 60 minutes after embedded/sign_url has been called and expire as soon as they're accessed.

Text Tags

The embedded functionality can be used in conjunction with HelloSign Text Tags.

Events

Here is the detail of all possible events the iFrame could send to the opening window:

Event Description Data fields
HelloSign.EVENT_TEMPLATE_CREATED The user has successfully created the template.
template_id
template_info
  • title
  • message
  • signer_roles
  • cc_roles
HelloSign.EVENT_CANCELED The user has canceled before the document was signed. None
HelloSign.EVENT_ERROR An error occurred and the document could not be signed. description