Fetching the templates of e-sign documents

  1. 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'}
    
  2. Send a GET request to the /templates endpoint:

    >>> response = requests.get(f'{base_url}/templates', headers=auth)
    
  3. Check the status code of the response:

    >>> response.status_code
    200
    

    Status code 200 means that the request was successful.

    A different status code means that an error has occurred. For the details, refer to “Status and error codes”.

    Also, the response body contains the templates key containing an array of e-sign document templates formatted as a JSON text. When converted to an object, it will look as follows:

    >>> pprint.pprint(response.json())
    {'paging': {'cursors': {}},
    'templates': [{'created_at': '2021-04-15T07:09:22.426923Z',
                    'document_count': 0,
                    'file_id': '0a67df08-56a5-4a9a-96ce-fa2d91e87ae1',
                    'file_name': 'file_name.pdf',
                    'id': '84c8eab4-59b9-4873-bc44-92615c2f7713',
                    'name': 'template_name',
                    'updated_at': '2021-04-15T07:09:22.426923Z'},
                {'created_at': '2021-04-15T07:09:29.148799Z',
                    'document_count': 0,
                    'file_id': '99fb3a13-2545-4dd0-bb67-5c5b19c77b9e',
                    'file_name': 'file_name.pdf',
                    'id': '3922edc2-d70d-4d5d-9789-5d739a6e7bdc',
                    'name': 'template_name',
                    'updated_at': '2021-04-15T07:09:29.148799Z'}]}
    
  4. Convert the JSON text, that the response body contains, to an object, and then fetch the list of e-sign documents’ templates from the response:

    >>> document_templates = response.json()['templates']
    

Full code example