create-a-widget

Widgets are hosted documents that can be signed by anyone who has access to them. They are ideal for signup sheets, waivers, or any document you need many people to access and sign online.

You can quickly create a Widget from a transient document as shown in the following example.

Before you begin, ensure that you have included the appropriate JavaScript files as shown below:

<script src="js/adobe-sign-sdk.js"></script>
<script src="vendor/superagent.min.js"></script>
<script src="vendor/validator.min.js"></script>
//Get the context
var context = new AdobeSignSdk.Context();

//Initialize the Widget API        
var widgetsApi = new AdobeSignSdk.WidgetsApi(context);        

//Get the Widget model        
var widgetsModel = AdobeSignSdk.WidgetsModel;        

//Populate the access token
var headerParams = {"accessToken": "3AAANOTTHEREALTOKENbGQm9WNai"};        

//Start creating the widget
var widgetCreationInfo = new widgetsModel.WidgetCreationInfo();

//Set the document ID
var fileInfo = new widgetsModel.WidgetFileInfo();
fileInfo.setTransientDocumentId("3AAljRNOTTHEREALID9GoAOxiK");        

var fileInfoList = [];        
fileInfoList.push(fileInfo);       

//Populate the widget creation details
widgetCreationInfo.setName("MyAgreement");        
widgetCreationInfo.setFileInfos(fileInfoList);
widgetCreationInfo.setSignatureFlow("SENDER_SIGNATURE_NOT_REQUIRED");        

var widgetCreationRequest = new widgetsModel.WidgetCreationRequest();        
widgetCreationRequest.setWidgetCreationInfo(widgetCreationInfo);        

widgetsApi.createWidget(headerParams, widgetCreationRequest)                
          .then(function (widgetCreationResponse) {                    
                console.log(widgetCreationResponse.getWidgetId());                
           })               
           .catch(function (apiError) {                   
                 console.log(apiError);               
           });