153 DocuSign API Code Examples (and more to come!)

The easiest way to write software is to start with “known-good” software, then update it to meet your own specific requirements. Starting with software you know works also helps with debugging.

In 2018, I focused on re-writing the DocuSign eSignature API code examples for our developers, providing new examples that are easier to use, more representative of real-world use cases and patterns, and supporting more programming languages. We now have the following examples:

  • New workflow code examples that use the current versions of the DocuSign SDKs are available on github.com/docusign in all of our primary languages: C#, PHP, Java, Node.js, Python, and Ruby. Code examples showing how to call the API directly are also available. They use the cURL utility.
  • Each new code example has been grouped into a launcher, which provides access to all of the workflow code examples for a given language. Each launcher includes software for authenticating with DocuSign via either the Authorization Code Grant flow or the JWT Grant flow.
  • Each workflow code example can be used with either type of authentication. For example, you can list and then download an envelope’s documents (workflow examples 6 and 7) using either the Authorization Code or JWT Grant flows--all you need to do is pass in an access token, account_id, and base_path from the authentication flow. The primary launchers, each of which includes 14 – 18 workflow examples, are the Github repositories that include support for the OAuth Authorization Code Grant flow.

Getting started with the code example launchers

So how do you use them? First, decide which language you want to use: C#, PHP, Java, Node.js, Python, Ruby, or the direct API examples via cURL. Next, click the link, download the launcher’s repository, and follow the instructions in the readme file for configuring and running it.

The example projects listed above all implement Authorization Code Grant authentication to obtain an access token, but we also provide examples of how to implement the OAuth JWT Grant flow. You can access code examples that implement JWT authentication from the following list: C# .NET Core, C# .NET Framework, PHP, Java, Node.js, Python, and Ruby.

Notable workflow code examples

The code example launchers include many different workflow examples. Here are some of the most notable examples.

  • The embedded signing example (example workflow 1 of the authorization code grant launchers) demonstrates a good UI for embedding the DocuSign Signing Ceremony within your app’s flow. Note the busy indicator that’s used to reassure the user that something is happening.
  • The sign via email example (example workflow 2) demonstrates how an envelope can include multiple documents of different source types.
  • Sending an envelope with binary upload of the documents (example workflow 10) demonstrates the best way to send envelopes that include large documents or document sets.

What’s Next

Within the DocuSign DevCenter team, we’re working to add additional workflow examples to the launchers. We’re also working on articles about each workflow example, which will be published in the DevCenter.

If you have an idea for a new code example, please let me know via apihelp@docusign.com

Larry Kluger
Larry Kluger
Lead Product Manager, Partner Platform