Creating an e-sign document from template
Important
A POST request to the /templates/{template_id}/documents
endpoint will fail
if the account has exceeded the Document templates quota.
Start the Python shell and configure its session.
The following variables should be available now:
>>> base_url # the base URL of the API 'https://eu2-cloud.acronis.com/api/notary/v2' >>> auth # the 'Authorization' header value with the access token {'Authorization': 'Bearer 8770b34b74f9e4d9424eff50c38182bb4ae7f5596582ae61900b1b6a23e3ec58'}
Define a variable named
template_id
, and then assign an ID of the e-sign document template to this variable:>>> template_id = '3922edc2-d70d-4d5d-9789-5d739a6e7bdc'
Define a variable named
template_data
, and then assign an object with the name that will be used for the created e-sign document to this variable:>>> template_data = { ... 'document_name': 'template_name' ... }
Pre-fill the document template fields with placeholders. The emails provided in the placeholders will be used for sending the invites to the signees:
>>> template_data['template_fields'] = { ... 'Signer 1': {'signee':'john.doe@acronis.com'}, ... 'Signer 2': {'signee':'john2.doe@acronis.com'} ... }
Convert the
template_data
object to a JSON text:>>> template_data = json.dumps(template_data, indent=4) >>> print(template_data) { "document_name": "template_name", "template_fields": { "Signer 1": {"signee":"john.doe@acronis.com"}, "Signer 2": {"signee":"john2.doe@acronis.com"} } }
Send a POST request to the
/templates/{template_id}/documents
endpoint:>>> response = requests.post( ... f'{base_url}/templates/{template_id}/documents', ... headers={'Content-Type': 'application/json', **auth}, ... data=template_data, ... )
Check the status code of the response:
>>> response.status_code 200
Status code 200 means that the notary service has created the e-sign document from template, initiated the signing and sent email messages with the signature request to the signees. To check the signing status, refer to Checking the status of signing process.
A different status code means that an error has occurred. For the details, refer to “Status and error codes”.
Also, the response body contains an object containing the document ID and the list of signees formatted as a JSON text. When converted to an object, it will look as follows:
>>> pprint.pprint(response.json()) {'document_id': '2e6b838c7fb3c98d86f841661a56505e15a54b92de568f4b0417605062564256', 'signers': [{'email': 'john.doe@acronis.com', 'fullname': '', 'id': 'a011a73c-3798-4de4-98fe-c1cac06c4b7e', 'owner': False, 'signed_at': None}, {'email': 'john2.doe@acronis.com', 'fullname': '', 'id': 'a011a73c-3798-4de4-98fe-c1cac06c4b7e', 'owner': False, 'signed_at': None}]}