Docs
C# / .NET SDK
Use dotnet add package RelayPDF in C# / .NET 8 when you want async HttpClient helpers instead of raw HTTP. Request JSON field names match REST; methods are PascalCase. The package README is the full method and error reference.
The official .NET SDK uses HttpClient and System.Text.Json. Field names in request bodies match REST. Methods are async PascalCase.
Installation
Targets net8.0. Install with `dotnet add package RelayPDF`. Source is github.com/timspell1/relaypdf-dotnet.
dotnet add package RelayPDFQuick start
apiKey is required. Load RELAYPDF_API_KEY from the environment.
using RelayPDF;
var client = new RelayPDF.RelayPDF(Environment.GetEnvironmentVariable("RELAYPDF_API_KEY")!);
var pdf = await client.Pdf.FromHtmlAsync(
"<h1>Invoice #1042</h1><p>Total: $1,200.00</p>",
extra: new() { ["filename"] = "invoice.pdf" }
);
pdf.Save("invoice.pdf");Errors and webhooks
Failures throw RelayPDFException. Webhook.Verify checks RelayPDF-Signature against the raw body.
try {
await client.Pdf.FromUrlAsync("https://example.com");
} catch (RelayPDFException err) {
Console.WriteLine($"{err.Status} {err.Code} {err.Message} {err.RetryAfter}");
}
var ok = Webhook.Verify(
Environment.GetEnvironmentVariable("RELAYPDF_WEBHOOK_SECRET")!,
rawBody,
signatureHeader
);SDK reference
Pass extra dictionaries for REST camelCase fields. File bytes are Base64-encoded automatically.
| Method | HTTP | Description |
|---|---|---|
| HealthAsync / AccountAsync | GET /health · /v1/account | Liveness and wallet |
| Pdf.FromHtmlAsync / FromUrlAsync / FromMarkdownAsync / FromTemplateAsync | POST /v1/pdf | Generate PDF |
| Pdf.MergeAsync / ExtractAsync / ProtectAsync / … / FormFillAsync | POST /v1/pdf/* | PDF tools |
| Images / Convert / Templates / Barcodes / Zip / Jobs / Files / Webhooks | matching REST | Same surface as Node |
| Webhook.Verify | RelayPDF-Signature | HMAC-SHA256 |
Document platform release support
The release adds ocr, pdfa, crop, resize, repair, optimize, attachments, extract-images, redact, compress, image-convert, and email processing. Every official SDK exposes process / ProcessAsync plus files.upload, files.delete, billingUsage / billing_usage, and billingLimits / billing_limits. Availability requires the matching released package. Older published versions may not contain these methods.
See /docs/files, /docs/billing, and each operation guide for field names and limits.
For safe retries, use URL or async output with Idempotency-Key. Per-request caps use X-RelayPDF-Max-Charge-Microdollars (integer millionths of USD). Billing APIs preserve microdollar precision; legacy account millicent fields are not the complete precise balance.
Native OCR with a per-job cap
Requires RelayPDF 0.1.2 or a compatible newer release. Replace the example URL with your own publicly accessible scan. The 40000-microdollar cap authorizes at most $0.04; it is not a price estimate. Reuse the idempotency key only for retries of the same request.
client.Files.UploadAsync / DeleteAsync; client.BillingUsageAsync / BillingLimitsAsync
Files and billing APIs do not require a separate client. See /docs/files, /docs/billing, and /docs/idempotency for ownership, precision, and retry behavior.
using var client = new global::RelayPDF.RelayPDF(
Environment.GetEnvironmentVariable(
"RELAYPDF_API_KEY")!
);
var job = await client.ProcessAsync("ocr", new() {
["url"] = "https://example.com/scan.pdf",
["response"] = "async",
}, new() {
["idempotencyKey"] = "scan-001",
["maxChargeMicrodollars"] = 40000,
});