While the DocuSign eSignature REST API SDKs can abstract away the need to manage individual HTTP packets, there are times when it is helpful to dig in deeper and see more information about what is happening when an application calls DocuSign’s eSignature API. For this reason, the SDKs offer variant methods that include HTTP information.
For example, the C# SDK offers two similar methods: EnvelopesApi.CreateEnvelope() and EnvelopesApi.CreateEnvelopeWithHttpInfo(). While the two perform the same function – creating an envelope – they differ in the response object they provide your application. The CreateEnvelope method simply returns an EnvelopeSummary, in which the EnvelopeId and Status are available. The CreateEnvelopeWithHttpInfo() method wraps that EnvelopeSummary in an ApiResponse object, which includes the EnvelopeSummary in the Data object as well as the HTTP response code and the packet’s headers.
As per API Resource Limits, most DocuSign API calls will include a set of headers that will aid in tracking an account’s API Limit usage. To access these using an SDK, only a small amount of refactoring is necessary:
- First, update the method to include HTTP info, and modify the expected response object type accordingly:
ApiResponse<EnvelopeSummary> results = envelopesApi.CreateEnvelopeWithHttpInfo(accountId, envelopeDefinition);
- Values that were previously available at the root level are now under the Data parameter. For example, to pull the EnvelopeId:
string envelopeId = results.Data.EnvelopeId;
- The response headers can also be pulled and analyzed:
results.Headers.TryGetValue("X-RateLimit-Remaining", out string remaining); results.Headers.TryGetValue("X-RateLimit-Reset", out string reset); Console.WriteLine("API calls remaining: " + remaining); Console.WriteLine("Next Reset: " + reset); // Unix timestamp
With this information, an application can then be aware of its limit and warn a user before taking bulk actions that would otherwise take an account over the limit. It would also be possible to track how low the remaining value gets each hour, and fire a warning if it is regularly exceeding a comfortable threshold.
The DocuSign eSignature REST API also offers an optional header to track processing times, which is useful when attempting to identify the cause of delays in a workflow. To use the TimeTrack function, you’ll need to add an additional header to your outgoing API call: The header’s Key should be “X-DocuSign-TimeTrack” and the Value can either be empty, or an arbitrary value that DocuSign will return in the response.
To add a header using the C# SDK:
If this header is present in the call to the API, the eSignature API will return timestamps of when the call hit DocuSign, and when DocuSign response was sent:
By parsing and comparing these two timestamps, one can identify if a delayed response was due to processing time on the DocuSign side or network latency.
- API Reference – Requests and Responses
- eSignature REST API Resource Limits
- DocuSign Developer Center
- @DocuSignAPI on Twitter
- DocuSign for Developers on LinkedIn
- DocuSign Developer Newsletter