Arex388.DocuSeal 2.1.0

dotnet add package Arex388.DocuSeal --version 2.1.0
                    
NuGet\Install-Package Arex388.DocuSeal -Version 2.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Arex388.DocuSeal" Version="2.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Arex388.DocuSeal" Version="2.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Arex388.DocuSeal" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Arex388.DocuSeal --version 2.1.0
                    
#r "nuget: Arex388.DocuSeal, 2.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Arex388.DocuSeal@2.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Arex388.DocuSeal&version=2.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Arex388.DocuSeal&version=2.1.0
                    
Install as a Cake Tool

Arex388.DocuSeal

Arex388.DocuSeal is a highly opinionated .NET Standard 2.0 library for the DocuSeal.co API. It is intended to be an easy, well structured, and highly performant client for interacting with the DocuSeal.co API for sending documents for e-signatures. It can be used in applications interacting with a single account using IDocuSealClient, or with applications interacting with multiple accounts using IDocuSealClientFactory.

As noted above, it is highly opinionated. The API documentation is not very clear, and there's redundancies, ambiguities, and object properties that I have no idea why they're there or what they stand for. While it has been one of the better documented APIs I've worked with, there was still some questionable design decisions about it. I've attempted to normalize the ambiguities, and to ignore the redundancies with this client.

Dependency Injection

To configure dependency injection use the AddDocuSeal() extensions on IServiceCollection. There are two signatures, with and without passing in a DocuSealClientOptions object. If the options object is passed to the extension, it will register IDocuSealClient for use with a single account, otherwise it will register IDocuSealClientFactory for use with multiple accounts.

Accounts on DocuSeal's EU region set Region = DocuSealRegion.Eu on the DocuSealClientOptions (it defaults to DocuSealRegion.Global), which sends requests to api.docuseal.eu instead of api.docuseal.com; the factory caches clients per authorization token and region.

How to Use

For a single account, inject the IDocuSealClient.

private readonly IDocuSealClient _docuSeal;

_ = await _docuseal.ListTemplatesAsync();

For multiple accounts, inject the IDocuSealClientFactory to create an instance per account.

private readonly IDocuSealClientFactory _docuSealFactory;

var docuseal = _docuSealFactory.CreateClient(new DocuSealClientOptions {
    AuthorizationToken = "Your authorization token from DocuSeal.co"
});

_ = await docuseal.ListTemplatesAsync();

To download a submission's signed documents, pass the URL the API returned to DownloadDocumentAsync(). Content is not null exactly when Success is true, and it is only readable until the response is disposed.

var submission = await _docuSeal.GetSubmissionAsync(submissionId);

if (submission.Submission?.CombinedDocumentUrl is { } url) {
    using var download = await _docuSeal.DownloadDocumentAsync(url);

    if (download.Content is { } content) {
        await content.CopyToAsync(destination);
    }
}

The client provides methods for interacting with Templates, Submissions, and Submitters using the following methods:

Templates
  • ArchiveTemplateAsync() - Archive a template so it can't be used. This is essentially a soft delete.
  • CloneTemplateAsync() - Clone a template.
  • CreateTemplateAsync() - Create a new template.
  • CreateTemplateFromHtmlAsync() - Create a new template from HTML with field tags.
  • GetTemplateAsync() - Get an existing template.
  • ListTemplatesAsync() - List all templates, with archived templates hidden by default.
  • MergeTemplatesAsync() - Merge two or more templates into one.
  • UpdateTemplateAsync() - Update a template.
  • UpdateTemplateDocumentsAsync() - Update a template's documents.
Submissions
  • ArchiveSubmissionAsync() - Archive a submission so it can't be used. This is essentially a soft delete.
  • CreateSubmissionAsync() - Create a new submission for a template. The response carries the new submission's id (SubmissionId) and one Submitter per submitter in the request (Submitters), each with the EmbedSrc of its signing form. It does not carry the submission itself, so call GetSubmissionAsync() with the id when you need it.
  • CreateSubmissionFromDocxAsync() - Create a one-off submission from DOCX documents, without a saved template, filling [[variables]] from Variables. The response carries the created Submission, with its Submitters and the EmbedSrc of each signing form; the API returns a subset of the submission, without documents, events, or template.
  • CreateSubmissionFromEmailsAsync() - Create one submission per email address for a template, with the simplified POST /submissions/emails request. The response carries one Submitter per address (Submitters), each with its own SubmissionId and the EmbedSrc of its signing form.
  • CreateSubmissionFromHtmlAsync() - Create a one-off submission from HTML documents with field tags, without a saved template. The response carries the created Submission, with its Submitters and the EmbedSrc of each signing form; the API returns a subset of the submission, without documents, events, or template.
  • CreateSubmissionFromPdfAsync() - Create a one-off submission from PDF documents, without a saved template, with fields from {{text}} tags or from each document's Fields. The response carries the created Submission, with its Submitters and the EmbedSrc of each signing form; the API returns a subset of the submission, without documents, events, or template.
  • DownloadDocumentAsync() - Download a document from a URL the API returned: a submission document's Url, a submission's CombinedDocumentUrl, or its AuditUrl. The response carries the content as a Stream, ContentType and ContentLength, and is disposable: dispose it when you are done reading. The download never sends your authorization token.
  • GetSubmissionAsync() - Get an existing submission.
  • GetSubmissionDocumentsAsync() - Get a submission's documents: the signed documents once it is completed, the partially filled ones before then. Set MustMerge on the request to merge them into a single PDF.
  • ListSubmissionsAsync() - List submissions, optionally filtered by status, folder, template, or archived state. Archived submissions are not hidden unless you set IsArchived to false.
  • UpdateSubmissionAsync() - Update a submission's name or expiration, or archive or unarchive it. Set IsArchived to false to unarchive it, and ClearExpiration to remove its expiration (ExpireAtUtc and ClearExpiration cannot be combined).
