Checking the status of signing process

  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. Define a variable named doc_id, and then assign the ID of the e-sign document to this variable:

    >>> doc_id = '8592b052a9979f8d651618092bb3ac8472beebc66d52ab980deb4d320e26b0cb'
    
  3. Fetch the e-sign document by sending a GET request to the /documents/{doc_id} endpoint:

    >>> response = requests.get(f'{base_url}/documents/{doc_id}', headers=auth)
    
  4. 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 document key containing the details about the e-sign document formatted as a JSON text. When converted to an object, it will look as follows:

    >>> pprint.pprint(response.json())
    {'document': {'certificate_id': 'bbcf753ad4fef97a224ac1ead13f6938286665885ae0fae85a96949d970d6aea',
                  'id': '8592b052a9979f8d651618092bb3ac8472beebc66d52ab980deb4d320e26b0cb',
                  'notarization_certificate_link': '/certificate/bbcf753ad4fef97a224ac1ead13f6938286665885ae0fae85a96949d970d6aea',
                  'phase': 3,
                  'signature_certificate_link': '/doc/8592b052a9979f8d651618092bb3ac8472beebc66d52ab980deb4d320e26b0cb/download',
                  'signed_at': '2018-09-20T14:54:14.110023Z',
                  'esign': {'embedded': False}
                  'signees': [{'email': 'john.smith@example.com',
                               'fullname': 'John Smith',
                               'id': '44a8d431-9e08-4b56-aff2-b40ffab9bc29',
                               'owner': False,
                               'signed_at': '2018-09-20T14:48:56.903307Z'},
                              {'email': 'john.doe@example.com',
                               'fullname': 'John Doe',
                               'id': 'd57f9fb4-53f2-41dd-8b76-38a29c8a288f',
                               'owner': True,
                               'signed_at': '2018-09-20T14:54:14.110023Z'}]}}
    
  5. Convert the JSON text that the response body contains to an object, and then fetch the value of the phase key from the certificate:

    >>> document = response.json()['document']
    >>> phase = document['phase']
    >>> phase
    3
    

    The following table describes the possible values of the phase key:

    Phase value

    description

    1

    The e-sign document is created.

    2

    The signees are invited to review and sign the file and the signing is in process. The signed_at value of the e-sign document will be None and the certificate_id value will be an empty string. You may see who has signed the file by fetching the signed_at value from each signee object in the signees list of the e-sign document. If a signee has signed the file, this value will be the date and time of the signature. Otherwise, the value will be None.

    5

    This phase is used only when the signatures are embedded into PDF. The signed PDF file with embedded signatures is generated.

    4

    This phase is used only when the signatures are embedded into PDF. The signature certificate file is generated and notarization of the signature certificate file and signed PDF file has started.

    3

    The signing process is complete, the signature certificate file is generated, and its notarization has started. The signed_at value will be the date and time of the last signature and the certificate_id value will be the ID of the notarization certificate created for the generated file.

    You may download the generated file by clicking Signature certificate on the e-sign document web page available at https://eu2-cloud.acronis.com/notary/doc/{doc_id}, where {doc_id} is the value of document['id']. You can also use signature certificate download link provided in the e-sign document as shown in the following example:

    >>> download_link = f'{base_url}{document["signature_certificate_link"]}'
    >>> download_link
    'https://eu2-cloud.acronis.com/api/notary/v2/doc/8592b052a9979f8d651618092bb3ac8472beebc66d52ab980deb4d320e26b0cb/download'
    
  6. [Optional] If a signee has not received the email message with the signature request or does not answer it, you may resend the signature request to this signee. See Resending signature request.

  7. Once the file is signed by all the signees, fetch the ID of the notarization certificate created for the signature certificate file:

    >>> certificate_id = document['certificate_id']
    >>> certificate_id
    'bbcf753ad4fef97a224ac1ead13f6938286665885ae0fae85a96949d970d6aea'
    
  8. Check the notarization status of the signature certificate file by sending a GET request to the /certificates/{certificate_id} endpoint. We recommend waiting about an hour before checking because the notarization process may take a long time:

    >>> response = requests.get(f'{base_url}/certificates/{certificate_id}', headers=auth)
    
  9. 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 notarization certificate object formatted as a JSON text. When converted to an object, it will look as follows:

    >>> pprint.pprint(response.json())
    {'contract': '0xd10e3Be2bc8f959Bc8C41CF65F60dE721cF89ADF',
     'eventtime': '2019-11-11T13:54:47.280686Z',
     'id': 'bbcf753ad4fef97a224ac1ead13f6938286665885ae0fae85a96949d970d6aea',
     'merkle_proof': '[{"right":"8e561ef25e227da2e58af0866f90f31652ad409a9042bfbdf6355fe2cb44f84b"}]',
     'merkle_root': '538bc78f39eb3d4b0f1ee1f5f2930f64662eb1a0e9fb366bd513a9d8ed39facc',
     'notarized_location': 'beta-baas',
     'object': {'eTag': '1e71c51ee871596a8614166626c0688c45247992f3899c2806fd747edb036d2a',
                'key': '<file name>_signature_certificate_2019_11_11T13_54_47.pdf',
                'sequencer': '8956e14840f279560b',
                'size': 150147},
     'blockchain': 'eth',
     'qr_code': 'data:image/png;base64,iVBORw0KGgoAAAAN...',
     'sender': '0x201354729f8d0f8b64e9a0c353c672c6a66b3857',
     'signee_details': {'tenant_name': 'JohnCustomer'},
     'timestamp': 1573572409,
     'txid': '0x8bf9f79be325047f5b5997184f40c5676f9dccda4f45f180f68bd16aeb5f3267',
     'version': '2'}
    

    If the notarization is complete:

    • The txid key contains the hash of the blockchain transaction that can be viewed on https://etherscan.io/tx/{txid}.

    • The contract, sender, merkle_root, and merkle_proof keys contain the blockchain transaction details.

    • The timestamp key contains the Unix time when the hash value of the file contents was written to the blockchain (notarization completion time).

    • The eTag key of the object object contains the actual hash value that was written to the blockchain.

    • The web version of the notarization certificate is available at https://eu2-cloud.acronis.com/notary/certificate/{certificate_id}.

    Empty txid, contract, merkle_proof, merkle_root, and sender keys mean that the notarization is still in progress and the web version of the certificate is not created yet.

