EnterTheCode
EnterTheCode

Reputation: 494

Retrieving the senders name and email from an envelope?

I have a service account that is using DocuSign's polling to retrieve a list of envelopes that had a status change. These envelopes were sent by various internal users. When I go to retrieve the envelopes, I'd like to retrieve who the sender of the envelope is (sender's name and email).

I initially excepted this information to be part of the Envelope object, but it's not:

Envelope envInfo = envelopesApi.GetEnvelope(AccountId, envelopeId);

I've tried various other API calls and reviewed documentation, but none of them seem to provide a way to get the sender's name and email.

Can this information be retrieved?

Upvotes: 0

Views: 280

Answers (2)

Kim Brandl
Kim Brandl

Reputation: 13480

There actually is a way that you can get Sender Name and Email for an Envelope via the API. First, issue a Get Envelope Audit Events request to identify the UserId of the Sender. Then, use that UserId to issue a Get User request to obtain the sender's name and email address. Here are the steps, with sample requests/responses (irrelevant info omitted, for brevity):

1) Get Envelope Audit Events

Request:

GET /accounts/{accountId}/envelopes/{envelopeId}/audit_events

Response:

{
    "auditEvents": [
        {
            "eventFields": [
                ...
                {
                    "name": "UserName",
                    "value": "John Doe"
                },
                {
                    "name": "UserId",
                    "value": "af465e97-83a6-472c-a25b-ebad10e4cc6a"
                },
                {
                    "name": "Action",
                    "value": "Registered"
                },
                {
                    "name": "Message",
                    "value": "The envelope was created by John Doe"
                },
                {
                    "name": "EnvelopeStatus",
                    "value": "created"
                },
                ...
            ]
        },
        ...
    ]
}

2) Get User (specifying the UserId from the previous response)

Request:

 GET /accounts/{accountId}/users/af465e97-83a6-472c-a25b-ebad10e4cc6a

Response:

{
    "userName": "John Doe",
    "userId": "af465e97-83a6-472c-a25b-ebad10e4cc6a",
    "email": "[email protected]",
    "firstName": "John",
    "lastName": "Doe",
    ...
}

Another option (if you're creating the Envelopes with the API to begin with) would be to always specify "Custom Envelope Fields" for each Envelope at creation-time that contain the sender's name and email address. Doing it this way would let you retrieve this info with the same request you're already issuing to retrieve the envelope info (provided that you include the extra querystring parameter (include=custom_fields):

GET accounts/{accountId}/envelopes/{envelopeId}?include=custom_fields

Upvotes: 2

Amit K Bist
Amit K Bist

Reputation: 6808

DocuSign does not work in this way, as envelopes are linked to a user and its user's documents so no one can access the document until and unless user shares the envelopes with anyone. So there are no APIs which will inform you the sender email/name by querying DS on envelopeId. You have two ways to achieve this requirement:

  • Use DS Connect (recommended way), configure Connect in your DS Account and DocuSign will push the connect messages with the sender details in that XML message when a subscribed trigger event occurs

  • Another way is you need to get OAUTH access token of all your users and then call DS APIs to know the envelopes for each user

Connect message will look like below:

<UserName>Sender Name</UserName>
<Email>[email protected]</Email>

Upvotes: 0

Related Questions