You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何无需运行WebApp,使用DocuSign C# SDK实现远程签署?

Automating DocuSign Signature Requests Without a Web App (C# SDK)

Absolutely! You don’t need to run a dedicated web app or manually click remote signing options to send signature requests automatically with the DocuSign C# SDK. You can fully automate this workflow from a standalone process—here’s how to do it:

1. Set Up Server-Side Authentication

First, you’ll need to authenticate your application without user interaction. The best approach here is JWT Authentication (JSON Web Token), which lets your app authenticate directly with DocuSign after a one-time authorization setup.

Here’s a quick code snippet to get your access token:

var apiClient = new ApiClient("https://demo.docusign.net/restapi");
var jwtConfig = new JwtConfiguration
{
    ClientId = "YOUR_INTEGRATION_KEY",
    UserId = "YOUR_USER_ID",
    OAuthBasePath = "account-d.docusign.com",
    PrivateKey = File.ReadAllText("private_key.pem"),
    Scopes = new List<string> { "signature", "impersonation" }
};

var accessToken = apiClient.RequestJWTUserToken(
    jwtConfig.ClientId,
    jwtConfig.UserId,
    jwtConfig.OAuthBasePath,
    jwtConfig.PrivateKey,
    3600,
    jwtConfig.Scopes
);
apiClient.Configuration.DefaultHeader.Add("Authorization", $"Bearer {accessToken}");

2. Construct and Send the Envelope Programmatically

Next, build your envelope definition directly in code—no need to wait for POST data from another web app. You’ll define the document, signers, and signature tabs, then send the envelope with a single API call.

Example code to create and send an envelope:

var envelopesApi = new EnvelopesApi(apiClient);

// Load your document
var documentBytes = File.ReadAllBytes("document_to_sign.pdf");
var document = new Document
{
    DocumentBase64 = Convert.ToBase64String(documentBytes),
    Name = "Contract",
    DocumentId = "1"
};

// Define the signer
var signer = new Signer
{
    Email = "signer@example.com",
    Name = "John Doe",
    RecipientId = "1",
    RoutingOrder = "1"
};

// Add a signature tab (position it on the document)
var signHereTab = new SignHere
{
    DocumentId = "1",
    PageNumber = "1",
    XPosition = "100",
    YPosition = "100"
};
signer.Tabs = new Tabs { SignHereTabs = new List<SignHere> { signHereTab } };

// Build the envelope
var envelopeDefinition = new EnvelopeDefinition
{
    EmailSubject = "Please sign this contract",
    Documents = new List<Document> { document },
    Recipients = new Recipients { Signers = new List<Signer> { signer } },
    Status = "sent" // This triggers the email send
};

// Send the envelope
var envelopeSummary = envelopesApi.CreateEnvelope("YOUR_ACCOUNT_ID", envelopeDefinition);
Console.WriteLine($"Envelope sent! Envelope ID: {envelopeSummary.EnvelopeId}");

3. Run as a Standalone Process

You can package this code into:

  • A console application: Run it manually or schedule it via Windows Task Scheduler/cron.
  • A Windows service: Run it in the background to handle automated requests.
  • A serverless function: Deploy to Azure Functions, AWS Lambda, or similar to trigger on events (like a database update or scheduled time).

Key Notes

  • Ensure your DocuSign integration key has the necessary permissions (e.g., signature scope) and that you’ve completed the one-time JWT authorization step (granting your app access to your DocuSign account).
  • If you need to track signing status later, you can set up DocuSign Webhooks (Connect) to receive notifications, but this is optional for the initial send.

内容的提问来源于stack exchange,提问作者rlatagan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.09 20:37:54