Submitters
  • GetSubmitterAsync() - Get a submitter for a submission.
  • ListSubmittersAsync() - List the submitters for a submission.
  • UpdateSubmitterAsync() - Update a submitter. The response carries the updated submitter, with its EmbedSrc.
Webhooks

DocuSeal posts webhook events to an endpoint you host, so parsing them needs no client or authorization token. DocuSealWebhook.Parse() takes the request body, as a string or as UTF-8 bytes, and returns the event as the subtype matching its event_type:

  • FormWebhookEvent - form.viewed, form.started, form.completed, and form.declined. Data is the submitter, with its Submission and Template.
  • SubmissionWebhookEvent - submission.created, submission.completed, and submission.expired. Data is the Submission.
  • SubmissionArchivedWebhookEvent and TemplateArchivedWebhookEvent - submission.archived and template.archived. Data carries the archived object's Id and ArchivedAtUtc.
  • TemplateWebhookEvent - template.created and template.updated. Data is the Template.
  • UnknownWebhookEvent - any event_type the client doesn't know yet, with the raw event_type in RawType and the unparsed data in Data.

It never throws. It returns null when it can't read the payload, which doesn't by itself mean the request didn't come from DocuSeal:

  • The body isn't valid JSON, including invalid UTF-16 or UTF-8 text.
  • The body's root isn't an object.
  • event_type is missing or isn't a string.
  • timestamp is missing or isn't an ISO 8601 date string.
  • data is missing.
  • The event_type is known, but its data isn't an object or doesn't bind to its model.
app.MapPost("/webhooks/docuseal", async (HttpRequest request) => {
    using var reader = new StreamReader(request.Body);

    var webhookEvent = DocuSealWebhook.Parse(await reader.ReadToEndAsync());

    switch (webhookEvent) {
        case FormWebhookEvent { Type: WebhookEventType.FormCompleted } formCompleted:
            //  formCompleted.Data.Email, formCompleted.Data.Values, ...
            break;

        case SubmissionWebhookEvent { Type: WebhookEventType.SubmissionCompleted } submissionCompleted:
            //  submissionCompleted.Data.Documents, ...
            break;

        case null:
            return Results.BadRequest();
    }

    return Results.Ok();
});

Parse() only reads the body; it doesn't authenticate the request, so check that it came from DocuSeal before acting on it.

Hoping for API Improvements

For the most part the API is one of the most well structured ones I've built a client for, and the OpenAPI spec has since settled most of what used to bother me. Creating a submission returns the submitters of the one submission that was created, not a submission that sometimes comes back as an array: in each of them id is the submitter's id and submission_id is the submission's id, which is why CreateSubmission.Response exposes SubmissionId and Submitters and Submission.Id is simply the id of the submission body. The status values, and every other enum, are defined, so the client types them (SubmissionStatus, SubmitterStatus, and the rest). It still has a couple of flaws:

  • You can't ever delete something in DocuSeal, you can only archive it, which is just a soft delete. I would have preferred it if deleting was actually deleting, and archiving was just a specific update. The API can at least unarchive now: updating a submission (UpdateSubmissionAsync()) or a template (UpdateTemplateAsync()) with IsArchived set to false unarchives it.
  • Responses have properties that just don't seem to be relevant to anything. I've kept the majority, simply because I wasn't sure if users of this library might find them useful or not.

I'm sure there's something I've missed, but that's all I can remember now that I am at the end of two weeks of building this client. Hopefully, the DocuSeal API will improve in the future to address these, in my opinion, flaws.

That being said, it's a night-and-day difference working with the DocuSeal API vs the DocuSign API. The DocuSign API is absolutely the most awful API I've ever worked with.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.1.0 98 11/5/2026
2.0.1 99 11/3/2026
2.0.0 95 11/3/2026
1.0.6 450 3/17/2025
1.0.5 227 10/14/2024
1.0.4 219 9/25/2024
1.0.3 219 9/23/2024
1.0.2 255 8/8/2024
1.0.1 208 8/7/2024
1.0.0 218 8/7/2024