Using drafts to prepare envelopes

Before you start with this guide please also have a look at the API-Documentation and the Postman-Guide.

The Story 

You only want to prepare a document for the time being, but send it or have it signed later? This page explains in detail how you can create a draft via API and how you can then send this draft. The advantage you have by creating a draft compared to creating an envelope:
You can prepare the document completely and send it to your recipients at any time. Therefore, you have already prepared everything at the time of sending the draft.

Use Case Description

Using Drafts Overview


The following steps are necessary to send a draft:

  • Prepare a draft
  • Send the draft

This case guides you through the process of creating and sending a draft via API and UI.

Integration

All following API calls need an authorization. For information of how to authorize please see the Postman-Guide.

Note the following regarding AgentRedirectConfiguration:

  •  Draft/create
    • If Allow flag is set to false, Policy and IFrameAllowList should be null
  • Draft/Update
    • If Allow flag is set to false,
      • Policy and IFrameAllowList should be null
      • If it is valid, then Policy and IFrameAllowList are reset to default
"AgentRedirectConfiguration": {
    "Policy": "Workflow",
    "Allow": false,
    "IFrameAllowList": []
  }

RedirectPolicy values:

  • "Workflow" → redirects to the create envelope page
  • "FormEditor" → redirects to the designer page
  • "Summary" → redirects to the envelope summary page

Creating a draft

It is allowed to define placeholders on a template, create a draft still with unresolved placeholders using the POST v6/template/createdraft method and retrieve placeholder information from the draft using GET /v6/draft/{id}. Placeholders need to be replaced before sending the draft.

First step is to create a draft. To create one you have to run the following API call:

https://demo.esignanywhere.net/Api/v6.0/draft/create

Please note: The following configuration includes one recipient who has to sign one ClickToSign:

{
    "Documents": [{
            "FileId": "19b7a4b4-1234-1234-1234-daa50efde453",
            "DocumentNumber": 1
        }
    ],
    "Name": "DraftCreate",
    "Activities": [{
            "Action": {
                "Sign": {
                    "RecipientConfiguration": {
                        "ContactInformation": {
                            "Email": "janedoe@sample.com",
                            "GivenName": "Jane",
                            "Surname": "Doe",
                            "LanguageCode": "EN",
                            "PhoneNumber":"+123456789"
                        }
                    },
                    
                    "Elements": {
                        "Signatures": [{
                                "TaskConfiguration": {
                                    "OrderDefinition": {
                                        "OrderIndex": 0
                                    }
                                },
                                "ElementId": "sample sig ClickToSign",
                                "Required": true,
                                "DocumentNumber": 1,
                                "DisplayName": "Sign here",
                                "AllowedSignatureTypes": {
                                    "ClickToSign": {
                                    }
                                },
                                "FieldDefinition": {
                                    "Position": {
                                        "PageNumber": 1,
                                        "X": 100,
                                        "Y": 200
                                    },
                                    "Size": {
                                        "Width": 100,
                                        "Height": 70
                                    }
                                }
                            }
                        ]
                    },
                    "SigningGroup": "firstSigner"
                }
            }
        }
    ]
}

Please note that it is possible to add a default signature type for the draft (only one signature type is allowed to be set to default). See the next configuration (also available for the update craft call):

{
    "Documents": [{
            "FileId": "075f6443-9d96-43d4-9c41-6957fafa44d1",
            "DocumentNumber": 1
        }
    ],
    "Name": "DraftCreate",
    "Activities": [{
            "Action": {
                "Sign": {
                    "RecipientConfiguration": {
                        "ContactInformation": {
                            "Email": "jane.doe@sample.com",
                            "GivenName": "Jane",
                            "Surname": "Doe",
                            "LanguageCode": "EN",
                            "PhoneNumber":"+123456789"
                        }
                    },
                     
                    "Elements": {
                        "Signatures": [{
                                "TaskConfiguration": {
                                    "OrderDefinition": {
                                        "OrderIndex": 0
                                    }
                                },
                                "ElementId": "sample sig ClickToSign",
                                "Required": true,
                                "DocumentNumber": 1,
                                "DisplayName": "Sign here",
                                "AllowedSignatureTypes": {
                                    "ClickToSign": {
                                        
                                    },
                                     "DrawToSign": {
                                       
                                    }
                                },
                                "FieldDefinition": {
                                    "Position": {
                                        "PageNumber": 1,
                                        "X": 100,
                                        "Y": 200
                                    },
                                    "Size": {
                                        "Width": 100,
                                        "Height": 70
                                    }
                                }
                            }
                               
                        ]
                    },
                     
                    "SigningGroup": "firstSigner"
                }
               
            }
        }
        
    ],
    "DefaultSignatureTypeConfiguration": {
    "ClickToSign": {
      "IsDefault": false
    },
    "DrawToSign": {
      "IsDefault": true
    },
    "TypeToSign": {
      "IsDefault": false
    },
    "LocalCertificate": {
      "IsDefault": false
    },
    "DisposableCertificate": {
      "IsDefault": false
    },
    "Biometric": {
      "IsDefault": false
    },
    "RemoteCertificate": {
      "IsDefault": false
    },
    "OneTimePassword": {
      "IsDefault": false
    }
                     }
}

