.NET SDK

Easily integrate BoldSign's e-signature features into your .NET applications. This SDK simplifies sending documents for signature, embedding signing ceremonies, tracking document status, downloading signed documents, and managing e-signature workflows.

The .NET SDK is available on Nuget.org and the source code can be found in the GitHub repository.

Install the package

Install the BoldSign API package in your project using the below command.

dotnet add package BoldSign.Api 

By default, the latest stable version will be installed. If you want to switch to any specific version, you can do by mentioning the exact version in the command.

dotnet add package BoldSign.Api --version 4.7.11

BoldSign.Api NuGet package can be found in this link - https://www.nuget.org/packages/BoldSign.Api/.

Refer this article Install and manage NuGet packages in Visual Studio, for other ways of installing a package.

Authentication

You can authenticate and configure the BoldSign CSharp SDK using either an API Key or a Bearer Token. Depending on your authentication method, you can set up with one of the two configurations outlined below.

API Key

To authenticate using an API Key, you'll need to first generate your API key. You can refer to the API-Key for more details .

Once you have your API key, you can configure as follows:

var apiClient = new ApiClient("Your-API-Key-Here");

Replace "Your-API-Key-Here" with the actual API key you generated. After setting this up, the SDK will use this API key for authenticating all API requests.

OAuth 2.0

To authenticate using an Bearer Token(Access Token), you'll need to first generate your Bearer Token. You can refer to the OAuth 2.0 for more details .

Once you have your Bearer Token, you can configure as follows:

configuration.SetBearerToken(Your-Bearer-Token-Here);
var apiClient = new ApiClient(configuration);

Replace "Your-Bearer-Token-Here" with the actual Bearer Token you generated. After setting this up, the SDK will use this Bearer Token for authenticating all API requests.

Getting started

Prepare to send a document for signing by creating new instance of the DocumentClient as shown below.

var documentClient = new DocumentClient(apiClient);

To send the document for signature, the list of documents that need to be signed should be added to the IDocumentFile collection.

Load the document as a stream and create an instance of DocumentFileStream with it, and add it to the IDocumentFile collection as shown below:

// Read document from local path as stream.
using var fileStream = File.OpenRead("doc-2.pdf");
var documentStream = new DocumentFileStream
{
    ContentType = "application/pdf",
    FileData = fileStream,
    FileName = "doc-2.pdf",
};

// Creating collection with loaded document.
var filesToUpload = new List<IDocumentFile>
{
    documentStream,
};

You can also upload multiple documents and add them in the filesToUpload collection mentioned in the above code. The document can also be loaded as byte array or directly from a file path.

File formats accepted by the upload operation include .pdf, .png, .jpg, and .docx.

Now that the documents are loaded, we need to create the form fields to be signed or filled by the signer. The code below demonstrates the creation of signature field and it is added to a form field collection.

// Creating signature field.
var signatureField = new FormField(
            id: "Sign",
            type: Type.Signature,
            pageNumber: 1,
            isRequired: true,
            bounds: new Rectangle(x: 50, y: 50, width: 200, height: 30));

// Adding the field to the collection.
List<FormField> formFields = new List<FormField>();
formFields.Add(signatureField);

You can also add multiple form fields in the form fields collection and this collection can be assigned to a particular signer.

The document and its form fields requires signing. So specify the signer to sign the form fields.

Create a new instance of DocumentSigner with all the required signer information and assign the collection of form fields created in the last step.

// Creating signer field.
var signer = new DocumentSigner(
        name: "Signer Name 1",
        emailAddress: "signer1@email.com",
        signerOrder: 1,
        authenticationCode: "123456",
        signerType: SignerType.Signer,
        privateMessage: "This is private message for signer",
        // Assign the created form fields to the signer.
        formFields: formFields);

// Adding the signer to the collection.
var documentSigners = new List<DocumentSigner>
{
    signer
};

The last step is to send the document for signing with the defined document, form fields and signer.

// Create send for sign request object.
var sendForSign = new SendForSign
{
    Title = "Sent from API SDK",
    Message = "This is document message sent from API SDK",
    EnableSigningOrder = false,

    // Assign the signers collection.
    Signers = documentSigners,

    // Assign the loaded files collection.
    Files = filesToUpload
};

// Send the document for signing.
var createdDocumentResult = documentClient.SendDocument(sendForSign);

The return type createdDocumentResult will contain the document ID of the document created, which can be used in later stages to get the particular document related operations.

Examples

You can find the .NET example application in the official GitHub repository. Additional code examples are available in this GitHub repository.

Class reference

Refer to the .NET SDK class reference documentation here.