How to delete and restore an envelope
This topic demonstrates how to delete and undelete an envelope. Deleting an envelope in Docusign means to move the envelope into the predefined folder Recycle Bin; undeleting an envelope means to move the envelope out of the Recycle Bin and into another folder as you desire: either another predefined folder, such as Inbox or Sent Items, or into any other folder you’ve defined in your Docusign account.
Docusign also provides other options for removing envelopes: you can void an envelope that’s still in progress (not completed), making it invalid; or you can purge an envelope in any state, which permanently destroys the envelope from your account. Both voiding and purging are one-way operations and cannot be reversed, unlike deleting.
Run this code example from our Quickstart or launcher projects: Bash, C#, Java, Node.js, PHP, PowerShell, Python, or Ruby.
Required data
Running the code in this how-to requires this data:
Step 1. Obtain your OAuth token
To make the API call shown in this how-to, you need a valid OAuth access token. Docusign supports access tokens for three different recommended OAuth grant types: Public Authorization Code Grant, Confidential Authorization Code Grant, and JSON Web Token (JWT) Grant. Choose the OAuth grant type appropriate for your scenario.
See Confidential Authorization Code Grant for guidance on your options to get an Confidential Authorization Code Grant OAuth token.
Step 2. Construct your API headers
After you have a valid OAuth access token, you are ready to construct the API headers that you will pass to the API call. Construct your headers like this, but make sure to substitute your valid OAuth access token for {ACCESS_TOKEN}.
Step 3. Construct the request body
Next, create the request body. The request body for this API call consists of an array of envelope IDs; you can include as many as you wish. For this how-to, view a sample envelope in your developer account (create one if you need to) and select Envelope ID to view the GUID value; then substitute that GUID for {ENVELOPE_ID} in the array.
Step 4. Call the eSignature REST API to delete your envelope
Now that you have constructed your API headers and request body, make a PUT request to the Folders:moveEnvelopes endpoint and include the request body to specify the envelope to move to the Recycle Bin. Here’s how you make the call, but make sure to substitute your API account ID for {API_ACCOUNT_ID}.
Step 5. Call the eSignature REST API to find the folder id
Find the Destination Folder ID: To restore an envelope to a specific folder, you must first get the folder’s unique ID. You can find this by making a GET request to the Docusign Folders:list API endpoint. This call returns a list of all the folders in your account; each folder’s properties include, among others, its name and corresponding folderId. You can then extract the folderId for the folder you want to move the envelope to; you’ll do that in Step 6.
Step 6. Call the eSignature REST API to undelete your envelope
Call the Folders:moveEnvelopes method with the ID of the envelope you want to undelete, the folder ID of the folder you want to move it to, and “recyclebin” as fromFolderId. The returned data will include the envelope ID moved from the recycle bin or Deleted folder. Deleted envelopes can be undeleted only within 24 hours from the Docusign Recycle Bin; thereafter, they are no longer accessible from your Docusign account.
Expected response
If you run this code example from our Quickstart or launcher projects, you should see a JSON response similar to the code shown.
Next steps
- Run this code example from our Quickstart or launcher projects: Bash, C#, Java, Node.js, PHP, PowerShell, Python, or Ruby.
- See how to Go-Live with a completed app and find the base path for API calls in the production environment.