After successfully creating the draft you get the draft id. We will need this id to send the draft as well as we need it for the GET call to receive the data of the draft.

If the create call was successful you can also see this draft in the UI like it is show in the next figure:

Created Draft

Get data of the draft

To get the data of the draft you need to run the following API call:

https://demo.esignanywhere.net/Api/v6.0/draft/{draftid}

Therefore, just replace {draftid} with your draft id and run the call. After a successful API call you should get the data of the draft like the following one:

{
    "Id": "3a086823-1234-1234-1234-6af6235b528b",
    "Name": "DraftCreate",
    "Activities": [
        {
            "Id": "12f67be4-1234-1234-1234-3907f818b2ec",
            "Action": {
                "Sign": {
                    "SigningGroup": 1,
                    "ContactInformation": {
                        "Email": "janedoe@sample.com",
                        "GivenName": "Jane",
                        "Surname": "Doe",
                        "PhoneNumber": "+123456789",
                        "LanguageCode": "EN"
                    }
                }
            }
        }
    ]
}

Update a draft

Even if only an empty string for e.g. "Name" is entered, the value of the draft will be adjusted. Therefore, after the update call the draft name would be "". If you do not want certain data from the draft to be changed by the update call, then do not include the value in the json structure. This keeps the value of the draft before updating it and only those declared in the json are changed.

You can change the already created draft with the update API call. For this call you have to run the following URI:

https://demo.esignanywhere.net/Api/v6.0/draft/update

The POST body contains the data of the draft to update (i.e.: the updated draft configuration). A complete configuration contains:

{
  "DraftId": "string",
  "Name": "string",
  "MetaData": "string",
  "AddDocumentTimestamp": true,
  "ShareWithTeam": true,
  "LockFormFieldsOnFinish": true,
  "SendFinishedDocumentsToAllSignersAndMustView": true,
  "EmailConfiguration": {
    "Subject": "string",
    "Message": "string",
    "SenderDisplayName": "string"
  },
  "ReminderConfiguration": {
    "Enabled": true,
    "FirstReminderInDays": 0,
    "ReminderResendIntervalInDays": 0,
    "BeforeExpirationInDays": 0
  },
  "ExpirationConfiguration": {
    "ExpirationInSecondsAfterSending": 0,
    "ExpirationDate": "2023-04-18T08:26:00.440Z"
  },
  "CallbackConfiguration": {
    "CallbackUrl": "string",
    "StatusUpdateCallbackUrl": "string",
    "AfterSendCallbackUrl": "string",
    "ActivityActionCallbackConfiguration": {
      "Url": "string",
      "ActionCallbackSelection": {
        "ConfirmTransactionCode": true,
        "AgreementAccepted": true,
        "AgreementRejected": true,
        "PrepareAuthenticationSuccess": true,
        "AuthenticationFailed": true,
        "AuthenticationSuccess": true,
        "AuditTrailRequested": true,
        "AuditTrailXmlRequested": true,
        "CalledPage": true,
        "DocumentDownloaded": true,
        "FlattenedDocumentDownloaded": true,
        "AddedAnnotation": true,
        "AddedAttachment": true,
        "AppendedDocument": true,
        "FormsFilled": true,
        "ConfirmReading": true,
        "SendTransactionCode": true,
        "PrepareSignWorkstepDocument": true,
        "SignWorkstepDocument": true,
        "UndoAction": true,
        "WorkstepCreated": true,
        "WorkstepFinished": true,
        "WorkstepRejected": true,
        "DisablePolicyAndValidityChecks": true,
        "EnablePolicyAndValidityChecks": true,
        "AppendFileToWorkstep": true,
        "AppendTasksToWorkstep": true,
        "SetOptionalDocumentState": true,
        "PreparePayloadForBatch": true
      }
    }
  },
  "AgentRedirectConfiguration": {
    "Policy": "Workflow",
    "Allow": true,
    "IFrameAllowList": [
      "string"
    ]
  },
  "AgreementConfiguration": {
    "Translations": [
      {
        "LanguageCode": "AF",
        "Text": "string",
        "Header": "string",
        "IsDefault": true
      }
    ]
  },
  "RedirectConfiguration": {
    "AfterSendRedirectUrl": "string",
    "BeforeSendRedirectUrl": "string"
  },
  "DefaultSignatureTypeConfiguration": {
    "ClickToSign": {
      "IsDefault": true
    },
    "DrawToSign": {
      "IsDefault": false
    },
    "TypeToSign": {
      "IsDefault": false
    },
    "LocalCertificate": {
      "IsDefault": false
    },
    "DisposableCertificate": {
      "IsDefault": false
    },
    "Biometric": {
      "IsDefault": false
    },
    "RemoteCertificate": {
      "IsDefault": false
    },
    "OneTimePassword": {
      "IsDefault": false
    }
  }
}

Sending a draft

To send the draft you need to run the following API call:

https://demo.esignanywhere.net/Api/v6.0/draft/send

Add the draftId and send the envelope:

{
  "DraftId": "string"
}

After a successful sending of the draft, the recipients will get the envelope.