Create Envelope with DocuSign in C#

In the digital age, paperless transactions have become the norm, and DocuSign, a leading eSignature solution, has made this possible. If you're a C# developer looking to create an envelope, or a document to be signed, using DocuSign, you're in the right place. In this guide, we'll walk you through the process, ensuring you understand the key steps and best practices.

✉️ How To Make An Envelope Out Of A4 Paper
✉️ How To Make An Envelope Out Of A4 Paper

Before we dive in, ensure you have the DocuSign eSign API installed in your C# project. You can find it on the NuGet package manager. Also, have your DocuSign account details ready, including your integration key, base URL, and access token.

Printing envelopes from Google Docs
Printing envelopes from Google Docs

Setting Up Your DocuSign Environment

To start, you need to configure your DocuSign environment in your C# application. This involves setting up the DocuSign eSign Client and authenticating with your DocuSign account.

Free Printable Envelope Templates
Free Printable Envelope Templates

Here's a basic example of how to set up your DocuSign environment:

Installing the DocuSign eSign API

2 Minutes Custom Made Envelopes
2 Minutes Custom Made Envelopes

Open your Package Manager Console in Visual Studio and run the following command to install the DocuSign eSign API:

Install-Package DocuSignEsign -Version 3.1.0

Configuring DocuSign Client

two pieces of paper sitting on top of a cutting board
two pieces of paper sitting on top of a cutting board

After installation, you can configure the DocuSign client as follows:

var dsApiClient = new DocuSignEsign.Client.ApiClient(baseUrl); dsApiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken); dsApiClient.Configuration.DefaultHeader.Add("X-DocuSign-Authentication", "{\"Username\":\"" + integrationKey + "\",\"Password\":\"" + integrationPassword + "\"}");

Creating a New Envelope

50 FREE Envelope Templates for Every Size (PDF - Word)
50 FREE Envelope Templates for Every Size (PDF - Word)

Now that your environment is set up, let's create a new envelope, which is a document to be signed.

Here's a step-by-step guide to creating a new envelope:

free printable envelope templates with scissors and other items
free printable envelope templates with scissors and other items
an open envelope with the front and back sides cut out
an open envelope with the front and back sides cut out
sobre
sobre
DIY Full Size Envelope! #craft #art #diy #papercraft #stationery #tips #crafting
DIY Full Size Envelope! #craft #art #diy #papercraft #stationery #tips #crafting
the instructions for how to make an origami envelope
the instructions for how to make an origami envelope
How To Make A Large Envelope
How To Make A Large Envelope
How to Make an Envelope for a Card
How to Make an Envelope for a Card
10 Free Printable Envelope Templates for Formal and Casual Events
10 Free Printable Envelope Templates for Formal and Casual Events
💌 How To Make Envelope DIY Guide
💌 How To Make Envelope DIY Guide
5 Free Envelope Templates for Microsoft Word
5 Free Envelope Templates for Microsoft Word
an envelope is cut out to show the pattern
an envelope is cut out to show the pattern
Learn how to create lined envelopes in this easy tutorial.
Learn how to create lined envelopes in this easy tutorial.
How to Make an Envelope
How to Make an Envelope
someone is holding up some cards to make it look like they are making something out of paper
someone is holding up some cards to make it look like they are making something out of paper
an envelope template with the measurements for each side and four sides, all in different sizes
an envelope template with the measurements for each side and four sides, all in different sizes
an image of a square cut out with lines in the middle and one line at the top
an image of a square cut out with lines in the middle and one line at the top
an envelope template for small greeting cards with the text, 4 75 x 5 8 inches
an envelope template for small greeting cards with the text, 4 75 x 5 8 inches
33 Creative DIY Envelope Ideas for Special Occasions and Gifts
33 Creative DIY Envelope Ideas for Special Occasions and Gifts
Post from AMY DIY CRAFT
Post from AMY DIY CRAFT
Free Mini Envelope Template Printable — Sarica Studio
Free Mini Envelope Template Printable — Sarica Studio

Preparing the Document

First, you need to prepare the document that will be signed. This could be a PDF, Word, or other supported document types. You'll need to upload this document to DocuSign.

Creating the Envelope Definition

Next, you'll create an envelope definition, which is a JSON object that describes the envelope. This includes the document to be signed, the signers, and any fields that need to be signed or filled out.

Here's a simple example of an envelope definition:

var envelopeDefinition = new EnvelopeDefinition { Email = "recipient@example.com", Status = "sent", Documents = new List { new Document { DocumentBase64 = Convert.ToBase64String(System.IO.File.ReadAllBytes("path_to_your_document.pdf")), Name = "Document Name", FileExtension = "pdf", DocumentId = "1" } }, // Add signers, fields, and other envelope details here... };

Sending the Envelope

Finally, you'll send the envelope to DocuSign using the envelope definition you've created:

var envelopesApi = new EnvelopesApi(dsApiClient); var results = envelopesApi.CreateEnvelope(accountId, envelopeDefinition);

Handling Envelope Status and Results

After sending the envelope, you'll want to monitor its status and retrieve the signed document when it's complete.

Checking Envelope Status

You can check the status of an envelope using its envelope ID:

var envelope = envelopesApi.GetEnvelope(accountId, envelopeId); Console.WriteLine("Envelope status: " + envelope.EnvelopeStatus);

Retrieving the Signed Document

Once the envelope status is "completed", you can retrieve the signed document:

var document = envelopesApi.GetDocument(accountId, envelopeId, "1"); System.IO.File.WriteAllBytes("path_to_saved_signed_document.pdf", Convert.FromBase64String(document.DocumentBase64));

And there you have it! You've successfully created an envelope and handled its results using DocuSign and C#. This guide should provide you with a solid foundation for building more complex envelope creation workflows. Happy coding!

Related Articles

Money Envelope Size In Canva What Is The 100 Envelope Challenge Document Envelope Dimensions Create Envelope Docusign Free Printable Birthday Money Envelope Template Money Envelopes Printable What Is Envelope 10 Print Size Money Envelope Size In Mm Free Printable Birthday Envelope Template Money Envelope Size In Cm