Resending signature request

Note

If you are signing the file by the permanent link and already have the ID of the document, skip steps 2-5.

  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 file_id, and then assign the ID of signed file to this variable:

    >>> file_id = 'aa95bac7-33fd-4faa-9fa1-f4baeaca82cd'
    
  3. Fetch the details about the file by sending a GET request to the /stored-files/{file_id} endpoint:

    >>> response = requests.get(f'{base_url}/stored-files/{file_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 file key containing the details about the file formatted as a JSON text. When converted to an object, it will look as follows:

    >>> pprint.pprint(response.json())
    {'file': {..., 'document': {...},
              'document_id': '8592b052a9979f8d651618092bb3ac8472beebc66d52ab980deb4d320e26b0cb'}}
    
  5. Convert the JSON text that the response body contains to an object, and then fetch the ID of the document:

    >>> doc_id = response.json()['file']['document_id']
    >>> doc_id
    '8592b052a9979f8d651618092bb3ac8472beebc66d52ab980deb4d320e26b0cb'
    
  6. Fetch the document by sending a GET request to the /documents/{doc_id} endpoint:

    >>> response = requests.get(f'{base_url}/documents/{doc_id}', headers=auth)
    
  7. 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 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',
                  'phase': 2,
                  'signed_at': '2018-09-20T14:54:14.110023Z',
                  'signature_certificate_link': '/doc/8592b052a9979f8d651618092bb3ac8472beebc66d52ab980deb4d320e26b0cb/download',
                  'notarization_certificate_link': '/certificate/bbcf753ad4fef97a224ac1ead13f6938286665885ae0fae85a96949d970d6aea',
                  'signees': [{'email': 'john.smith@example.com',
                               'fullname': 'John Smith',
                               'id': '44a8d431-9e08-4b56-aff2-b40ffab9bc29',
                               'owner': False,
                               'signed_at': ''},
                              {'email': 'john.doe@example.com',
                               'fullname': 'John Doe',
                               'id': '867139bf-30ca-4c83-8683-a30c5db57046',
                               'owner': True,
                               'signed_at': '2019-11-11T13:54:38.619811Z'},
                               {'email': 'foobar@othercompany.com',
                               'fullname': 'Foo Bar',
                               'id': '32ff6407-605c-4203-a611-34deb036cda4',
                               'owner': False,
                               'signed_at': null}]},
                  'document_id': '8eb2c5179b84a1b97a4f69eb0e97b4e910a1eace1b781926f83ee964f12e6922',
                  ...}}
    
  8. Fetch the list of signees from the document:

    >>> signees = response.json()['document']['signees']
    
  9. Find the signee by his email and fetch the ID of the signee:

    >>> signee_id = None
    >>> for signee in signees:
    ...     if signee['email'] == 'john.smith@example.com':
    ...         signee_id = signee['id']
    ...         break
    >>> signee_id
    '44a8d431-9e08-4b56-aff2-b40ffab9bc29'
    
  10. Resend the email to the signee by sending a POST request to the /documents/{doc_id}/signees/{signee_id}/resend endpoint:

    >>> response = requests.post(f'{base_url}/documents/{doc_id}/signees/{signee_id}/resend', headers=auth)
    
  11. Check the status code of the response:

    >>> response.status_code
    200
    

    Status code 200 means that the email has been resent to the signee.

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

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 "file_id" and then assign it with the ID of the file
55file_id = 'aa95bac7-33fd-4faa-9fa1-f4baeaca82cd'
56
57# Fetch the information about the file in notary storage by sending a GET request to
58# the "/stored-files/{file_id}" endpoint
59response = requests.get(f'{base_url}/stored-files/{file_id}', headers=auth)
60response.raise_for_status()
61
62# Convert the JSON text that the response body contains to a dictionary and fetch the ID of the document
63doc_id = response.json()['file']['document_id']
64
65# Fetch the information about the e-sign document by sending a GET request to the "/documents/{doc_id}" endpoint
66response = requests.get(f'{base_url}/documents/{doc_id}', headers=auth)
67response.raise_for_status()
68
69# Convert the JSON text that the response body contains to a dictionary and fetch the information about the document
70document = response.json()['document']
71
72# Define a variable named "signees" and then assign it with the list of e-sign document signees
73signees = document['signees']
74
75# Find the signee by his email and fetch the ID of the signee
76signee_id = None
77for signee in signees:
78    if signee['email'] == 'john.smith@example.com':
79        signee_id = signee['id']
80        break
81
82# Resend the email to the signee by sending a POST request to the "/documents/{doc_id}/signees/{signee_id}/resend"
83# endpoint
84response = requests.post(f'{base_url}/documents/{doc_id}/signees/{signee_id}/resend', headers=auth)
85response.raise_for_status()