You are using an older browser that might negatively affect how this site is displayed. Please update to a modern browser to have a better experience. Sorry for the inconvenience!

Update Recipient Using DocuSign REST API

By: Radha

In DocuSign, we can update the recipient once the envelop has been sent. When you update the recipient, the envelop must be in “In Process” status. You cannot update the recipient when the envelop is “Completed” or “Void” status.

For this you must have the following things.

  1. You must have a DocuSign account.
  1. Install DocuSign app in Salesforce account.
  1. Enable the API key into your DocuSign account.
  1. Store the DocuSign credential and API key into your custom setting in salesforce.

For updating the recipient into the envelop, you need to send the callout to the following endpoint


For sending callout to the above endpoint we should have envelopId, so we can store the envelop id in one hidden field. For my scenario, I have stored the envelopId in Envelop_Id__c field in case object.

Here is the code snippet for updating the recipient in the Envelop. You can execute this snippet in your developer console

String account; 

String UserName; 

String Password; 

String IntegratorKey; 

String endPointURL; 

String templateID;  

String endpoint; 

String json; 

String aaa = '?advanced_update=true'; 

Map<String,DocuSignCredentialsSetting__c> credentialSetting = DocuSignCredentialsSetting__c.getAll(); 

case currentParentCase = [SELECT Id,CaseNumber,Envelop_Id__c FROM Case WHERE Id =: '5000n000000pTjU']; 

//Get the docusign credential details from the custom setting. 

for(DocuSignCredentialsSetting__c credentialIns : credentialSetting.values()){ 

    UserName =; 

    account = credentialIns.account__c; 

    Password = credentialIns.Password__c; 

    IntegratorKey  = credentialIns.IntegratorKey__c; 

    endPointURL = credentialIns.end_Point__c; 


//docusign template Id 

templateID = label.WishClearence; 

if(currentParentCase.Envelop_Id__c == Null) 

 endpoint = endPointURL+'/accounts/'+account+'/envelopes'; 


   endpoint = endPointURL+'/accounts/'+account+'/envelopes/'+currentParentCase.Envelop_Id__c+'/recipients';  

system.debug('### endpoint #####'+endpoint ); 

String authorizationHeader = '<DocuSignCredentials><Username>'+UserName+'</Username><Password>'+Password+'</Password><IntegratorKey>'+IntegratorKey+'</IntegratorKey></DocuSignCredentials>'; 

HttpRequest req = new HttpRequest();  


if(currentParentCase.Envelop_Id__c == Null) 




req.setHeader('X-DocuSign-Authentication', authorizationHeader);  





if(currentParentCase.Envelop_Id__c == Null) { 


    ' '+  

    ' "emailSubject": "This is email subject",'+ 

    ' "emailBlurb": "This is emailblurb",'+  

    ' "templateId": "'+templateID+'",'+  

    ' "envelopeIdStamping": "false",'+  

    ' "customFields":{'+ 

    '    "textCustomFields":['+ 

    '      {'+ 

    '        "name":"##SFCase",'+ 

    '        "required":"true",'+ 

    '        "show":"false",'+ 

    '        "value":"'+currentParentCase.Id+'"'+ 

    '      }'+ 

    '    ]'+ 

    '  },'+ 

    ' "templateRoles": ['+  


    '"roleName": "Signer 1",'+  

    '"name": "'+'kanagaraj'+'",'+  

    '"email": "'+''+'",'+ 

    '"emailNotification": {'+ 

    '"emailSubject": "Signature Required-Wish Clearance ",'+ 




    ' ],'+  

    ' "status": "sent"'+  





    ' '+ 

     ' "signers": ['+  


    '"roleName": "Signer 1",'+  


    '"name": "'+'Vijy'+'",'+  

    '"email": "'+''+'",'+ 

    '"emailNotification": {'+ 

    '"emailSubject": "Signature Required-Wish Clearance ",'+ 




    ' ],'+  

    ' "status": "sent"'+  




Http http = new Http();  

HTTPResponse res;  


    res = http.send(req);  

    system.debug('DocuSign Response'+ res.getBody());  


catch(Exception e){  

    ApexPages.addMessage( new ApexPages.Message(ApexPages.Severity.FATAL, e.getMessage()));  


WrapperDocuSign wrapInst = WrapperDocuSign.parse(res.getBody());  

IF(currentParentCase.Envelop_Id__c == Null) 


    currentParentCase.Envelop_Id__c = wrapInst.envelopeId; 

    Update currentParentCase; 



system.debug('Current Case Id'+currentParentCase.Id); 

// This wrapper class is used to parse the Jason response that is received from the docusign 

public class WrapperDocuSign {  

public String envelopeId;  

public String uri;  

public String statusDateTime;  

public String status;  

public static WrapperDocuSign parse(String json){ 

return (wrapperDocusign)System.JSON.deserialize(JSON,WrapperDocuSign.class);  

} } 

Result :  

Here, we are making a callout to DocuSign with the recipient as “Kanagaraj”

docusign rest api

Here, we are making a callout to update the recipient with the name as “Vijay”

docusign rest api

Reference Link