How to delete a document via BoldSign API?

BoldSign offers the ability to delete previously created documents through the API. If your organization accumulates many documents, some may become obsolete over time. You can review and remove these documents using the API.

To delete a document, you first need to obtain the document ID of the document you wish to delete. You can either list your documents using the API to find this ID or retrieve it from the web app. Refer to this guide for instructions on how to list documents via API: List documents via API.

To permanently delete the document, you need to set deletePermanently parameter to true. The default value for this parameter is false. By default, the document is moved to the trash when deleting the document.

To delete the document via API it must be in one of the following states: completed, revoked, or declined. If the document is In Progress state, you can revoke the document using the /v1/document/revoke API and then you can proceed to delete it. Refer to this documentation for revoking the document via API Revoke document

Here are some example codes demonstaring on how to delete a document via API:

Code snippet

curl -X 'DELETE' \ 'https://api.boldsign.com/v1/document/delete?documentId=documentId&deletePermanently=false' \
     -H 'X-API-KEY: {your API key}' 
using BoldSign.Api;

var apiClient = new ApiClient("https://api.boldsign.com", "{Your API Key}");
var documentClient = new DocumentClient(apiClient);
documentClient.DeleteDocument("{Your document id}", false);
import requests

url = "https://api.boldsign.com/v1/document/delete?documentId=document id&deletePermanently=false"
payload={}
headers = {
  'X-API-KEY': '{Your API Key}'
}
response = requests.request("DELETE", url, headers=headers, data=payload)
print(response.text)

const axios = require('axios');

async function DeleteDocument(){
try{
    
    const response = await axios.delete('https://api.boldsign.com/v1/document/delete', {
        params: {
    
            'documentId': '{your document id}',
            '&deletePermanently': 'false'
    
        },
    
        headers: {
    
            'X-API-KEY': '{Your API Key}'
    
        }
    });

  console.log(JSON.stringify(response.data));
  return response;
  }
  catch (error) {
    console.error('Error:', error.message);
    throw error; 
  } 
}
  DeleteDocument();
<?php

require 'vendor/autoload.php';
use GuzzleHttp\Client;

$client = new Client([
    'verify' => false
]);

$url = "https://api.boldsign.com/v1/document/delete?documentId=documentId&deletePermanently=false";

$response = $client->request('DELETE', $url, [
    'headers' => [
        'X-API-KEY' => '{Your API Key}'
    ]
]);

echo $response->getBody();
?>

In the above examples, make sure to replace documentId with the ID of the document that you want to delete. Once the code is executed, the specified document will be deleted from your account.