How to revoke or cancel a document via the API?

BoldSign allows senders to cancel or revoke a document after it has been sent for signature, but this can only be done before the document is signed. This may be necessary if errors or inaccuracies are discovered in the document, or if it was sent to the wrong recipient. Once the document is canceled, signers will no longer be able to proceed with signing, and both the sender and signer will receive email notifications about the cancellation.

Below is a code snippet demonstrating how to revoke or cancel a document via the API.

Code snippet

curl -X 'POST' \
  'https://api.boldsign.com/v1/document/revoke?documentId={Your document id}' \
  -H 'X-API-KEY: {Your API Key}' \
  -H 'Content-Type: application/json;odata.metadata=minimal;odata.streaming=true' \
  -d '{
  "message": "Reason for revocation or cancellation",
}'

using BoldSign.Api;

var apiClient = new ApiClient("https://api.boldsign.com", "{Your API Key}");
var documentclient = new DocumentClient(apiClient);
await documentclient.RevokeDocumentAsync("{Your document id}", "Reason for revocation or cancellation").ConfigureAwait(false);

import requests
import json

url = "https://api.boldsign.com/v1/document/revoke?documentId={Your document id}"

payload = json.dumps({
  "message": "Reason for revocation or cancellation"
})
headers = {
  'X-API-KEY': '{Your API Key}',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)
print(response.text) 
const axios = require('axios'); 
async function Revoke() {
    try {
   const response = await axios.post( 

    'https://api.boldsign.com/v1/document/revoke', 

    { 
        message: 'Reason for revocation or cancellation' 
    }, 

    { 
        params: { documentId: '{Your document id}' }, 
        headers: { 
            'X-API-KEY': '{Your API Key}', 
            'Content-Type': 'application/json' 
        } 
    } 
); 
return response;   
    }
    catch (error)
     {
        console.error('Error:', error.message);
        throw error;
     }
}

Revoke(); 
<?php
require 'vendor/autoload.php';

use GuzzleHttp\Client;

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

$url = "https://api.boldsign.com/v1/document/revoke?documentId={Your document id}";

$payload = json_encode([
    "message" => "Reason for revocation or cancellation"
]);

$headers = [
    'X-API-KEY' => '{Your API Key}',
    'Content-Type' => 'application/json'
];

$response = $client->request('POST', $url, [
    'headers' => $headers,
    'body' => $payload
]);

echo $response->getBody()->getContents();

In the provided code examples, ensure that you update the documentId with the actual ID of the document you created. Once the code is executed, the document will be revoked, and the recipient will no longer be able to access it.