docusign / docusign-esign-python-client

The Official DocuSign Python Client Library used to interact with the eSign REST API. Send, sign, and approve documents using this client. https://www.docusign.com/devcenter
MIT License
97 stars 88 forks source link

How to update an envelope and change it's status from 'sent' to 'voided' #99

Open maaqib121 opened 3 years ago

maaqib121 commented 3 years ago

I want to implement an option to delete envelope in my application. For that I want to alter the envelope's status from 'send' to 'voided', but currently I haven't found any suitable method to do this. Is there any?

InbarGazit commented 3 years ago

https://www.docusign.com/blog/dsdev-common-api-tasks-void-an-envelope should help

InbarGazit commented 3 years ago
# You would need to obtain an accessToken using your chosen auth flow 
api_client = ApiClient()
api_client.host = base_path
api_client.set_default_header('Authorization', 'Bearer ' + access_token)
envelopes_api = EnvelopesApi(api_client)
env = Envelope()
env.status = 'voided'
env.voided_reason = 'changed my mind'
envelopes_api.update(account_id, envelope_id, env)
InbarGazit commented 3 years ago

Let me know if you need further assistance.

maaqib121 commented 3 years ago

Thanks, the issue is resolved.

Before calling the update method, we also have to change the purge_state of envelope to None, otherwise it return 400 Bad Request response. My issue is resolved by using the following code:

env = Envelope()
env.status = 'voided'
env.voided_reason = 'changed my mind'
env.purge_state = None
envelopes_api.update(account_id, envelope_id, envelope=env)

I have another question that when I send an envelope to bulk recipients, I get the following response from bulk_envelopes_api.create_bulk_send_list(ACCOUNT_ID, bulk_sending_list=bulk_sending_list) method:

{'bulk_copies': [{'custom_fields': [],
                  'email_blurb': None,
                  'email_subject': None,
                  'recipients': [{'access_code': None,
                                  'client_user_id': None,
                                  'custom_fields': None,
                                  'delivery_method': None,
                                  'email': 'f168324@nu.edu.pk',
                                  'email_notification': None,
                                  'embedded_recipient_start_url': None,
                                  'fax_number': None,
                                  'id_check_configuration_name': None,
                                  'id_check_information_input': None,
                                  'identification_method': None,
                                  'name': 'Aaqib 1',
                                  'note': None,
                                  'phone_authentication': None,
                                  'recipient_id': '1',
                                  'recipient_signature_providers': None,
                                  'role_name': None,
                                  'sms_authentication': None,
                                  'social_authentications': None,
                                  'tabs': None}]},
                 {'custom_fields': [],
                  'email_blurb': None,
                  'email_subject': None,
                  'recipients': [{'access_code': None,
                                  'client_user_id': None,
                                  'custom_fields': None,
                                  'delivery_method': None,
                                  'email': 'm.aaqib@thedevden.co',
                                  'email_notification': None,
                                  'embedded_recipient_start_url': None,
                                  'fax_number': None,
                                  'id_check_configuration_name': None,
                                  'id_check_information_input': None,
                                  'identification_method': None,
                                  'name': 'Aaqib 2',
                                  'note': None,
                                  'phone_authentication': None,
                                  'recipient_id': '2',
                                  'recipient_signature_providers': None,
                                  'role_name': None,
                                  'sms_authentication': None,
                                  'social_authentications': None,
                                  'tabs': None}]}],
 'list_id': '20e7d94d-5c21-4b5f-9c92-5b8d1c793dda',
 'name': 'employee_contract'}

And the following response from batch = bulk_envelopes_api.create_bulk_send_request(ACCOUNT_ID, bulk_list_id, bulk_send_request=bulk_send_request) method:

{'batch_id': 'e6a604dd-c965-4c4c-9eb9-d7f58e8b58c4',
 'batch_name': 'employee_contract',
 'batch_size': '2',
 'envelope_or_template_id': 'a40b8d8d-1125-42e5-b476-281339e72dc8',
 'error_details': None,
 'errors': None,
 'queue_limit': '2000',
 'total_queued': '2'}

How can I get the envelope_id for each envelope sent to each recipient? Thanks in advance.