Full code example

 1#!/usr/bin/env python3
 2
 3import requests  # Will be used for sending requests to the API.
 4import hashlib   # Will be used for calculating hash values.
 5import os.path   # Will be used for path-related operations.
 6import pprint    # Will be used for formatting the output of JSON objects received in API responses.
 7import json      # Will be used for converting dictionaries into JSON text
 8
 9# Define variables named "LOGIN" and "PASSWORD" and then assign them with your account credentials
10LOGIN = '<your login>'        # Change login here
11PASSWORD = '<your password>'  # Change password here
12
13# Define a variable named "cloud_url" and then assign it with the URL of the cloud platform
14cloud_url = 'https://cloud.acronis.com'
15
16# Fetch the URL of the data center where your account is located by sending a GET request to the "/api/1/accounts" endpoint
17response = requests.get(
18    f'{cloud_url}/api/1/accounts',
19    params={'login': LOGIN}
20)
21response.raise_for_status()
22
23# Convert the JSON text that the response body contains to a dictionary and store the data center URL
24# in a variable that will be used in further requests
25server_url = response.json()['server_url']
26
27# Define a variable named "account_creds", and then assign the username and password to this variable
28account_creds = {
29    'username': LOGIN,
30    'password': PASSWORD
31}
32
33# Generate a token by sending a POST request to the "/api/2/idp/token" with your account credentials to the cloud platform
34response = requests.post(
35    f'{server_url}/api/2/idp/token',
36    headers={'Content-Type': 'application/x-www-form-urlencoded'},
37    data={'grant_type': 'password', **account_creds}
38)
39response.raise_for_status()
40
41# Convert the JSON text that the response body contains to a dictionary and then assign it to a variable named "token_info"
42token_info = response.json()
43
44# Define a variable named "auth" and then assign it with a dictionary with "Authorization" key containing
45# token string formatted as "Bearer <access_token>"
46auth = {
47    'Authorization': 'Bearer ' + token_info['access_token']
48}
49
50# Define a variable named "base_url", and then assign the API base URL using the data center URL
51# to this variable
52base_url = f'{server_url}/api/notary/v2'
53
54# Define a variable named "doc_id" and assign it with the e-sign document ID
55doc_id = '8592b052a9979f8d651618092bb3ac8472beebc66d52ab980deb4d320e26b0cb'
56
57# Fetch the information about the e-sign document by sending a GET request to the "/documents/{doc_id}" endpoint
58response = requests.get(f'{base_url}/documents/{doc_id}', headers=auth)
59response.raise_for_status()
60
61# Convert the JSON text that the response body contains to a dictionary and fetch the e-sign document dictionary
62document = response.json()['document']
63
64# Define a variable named "phase" and then assign it with the value of the 'phase' key of the e-sign document dictionary
65phase = document['phase']
66
67# Print the value of the current e-sign document phase
68print(phase)