Skip to main content

Hi,

I’m attempting to leverage the embedded URL function in the apex toolkit where a user can initiate a contract and have a user sign on their device in person using embedded URL to docusign.

I’m requesting an envelope using this code:

 

        // 2. Create empty envelope tied to CPA
        dfsle.Envelope env = dfsle.EnvelopeService.getEmptyEnvelope(
            new dfsle.Entity(cpa.Id)
        );

        // 3. Attach DocuSign template
        dfsle.Document doc = dfsle.Document.fromTemplate(
            dfsle.UUID.parse(templateUuid),
            'Customer Product Agreement'
        );
        env = env.withDocuments(new List<dfsle.Document>{ doc });

        // 4. Create embedded recipient (⚠️ role name must match template role exactly)
        dfsle.Recipient signer = dfsle.Recipient.newEmbeddedSigner(
            cpa.Primary_Contact__r.Name,
            cpa.Primary_Contact__r.Email,
            String.valueOf(cpa.Primary_Contact__c) // clientUserId = Contact Id
        ).withRole(
            new dfsle.Recipient.Role('Primary Contact', 1) // role name must match your template
        );
        
        env = env.withRecipients(new List<dfsle.Recipient>{ signer })
                 .withEmail('Please sign: ' + cpa.Name, '');

        // 5. Send envelope (true = suppress email for embedded signing)
        env = dfsle.EnvelopeService.sendEnvelope(env, true);
        return String.valueOf(env.docuSignId);


And requesting URL with this code:

    public static String getEmbeddedSigningUrl(String envId, String url) {
      Url mySigningUrl = dfsle.SigningService.getEmbeddedSigningUrl(
        dfsle.UUID.parse(envId), // envId value as a UUID
        new URL(url) // url value as a URL
      );
      // Return string value of Url to controller
      return mySigningUrl.toExternalForm();

 

The response when trying to request the URL:

 

Line: 315, Column: 1
dfsle.APIException: The recipient you have identified is not a valid recipient of the specified envelope.

Hello ​@davidpezzulo,

The error you're experiencing is related to the envelope recipient, the email or name is incorrect, possibly it can be a misstype or the recipient updated their name.

To fix this double check the recipient email and name and create a new session for them. 

You can check how to update the in person signing recipient below:

dfsle.Recipient inPersonRecipient = new dfsle.Recipient();
inPersonRecipient.type = dfsle.RecipientType.InPersonSigner;
inPersonRecipient.name = 'Signer Name'; 
inPersonRecipient.email = 'signer@email.com'; 
inPersonRecipient.hostName = 'Host Name'; 
inPersonRecipient.hostEmail = 'host@email.com'; 

// Add recipient to envelope
myEnvelope.recipients.add(inPersonRecipient);

 

Also, try to create an embedded view with the code below:

 

public static String getEmbeddedSigningUrl(String envId, String returnUrl)

{
    dfsle.UUID envelopeUUID = dfsle.UUID.parse(envId);

    Url returnUrlObj = Url.valueOf(returnUrl);
    Url signingUrl = dfsle.SigningService.getEmbeddedSigningUrl(
        envelopeUUID,
        returnUrlObj
    );
    return signingUrl.toExternalForm();
}

 

Thanks,