> You are reading the Docusign Developer Documentation. For clean Markdown of any page, append .md to the page URL.
>
> Documentation indexes by section:
> - APIs and SDKs: https://docusign.docs.buildwithfern.com/docs/llms.txt
> - Platform 101: https://docusign.docs.buildwithfern.com/platform/llms.txt
> - Extension Apps: https://docusign.docs.buildwithfern.com/extension-apps/llms.txt
> - Docusign CLI: https://docusign.docs.buildwithfern.com/docusign-cli/llms.txt
>
> Authentication (OAuth, JWT Grant, M2M): https://docusign.docs.buildwithfern.com/platform/auth
> Webhooks and Connect: https://docusign.docs.buildwithfern.com/platform/webhooks
>
> OpenAPI specifications: https://docusign.docs.buildwithfern.com/openapi.json
> MCP server: https://docusign.docs.buildwithfern.com/_mcp/server

# PurgeDocuments

## PurgeDocuments

This method can be used to purge completed documents from the Docusign system. When the PurgeDocuments method is used, the envelope documents are placed in a purge queue for deletion in 14 days. A warning email notification is sent to the sender and recipients associated with the envelope notifying them that the envelope document will be deleted in 14 days and providing a link to the documents. Another email is sent 7 days later with the same message. At the end of the 14-day period, the envelope documents are deleted from the system. The envelope information for the document will remain, but the documents are removed.

**Note:** If you set up a Document Retention policy for your account, by specifying the number of days to retain documents in the Account Preferences Features section, at the end of the retention period the documents are placed on that 14-day purge queue and the warning emails are sent. So in effect, setting Document Retention policy is the same as setting a schedule for calling PurgeDocuments.

**`C#`**

```csharp title="C#"
// Create and send envelope as shown in linked code
DocuSignWeb.EnvelopeStatus status = <create and send envelope>;

// Purge the documents from the envelope
DocuSignWeb.PurgeDocumentStatus pStatus = _apiClient.PurgeDocuments(status.EnvelopeID);

// Confirm that the purge succeeded
Console.WriteLine("Purging the envelope worked? {0}", pStatus.PurgeDocumentSuccess);
```

**`PHP`**

```php title="PHP"
// Create and send envelope as shown in linked code
$response = <create and send envelope>;
$createResult = $response->CreateAndSendEnvelopeResult;

// Purge the documents from the envelope
$purgeDocumentsparams = new PurgeDocuments();
$purgeDocumentsparams->EnvelopeID = $createResult->EnvelopeID;
$response = $api->PurgeDocuments($purgeDocumentsparams);
```

### Schema

![](/_fern-files/_img/115a58c04f26f7b53d1c3ed3653d9910eba2210b0861b289c80f5c41d065653b.webp)

| Name       | Schema Type | Description                              |
| ---------- | ----------- | ---------------------------------------- |
| EnvelopeId | DSXId       | Envelope ID to purge the documents from. |

This method returns PurgeDocumentStatus upon execution completion.

## PurgeDocumentsStatus

### Schema

![](/_fern-files/_img/d48b0c4edc0463a5cfa2132642dbb5a4e42f88c0a836511bda15fd8ded5ee88f.webp)

| Name                 | Schema Type | Description                                                        |
| -------------------- | ----------- | ------------------------------------------------------------------ |
| PurgeDocumentSuccess | Boolean     | True if successful.                                                |
| PurgeDocumentError   | String      | If PurgeDocumentSuccess is false an error description is returned. |

### Rules and Exceptions for PurgeDocuments

* Envelope_Does_Not_Exist – invalid envelope ID passed. This exception will be thrown.

* User_Lacks_Permissions - The user making the API calls must have permissions to export Authoritative Copy Documents. This exception will be thrown.

* If PurgeDocumentSuccess returns false one of the following error conditions occurred:

* Only the sender may remove the envelope documents.
  * Envelope is an authoritative copy, documents cannot be removed.
  * Envelope is not complete, documents cannot be removed.