Adding PDF annotations to existing template
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'
Follow the Generating PDF annotations procedure to fetch the list of PDF annotations.
Add the
annotations
key with the list of JSON objects containing PDF annotations:Define a variable named
template_data
, and then assign an object containing the list of annotations to this variable:>>> template_data = { ... 'annotations': [ ... '{"bbox":[129.81423950195312,216.01904296875,200,50], ...}', ... '{"bbox":[186.60797119140625,409.7261962890625,200,50], ...}' ... ] ... }
Convert the
template_data
object to a JSON text:>>> template_data = json.dumps(template_data, indent=4) >>> print(template_data) { "annotations": [ "{\"bbox\":[129.81423950195312,216.01904296875,200,50], ...}", "{\"bbox\":[186.60797119140625,409.7261962890625,200,50], ...}" ] }
Send a POST request with the JSON text to the
/templates/{template_id}/annotations
endpoint:>>> response = requests.post( ... f'{base_url}/templates/{template_id}/annotations', ... 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 updated the PDF annotations of the e-sign document template.
A different status code means that an error has occurred. For the details, refer to “Status and error codes”.