### StartTotpEnrollmentAsync usage example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/user-resource.md Example of starting TOTP enrollment with a device label and showing the secret and provisioning URI to the user. ```csharp var enrollment = await client.Users.StartTotpEnrollmentAsync(new StartTotpEnrollmentRequest { Label = "My phone" }); // show enrollment.Secret / enrollment.ProvisioningUri to the user ``` -------------------------------- ### POST /v1/signers/certificate/start request example Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example HTTP request for starting certificate signing. Requires signer access code in both query and body. The body is JSON with the signer-access-code field. ```http POST /v1/signers/certificate/start?signer-access-code=access-code Content-Type: application/json { "signer-access-code": "access-code" } ``` -------------------------------- ### Certificate signature workflow example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/signing-resource.md Example showing the complete certificate signature workflow: start the certificate signature, sign the token with the Web PKI library, then complete the signature. ```csharp var started = await client.Signing.StartCertificateAsync(accessCode); // ... sign started.Token with the Web PKI library ... await client.Signing.CompleteCertificateAsync(accessCode, signedToken); ``` -------------------------------- ### POST /v1/users/self/mfa/totp - Example Request Payload Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example request payload for starting authenticator enrollment. Includes a label for the method. ```json { "label": "My phone" } ``` -------------------------------- ### POST /v1/users/self/mfa/totp - Example Success Payload Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example success response payload when enrollment starts. Contains the id, secret, and provisioning URI. ```json { "status": 200, "message": "", "data": { "id": "a1b2c3d4e5f60718293a4b5c6d7e8f90", "secret": "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ", "provisioning_uri": "otpauth://totp/user%40example.com?issuer=Assinafy&secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ" } } ``` -------------------------------- ### Create signer example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/signer-resource.md Example of creating a signer with FullName, Email, and GovernmentId. ```csharp var signer = await client.Signers.CreateAsync(new CreateSignerRequest { FullName = "Ana Souza", Email = "ana@example.com", GovernmentId = "12345678900", }); ``` -------------------------------- ### GET /v1/accounts/{accountId}/theme - Example Payload Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example response payload for the GET theme endpoint, showing account name, primary and secondary colors, and logo URL. ```json { "status": 200, "message": "", "data": { "account_name": "Account Name", "primary_color": "aabbcc", "secondary_color": "aabbcc", "logo": "https://api.assinafy.com.br/v1/accounts/1a/logo" } } ``` -------------------------------- ### GET /v1/oauth/userinfo example success response (JSON) Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example success response for GET /v1/oauth/userinfo. Shows nullable fields present only when corresponding scopes granted. ```json { "sub": "d6zqpbyog2v3xvxerwn8la94", "name": "Maria Silva", "email": "maria@example.com", "email_verified": true } ``` -------------------------------- ### GET /v1/users/self/notification-preferences example payload Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example response payload showing all nine notification preference keys set to true. ```json { "status": 200, "message": "", "data": { "DocumentCompleted": true, "SignerDeclined": true, "DocumentCancelled": true, "DocumentAboutToExpire": true, "DocumentExpired": true, "DocumentExpirationReset": true, "DocumentProcessingFailed": true, "TemplateProcessingFailed": true, "SignerWhatsappFailed": true } } ``` -------------------------------- ### GET /.well-known/oauth-protected-resource example success response (JSON) Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example success response for GET /.well-known/oauth-protected-resource. Shows resource, authorization_servers, scopes_supported, and bearer_methods_supported. ```json { "resource": "https://api.assinafy.com.br", "authorization_servers": ["https://auth.assinafy.com.br"], "scopes_supported": [ "documents:read", "documents:write", "templates:read", "templates:write", "account:read", "openid", "profile", "email" ], "bearer_methods_supported": ["header"] } ``` -------------------------------- ### DownloadAsync usage example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/signature-resource.md Example of downloading a signature image and saving it to a file. ```csharp var bytes = await client.Signatures.DownloadAsync(accessCode, SignatureImageTypes.Signature); await File.WriteAllBytesAsync("my-signature.png", bytes); ``` -------------------------------- ### FromConfig method usage example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/assinafy-client.md Example of using the FromConfig factory method with a dictionary built from configuration values. ```csharp using var client = AssinafyClient.FromConfig(new Dictionary { ["api_key"] = configuration["Assinafy:ApiKey"], ["account_id"] = configuration["Assinafy:AccountId"], }); ``` -------------------------------- ### Login example with MFA handling Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/authentication-resource.md Example of calling LoginAsync and handling the MFA token or creating a new client with the access token. ```csharp var login = await client.Authentication.LoginAsync(new LoginRequest { Email = "owner@example.com", Password = "secret", }); if (login.MfaToken is not null) { // forward to the two-factor challenge screen; verify with VerifyMfaAsync } else { using var userClient = new AssinafyClient(new AssinafyClientOptions { Token = login.AccessToken }); } ``` -------------------------------- ### DownloadAsync usage example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/document-resource.md Example of downloading a PAdES artifact and saving it to a file. Uses the DocumentArtifactNames.Pades constant. ```csharp var pdf = await client.Documents.DownloadAsync(documentId, DocumentArtifactNames.Pades); await File.WriteAllBytesAsync("signed-pades.pdf", pdf); ``` -------------------------------- ### GET /.well-known/oauth-protected-resource example request (HTTP) Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example HTTP request for fetching protected resource metadata using OAuthResource.GetProtectedResourceMetadataAsync. ```http GET /.well-known/oauth-protected-resource ``` -------------------------------- ### GET /v1/users/api-keys Example Payload Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example payload for the GET /v1/users/api-keys success response, showing a masked API key. ```json { "status": 200, "message": "", "data": { "api_key": "example-api-key" } } ``` -------------------------------- ### GetThemeAsync usage example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/account-resource.md Example of retrieving the account theme and printing the account name and primary color. ```csharp var theme = await client.Accounts.GetThemeAsync(); Console.WriteLine($"{theme.AccountName}: #{theme.PrimaryColor}"); ``` -------------------------------- ### CreateAsync usage example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/template-resource.md Example of creating a template from a local PDF file, specifying a display name. ```csharp await using var pdf = File.OpenRead("nda-template.pdf"); var template = await client.Templates.CreateAsync(pdf, "nda-template.pdf", name: "NDA Template"); ``` -------------------------------- ### StartIdentityVerificationAsync usage example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/signing-resource.md Starts an identity verification session with explicit consent and redirects to the hosted capture URL. The URL should be opened as-is including fragment; never log or persist it. ```csharp var session = await client.Signing.StartIdentityVerificationAsync(accessCode, consent: true); return Redirect(session.Url); ``` -------------------------------- ### GET /v1/accounts - Example Payload Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example success payload for listing accounts, containing an array with one account object. ```json { "status": 200, "message": "", "data": [ { "resource": "account", "id": "6401df46d6a6b0c692d9ec49", "name": "Acme Inc.", "primary_color": "aabbcc", "secondary_color": "112233", "notification_sender_type": "User", "roles": [ "owner" ], "is_delete_allowed": true, "created_at": "2026-06-03T03:54:16Z" } ] } ``` -------------------------------- ### Create method usage example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/assinafy-client.md Example of using the Create factory method with a configure action to set the BaseUrl to the sandbox endpoint. ```csharp using var client = AssinafyClient.Create(apiKey, accountId, options => options.BaseUrl = "https://sandbox.assinafy.com.br/v1"); ``` -------------------------------- ### GET /v1/oauth/userinfo example request (HTTP) Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example HTTP request for retrieving user info using OAuthResource.GetUserInfoAsync. Requires bearer token with openid scope. ```http GET /v1/oauth/userinfo Authorization: Bearer example-access-token ``` -------------------------------- ### POST /v1/signers/certificate/start success response Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example success response for the start certificate endpoint. Returns a JSON envelope with a Web PKI operation token in data.token. ```json { "status": 200, "message": "", "data": { "token": "web-pki-token" } } ``` -------------------------------- ### UploadAsync usage example with reuse Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/signature-resource.md Example of uploading an initial image with reuse enabled, using the SignatureImageTypes.Initial type. ```csharp await using var initial = File.OpenRead("initial.png"); await client.Signatures.UploadAsync(initial, accessCode, reuse: true, type: SignatureImageTypes.Initial); ``` -------------------------------- ### GetSigningProgressAsync usage example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/document-resource.md Example of calling GetSigningProgressAsync and printing the progress. Shows how to access Signed, Total, and Percentage properties. ```csharp var progress = await client.Documents.GetSigningProgressAsync(documentId); Console.WriteLine($"{progress.Signed}/{progress.Total} signed ({progress.Percentage}%)"); ``` -------------------------------- ### Create tag example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/tag-resource.md Example of creating a tag with name 'urgent' and color 'ff0000'. The color is provided without a '#' prefix. ```csharp var tag = await client.Tags.CreateAsync(new CreateTagRequest { Name = "urgent", Color = "ff0000" }); ``` -------------------------------- ### GetSelfAsync usage example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/user-resource.md Example of calling GetSelfAsync and printing the user's name and email. ```csharp var me = await client.Users.GetSelfAsync(); Console.WriteLine($"{me.Name} <{me.Email}>"); ``` -------------------------------- ### DeclineAsync usage example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/signing-resource.md Example of calling DeclineAsync with a decline reason. ```csharp await client.Signing.DeclineAsync(documentId, assignmentId, accessCode, "I no longer agree to these terms"); ``` -------------------------------- ### POST /v1/login Example Payload Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example request payload for the login endpoint. ```json { "email": "user@example.com", "password": "password" } ``` -------------------------------- ### POST /v1/accounts - Example Payload Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example success payload for creating an account, containing the created account object. ```json { "status": 200, "message": "", "data": { "resource": "account", "id": "6401df46d6a6b0c692d9ec49", "name": "Acme Inc.", "primary_color": "aabbcc", "secondary_color": "112233", "notification_sender_type": "User", "roles": [ "owner" ], "is_delete_allowed": true, "created_at": "2026-06-03T03:54:16Z" } } ``` -------------------------------- ### Login error handling example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/authentication-resource.md Example of catching ApiException for invalid credentials (401) and invalid request (400). ```csharp try { var login = await client.Authentication.LoginAsync(request); Console.WriteLine(login.AccessToken); } catch (ApiException ex) when (ex.StatusCode == 401) { // Invalid credentials. } catch (ApiException ex) when (ex.StatusCode == 400) { // Invalid request; ex.Details carries structured field errors. } ``` -------------------------------- ### UpdateAsync usage example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/template-resource.md Example of updating a template's name and message. ```csharp var updated = await client.Templates.UpdateAsync(templateId, new UpdateTemplateRequest { Name = "NDA v2", Message = "Please sign the attached NDA" }); ``` -------------------------------- ### CreateApiKeyAsync usage example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/authentication-resource.md Example of calling CreateApiKeyAsync with a password and printing the new API key. The key cannot be read again, so it must be stored immediately. ```csharp var key = await client.Authentication.CreateApiKeyAsync(new CreateApiKeyRequest { Password = password }); Console.WriteLine($"New API key: {key.ApiKey}"); // store it now; it cannot be read again ``` -------------------------------- ### GetAsync usage example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/signing-resource.md Example of calling GetAsync and iterating over the signers in the returned assignment to print their full name and completion status. ```csharp var doc = await client.Signing.GetAsync(accessCode); foreach (var signer in doc.Assignment!.Signers) Console.WriteLine($"{signer.FullName}: {signer.Completed}"); ``` -------------------------------- ### ListMfaMethodsAsync usage example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/user-resource.md Example of calling ListMfaMethodsAsync and printing the number of methods and recovery codes remaining. ```csharp var mfa = await client.Users.ListMfaMethodsAsync(); Console.WriteLine($"{mfa.Methods.Count} methods, {mfa.RecoveryCodesRemaining} recovery codes left"); ``` -------------------------------- ### CreateAsync usage example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/field-resource.md Example of creating a field definition with Type 'cpf' and Name 'Signer CPF', with IsRequired set to true. ```csharp var field = await client.Fields.CreateAsync(new CreateFieldDefinitionRequest { Type = "cpf", Name = "Signer CPF", IsRequired = true, }); ``` -------------------------------- ### POST /v1/accounts/{accountId}/tags - Example Request Payload Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example JSON payload for creating a tag with name and color. ```json { "name": "Contracts", "color": "ff8800" } ``` -------------------------------- ### GetApiKeyAsync usage example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/authentication-resource.md Example of calling GetApiKeyAsync and printing the masked API key or 'no key' if null. ```csharp var key = await client.Authentication.GetApiKeyAsync(); Console.WriteLine(key.ApiKey ?? "no key"); ``` -------------------------------- ### UploadLogoAsync usage example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/account-resource.md Example of uploading a logo from a file stream. The stream is opened with await using and the method is called with the file name. ```csharp await using var logo = File.OpenRead("logo.png"); await client.Accounts.UploadLogoAsync(logo, "logo.png"); ``` -------------------------------- ### ListAsync pagination usage example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/document-resource.md Example of listing documents with filters and paginating through all pages using the Meta information from the response. ```csharp var page = await client.Documents.ListAsync(new Dictionary { ["status"] = "pending_signature", ["sort"] = "-created_at", ["per-page"] = "50", }); while (page.Meta is { CurrentPage: int current, LastPage: int last } && current < last) { // process page.Data page = await client.Documents.ListAsync(new Dictionary { ["page"] = (current + 1).ToString() }); } ``` -------------------------------- ### List tags example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/tag-resource.md Example of listing tags with a search filter for 'contract'. Uses the client's Tags property. ```csharp var tags = await client.Tags.ListAsync(search: "contract"); ``` -------------------------------- ### Create AssinafyClient with options Source: https://github.com/assinafy/csharp-sdk/blob/main/README.en.md Use this snippet to create a client with the main constructor, reading API key and account ID from environment variables. Set BaseUrl to the sandbox endpoint for testing; omit it for production. Timeout defaults to 30 seconds. ```csharp using Assinafy.Sdk; using Assinafy.Sdk.Models; using var client = new AssinafyClient(new AssinafyClientOptions { ApiKey = Environment.GetEnvironmentVariable("ASSINAFY_API_KEY"), AccountId = Environment.GetEnvironmentVariable("ASSINAFY_ACCOUNT_ID"), BaseUrl = "https://sandbox.assinafy.com.br/v1", // omit for production Timeout = TimeSpan.FromSeconds(30), // default }); ``` -------------------------------- ### GET /v1/users/self Example Payload Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example payload for the GET /v1/users/self success response, showing a user profile with fields like id, name, email, and timestamps. ```json { "status": 200, "message": "", "data": { "id": "bgjazeo5r9v2lq7l36dx48np", "name": "John Smith", "email": "example@example.com", "telephone": "17989206641", "government_id": "15774136604", "is_email_verified": false, "has_accepted_terms": true, "created_at": "2023-03-03T11:51:34Z", "to_be_deleted_at": "2026-08-19T12:00:00Z" } } ``` -------------------------------- ### Create AssinafyClient using shorthand methods Source: https://github.com/assinafy/csharp-sdk/blob/main/README.en.md Two shorthand creation methods: Create with apiKey and accountId, and FromConfig with a dictionary of configuration keys. FromConfig accepts snake_case or camelCase keys for api_key, account_id, token/access_token, and base_url. ```csharp using var fromArgs = AssinafyClient.Create(apiKey, accountId); using var fromSettings = AssinafyClient.FromConfig(new Dictionary { ["api_key"] = configuration["Assinafy:ApiKey"], ["account_id"] = configuration["Assinafy:AccountId"], }); ``` -------------------------------- ### PUT /v1/signers/documents/sign-multiple - Example Payload Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example request payload for signing multiple documents. Contains the document IDs to sign. ```json { "document_ids": [ "documentid1", "documentid2" ] } ``` -------------------------------- ### POST /v1/signers/certificate/complete request example Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example HTTP request for completing certificate signing. Requires signer access code and the browser-signed token in the body. ```http POST /v1/signers/certificate/complete?signer-access-code=access-code Content-Type: application/json { "signer-access-code": "access-code", "token": "signed-web-pki-token" } ``` -------------------------------- ### GET signers example payload Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example success response payload for the list signers endpoint. ```json { "status": 200, "message": "", "data": [ { "resource": "signer", "id": "62d6ee35c7741ca4006b9e11", "full_name": "John Signer", "email": "john@example.com", "whatsapp_phone_number": "+5548999990000", "government_id": "39053344705", "has_accepted_terms": false } ] } ``` -------------------------------- ### POST /v1/accounts - Example Payload Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example request body for creating an account with name 'Acme Inc.' and notification_sender_type 'Account'. ```json { "name": "Acme Inc.", "notification_sender_type": "Account" } ``` -------------------------------- ### UploadAsync usage example without reuse Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/signature-resource.md Example of uploading a signature image from a file using the UploadAsync overload without reuse. ```csharp await using var sig = File.OpenRead("signature.png"); await client.Signatures.UploadAsync(sig, accessCode); ``` -------------------------------- ### Create AssinafyClient from configuration dictionary Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/configuration.md Builds a client from a dictionary of configuration keys. Accepted keys include api_key/apiKey, account_id/accountId, token/access_token/accessToken, and base_url/baseUrl. Keys are matched case-sensitively; the first non-blank value wins. ```csharp var client = AssinafyClient.FromConfig(new Dictionary { ["api_key"] = configuration["Assinafy:ApiKey"], ["account_id"] = configuration["Assinafy:AccountId"], ["base_url"] = configuration["Assinafy:BaseUrl"], }); ``` -------------------------------- ### POST /v1/signers/certificate/complete error response example Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example error response for the complete certificate endpoint. Shows a 400 error with an invalid request message. ```json { "status": 400, "message": "Invalid request", "data": {} } ``` -------------------------------- ### POST /v1/login Example Success Response Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example success response payload for the login endpoint, containing an access token, user details, and account information. ```json { "status": 200, "message": "", "data": { "access_token": "example-access-token", "user": { "id": "bgjazeo5r9v2lq7l36dx48np", "name": "John Smith", "email": "example@example.com", "telephone": "17989206641", "government_id": "15774136604", "is_email_verified": false, "has_accepted_terms": true, "created_at": "2023-03-03T11:51:34Z", "to_be_deleted_at": "2026-08-19T12:00:00Z" }, "accounts": [ { "id": "6401df46d6a6b0c692d9ec49", "name": "JS", "roles": [ "owner" ], "is_delete_allowed": true, "created_at": "2023-03-03T11:51:34Z" } ] } } ``` -------------------------------- ### CreatePkcePair() usage example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/oauth-resource.md Shows how to create a PKCE pair and store the verifier in the session. The verifier is kept server-side; the challenge is sent to the authorization endpoint. ```csharp var pkce = OAuthResource.CreatePkcePair(); HttpContext.Session.SetString("assinafy_verifier", pkce.CodeVerifier); ``` -------------------------------- ### SocialLoginAsync usage example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/authentication-resource.md Example call to SocialLoginAsync using a Google ID token and accepting terms. Returns a Task. ```csharp var login = await client.Authentication.SocialLoginAsync(new SocialLoginRequest { Provider = "google", Token = googleIdToken, HasAcceptedTerms = true, }); ``` -------------------------------- ### AssinafyClient.Create(string apiKey, string accountId, Action? configure = null) Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/configuration.md Builds an API-key client from two strings and an optional mutation callback. Throws ArgumentException for blank apiKey/accountId. ```APIDOC ## AssinafyClient.Create(string apiKey, string accountId, Action? configure = null) ### Description Builds an API-key client from two strings and an optional mutation callback. Throws ArgumentException for blank apiKey/accountId. ### Method Create ### Parameters - **apiKey** (string) - Required - The API key. - **accountId** (string) - Required - The account ID. - **configure** (Action?) - Optional - Mutation callback for client options. ### Request Example ```csharp var client = AssinafyClient.Create(apiKey, accountId, options => { options.BaseUrl = "https://sandbox.assinafy.com.br/v1"; }); ``` ### Response Returns an AssinafyClient instance. ``` -------------------------------- ### GET /v1/field-types - Success Response Example Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example success response for the field-types endpoint, showing a single field type entry for CPF. ```json { "status": 200, "message": "", "data": [ { "type": "cpf", "name": "CPF" } ] } ``` -------------------------------- ### Create(string apiKey, string accountId, Action? configure = null) Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/assinafy-client.md Convenience factory that creates an API-key client and optionally tweaks options. Throws ArgumentException when apiKey or accountId is null/whitespace. ```APIDOC ## Create(string apiKey, string accountId, Action? configure = null) ### Description Convenience factory that creates an API-key client and optionally tweaks options. Throws `ArgumentException` when `apiKey` or `accountId` is null/whitespace. ### Method Static factory method ### Signature ```csharp public static AssinafyClient Create( string apiKey, string accountId, Action? configure = null) ``` ### Parameters - **apiKey** (string) - Required - The API key for authentication. - **accountId** (string) - Required - The account identifier. - **configure** (Action?) - Optional - Action to configure client options. ### Exceptions - **ArgumentException** - Thrown when `apiKey` or `accountId` is null or whitespace. ### Example ```csharp using var client = AssinafyClient.Create(apiKey, accountId, options => options.BaseUrl = "https://sandbox.assinafy.com.br/v1"); ``` ``` -------------------------------- ### GET /v1/users/self/mfa - Example Payload Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example success response payload for listing enrolled two-factor methods. Shows a single TOTP method and 8 remaining recovery codes. ```json { "status": 200, "message": "", "data": { "methods": [ { "id": "a1b2c3d4e5f60718293a4b5c6d7e8f90", "type": "Totp", "label": "My phone", "confirmed_at": "2026-09-09T14:21:03Z", "last_used_at": "2026-09-09T18:02:44Z" } ], "recovery_codes_remaining": 8 } } ``` -------------------------------- ### Create AssinafyClient with API key and account ID Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/configuration.md Builds an API-key client using AssinafyClient.Create. Throws ArgumentException for blank apiKey or accountId. The configure callback can set options like BaseUrl. ```csharp var client = AssinafyClient.Create(apiKey, accountId, options => { options.BaseUrl = "https://sandbox.assinafy.com.br/v1"; }); ``` -------------------------------- ### List Fields - Example Payload Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example payload for the success response of GET /v1/accounts/{accountId}/fields. Shows a single field definition with properties such as id, name, type, and flags. ```json { "status": 200, "message": "", "data": [ { "resource": "field", "id": "6152120297080d55bdd13197", "name": "Signature", "type": "signature", "regex": "string", "is_pre_defined": false, "is_active": false, "is_required": false, "is_standard": false, "is_read_only": false, "is_visible": false } ] } ``` -------------------------------- ### Install Assinafy.Sdk NuGet package Source: https://github.com/assinafy/csharp-sdk/blob/main/README.en.md Adds the Assinafy.Sdk package version 2.6.1 to the project. Requires a runtime compatible with net8.0, net9.0, or net10.0. ```bash dotnet add package Assinafy.Sdk --version 2.6.1 ``` -------------------------------- ### Run live sandbox tests with environment variables Source: https://github.com/assinafy/csharp-sdk/blob/main/README.en.md Runs live tests against the sandbox base URL. Requires ASSINAFY_API_KEY, ASSINAFY_ACCOUNT_ID, and ASSINAFY_BASE_URL set to the sandbox URL; the suite refuses any other base URL. Optional ASSINAFY_TEST_EMAIL_PRIMARY and ASSINAFY_TEST_EMAIL_SECONDARY override reserved example.com addresses. ```bash ASSINAFY_API_KEY=... \ ASSINAFY_ACCOUNT_ID=... \ ASSINAFY_BASE_URL=https://sandbox.assinafy.com.br/v1 \ dotnet test --project tests/Assinafy.Sdk.Tests/Assinafy.Sdk.Tests.csproj \ --framework net10.0 -- --filter-trait "Category=Live" ``` -------------------------------- ### PUT /v1/authentication/change-password example payload Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example request payload for changing the password. Uses the example values from the schema. ```json { "email": "user@example.com", "password": "X3$_!456aTa", "new_password": "X3$_!456aT" } ``` -------------------------------- ### End-to-end signature request (C#) Source: https://github.com/assinafy/csharp-sdk/blob/main/README.en.md Shows the full workflow: upload a PDF, wait for metadata_ready, create a signer, create an assignment to send invitations, poll until certificated, then download the signed PDF. Requires ASSINAFY_API_KEY and ASSINAFY_ACCOUNT_ID environment variables. Polling is shown for clarity; production should use the document_ready webhook. ```csharp using Assinafy.Sdk; using Assinafy.Sdk.Models; using var client = new AssinafyClient(new AssinafyClientOptions { ApiKey = Environment.GetEnvironmentVariable("ASSINAFY_API_KEY"), AccountId = Environment.GetEnvironmentVariable("ASSINAFY_ACCOUNT_ID"), }); // 1–2. Upload and wait for the document to be ready. await using var pdf = File.OpenRead("contract.pdf"); var document = await client.Documents.UploadAsync(pdf, "contract.pdf"); document = await client.Documents.WaitUntilReadyAsync(document.Id); // 3. Create the signer. var signer = await client.Signers.CreateAsync(new CreateSignerRequest { FullName = "John Doe", Email = "john@example.com", }); // 4. Request the signature. This sends the invitation. var assignment = await client.Assignments.CreateAsync(document.Id, new CreateAssignmentRequest { Method = AssignmentMethods.Virtual, Message = "Please review and sign.", Signers = [ new SignerRef { Id = signer.Id, VerificationMethod = SignerChannels.Email, NotificationMethods = [SignerChannels.Email], }, ], }); // assignment.SigningUrls carries a per-signer link if you would rather deliver it yourself. // 5. Wait for signing to finish, then download the certified PDF. using var deadline = new CancellationTokenSource(TimeSpan.FromHours(1)); DocumentDetails completed; do { await Task.Delay(TimeSpan.FromSeconds(10), deadline.Token); completed = await client.Documents.GetAsync(document.Id, deadline.Token); } while (!string.Equals(completed.Status, "certificated", StringComparison.OrdinalIgnoreCase)); var certified = await client.Documents.DownloadAsync(document.Id); await File.WriteAllBytesAsync("contract-signed.pdf", certified); ``` -------------------------------- ### POST /v1/accounts/{accountId}/fields/{fieldId}/validate - Example Payload Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example request body for validating a field value. Shows a CPF example. ```json { "value": "400.676.228-36" } ``` -------------------------------- ### Create PKCE pair and build authorization URL Source: https://github.com/assinafy/csharp-sdk/blob/main/README.en.md Creates a new PKCE pair and state per attempt, stores them in the session, and builds the authorization URL. PKCE is mandatory for all applications. Redirect URIs must be https and matched exactly. Use a full page navigation, not AJAX. ```csharp using Assinafy.Sdk.Models; using Assinafy.Sdk.Resources; var pkce = OAuthResource.CreatePkcePair(); // 256-bit verifier + its S256 challenge var state = OAuthResource.CreateState(); // CSRF protection HttpContext.Session.SetString("assinafy_verifier", pkce.CodeVerifier); HttpContext.Session.SetString("assinafy_state", state); var authorizationUrl = OAuthResource.BuildAuthorizationUrl(new OAuthAuthorizationRequest { ClientId = clientId, RedirectUri = "https://myapp.example.com/oauth/callback", Scopes = [ OAuthScopes.DocumentsRead, OAuthScopes.DocumentsWrite, OAuthScopes.OfflineAccess, // ask for this to receive a refresh token ], State = state, CodeChallenge = pkce.CodeChallenge, }); return Redirect(authorizationUrl.ToString()); // a full page navigation, never an AJAX call ``` -------------------------------- ### FromConfig(IDictionary config) Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/assinafy-client.md Builds a client from a dictionary of configuration keys. Accepts snake_case and camelCase variants; when no API key is present, token/access_token/accessToken is used as the Bearer credential; optional base_url/baseUrl sets the base URL. ```APIDOC ## FromConfig(IDictionary config) ### Description Builds a client from a dictionary of configuration keys. Accepts snake_case (`api_key`, `account_id`) and camelCase (`apiKey`, `accountId`) variants; when no API key is present, `token`/`access_token`/`accessToken` is used as the Bearer credential; an optional `base_url`/`baseUrl` sets the base URL. ### Method Static factory method ### Signature ```csharp public static AssinafyClient FromConfig(IDictionary config) ``` ### Parameters - **config** (IDictionary) - Required - Dictionary of configuration keys. ### Exceptions - **ArgumentNullException** - Thrown when `config` is null. ### Example ```csharp using var client = AssinafyClient.FromConfig(new Dictionary { ["api_key"] = configuration["Assinafy:ApiKey"], ["account_id"] = configuration["Assinafy:AccountId"], }); ``` ``` -------------------------------- ### PUT /v1/authentication/reset-password Example Payload Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example request payload for the reset-password endpoint. ```json { "email": "user@example.com", "token": "example-reset-token", "new_password": "N3w_p4ssw0rd" } ``` -------------------------------- ### AssinafyClient.FromConfig Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Creates an AssinafyClient from a configuration object. Accepts api_key/apiKey, account_id/accountId, token/access_token/accessToken, and base_url/baseUrl. ```APIDOC ## AssinafyClient.FromConfig ### Description Creates an AssinafyClient from a configuration object. Accepts api_key/apiKey, account_id/accountId, token/access_token/accessToken, and base_url/baseUrl. ### Method FromConfig ### Parameters - **config** (object) - Required - Configuration object with keys: api_key/apiKey, account_id/accountId, token/access_token/accessToken, base_url/baseUrl. ``` -------------------------------- ### PUT /v1/authentication/request-password-reset Example Payload Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example request payload for the request-password-reset endpoint. ```json { "email": "user@example.com" } ``` -------------------------------- ### BuildAuthorizationUrl() usage example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/oauth-resource.md Shows how to build the authorization URL with required fields and redirect the browser. Requires ClientId, RedirectUri, Scopes, State, and CodeChallenge; Resource, Nonce, and AuthorizationEndpoint are optional. ```csharp var url = OAuthResource.BuildAuthorizationUrl(new OAuthAuthorizationRequest { ClientId = clientId, RedirectUri = "https://myapp.example.com/oauth/callback", Scopes = [OAuthScopes.DocumentsRead, OAuthScopes.DocumentsWrite, OAuthScopes.OfflineAccess], State = state, CodeChallenge = pkce.CodeChallenge, }); return Redirect(url.ToString()); ``` -------------------------------- ### Users.StartTotpEnrollmentAsync Source: https://github.com/assinafy/csharp-sdk/blob/main/README.en.md Starts the enrollment of a new TOTP authenticator app. ```APIDOC ## Users.StartTotpEnrollmentAsync ### Description Starts the enrollment of a new TOTP authenticator app. ### Method StartTotpEnrollmentAsync ### Endpoint client.Users.StartTotpEnrollmentAsync(StartTotpEnrollmentRequest request) ### Parameters #### Request Body - **Label** (string) - Required - A label for the authenticator method (e.g., "My phone"). ### Request Example ```csharp var enrollment = await client.Users.StartTotpEnrollmentAsync(new StartTotpEnrollmentRequest { Label = "My phone" }); ``` ### Response #### Success Response - **enrollment** (TotpEnrollment) - Contains the enrollment ID and a provisioning URI for QR code rendering. #### Response Example ```csharp // Render enrollment.ProvisioningUri as a QR code ``` ``` -------------------------------- ### POST /v1/authentication/social-login - Example payload Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example request payload for the social login endpoint. ```json { "provider": "google", "token": "example-provider-token", "has_accepted_terms": true } ``` -------------------------------- ### ListDispatchesAsync usage example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/webhook-resource.md Example of calling ListDispatchesAsync with a filter for event 'document_ready' and delivered=false. ```csharp var page = await client.Webhooks.ListDispatchesAsync(new ListDispatchesParams { Event = "document_ready", Delivered = false, }); ``` -------------------------------- ### StartTotpEnrollmentRequest class Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/types-auth-user.md Accepted by Users.StartTotpEnrollmentAsync. Contains an optional label for the enrollment. ```csharp public sealed class StartTotpEnrollmentRequest { public string? Label { get; set; } } ``` -------------------------------- ### POST /v1/auth/link-social-login - Example payload Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example request payload for linking a social login provider. ```json { "provider": "google", "token": "string" } ``` -------------------------------- ### StartTotpEnrollmentRequest Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/types-auth-user.md Request model for starting TOTP enrollment. Accepted by Users.StartTotpEnrollmentAsync. ```APIDOC ## StartTotpEnrollmentRequest ### Description Request model for starting TOTP enrollment. ### Properties - **label** (string?) - Optional label for the enrollment. ### Accepted By - `Users.StartTotpEnrollmentAsync` ``` -------------------------------- ### PUT send-token success example payload Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example success response payload for the send-token endpoint. ```json { "status": 200, "message": "", "data": { "document": { "resource": "document", "id": "a1b2c3d4e5f6a7b8c9d0", "name": "Contract.pdf", "page_count": 3, "created_by": "Jane Doe" }, "channel": "email", "recipient": "signer@example.com" } } ``` -------------------------------- ### CreateFromTemplateAsync usage example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/document-resource.md Example of creating a document from a template. Opens an NDA PDF, creates a template, then creates a document with a signer bound to the first template role and sets the document name. ```csharp await using var pdf = File.OpenRead("nda.pdf"); var template = await client.Templates.CreateAsync(pdf, "nda.pdf"); var doc = await client.Documents.CreateFromTemplateAsync(template.Id, [new TemplateSigner { RoleId = template.Roles[0].Id, Id = signerId }], options: new CreateDocumentFromTemplateOptions { Name = "NDA — Acme" }); ``` -------------------------------- ### ChangePasswordAsync usage example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/authentication-resource.md Example of calling ChangePasswordAsync with a ChangePasswordRequest containing Email, Password, and NewPassword. ```csharp await client.Authentication.ChangePasswordAsync(new ChangePasswordRequest { Email = email, Password = current, NewPassword = next, }); ``` -------------------------------- ### SigningResource.StartCertificateAsync Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Starts an ICP-Brasil certificate-signing operation and returns its Web PKI token. Maps to POST /signers/certificate/start?signer-access-code={code}. Production-only deployed extension, absent from sandbox and published OpenAPI document. ```APIDOC ## POST /signers/certificate/start?signer-access-code={code} ### Description Production-only deployed extension: start an ICP-Brasil certificate-signing operation and return its Web PKI token. This route is absent from the sandbox and published OpenAPI document. ### Method POST ### Endpoint /signers/certificate/start?signer-access-code={code} ### Parameters #### Query Parameters - **signer-access-code** (string) - Required - The signer access code. ### Response #### Success Response (200) - **CertificateStartResult** - The Web PKI token. ``` -------------------------------- ### Error Response Example Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example of an error response. The SDK maps these to OAuthException with Error and ErrorDescription properties. ```json { "error": "invalid_grant", "error_description": "The authorization code has expired." } ``` -------------------------------- ### Signing.StartCertificateAsync Source: https://github.com/assinafy/csharp-sdk/blob/main/README.en.md Starts a digital-certificate signing operation. Requires a virtual assignment with DigitalCertificate verification method. ```APIDOC ## Signing.StartCertificateAsync ### Description Starts a digital-certificate signing operation. Requires a virtual assignment with DigitalCertificate verification method. ### Method POST ### Endpoint Signing.StartCertificateAsync ### Parameters #### Path Parameters - **signerAccessCode** (string) - Required - The per-assignment signer access code. ### Request Example ```csharp var operation = await client.Signing.StartCertificateAsync(signerAccessCode); ``` ### Response #### Success Response (200) - **Token** (string) - Token to send to the browser for Web PKI signing. ``` -------------------------------- ### PUT send-token example payload Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example request payload for sending a token via email to a signer. ```json { "channel": "email", "recipient": "signer@example.com" } ``` -------------------------------- ### Manage Templates with C# SDK Source: https://github.com/assinafy/csharp-sdk/blob/main/README.en.md Shows the full template lifecycle: create from a PDF, wait for processing, download a page image, list with search, update, instantiate a document from the template, and delete. Note that CreateAsync appends '.pdf' to the name if needed. ```csharp await using var file = File.OpenRead("nda.pdf"); var template = await client.Templates.CreateAsync(file, "nda.pdf", name: "Mutual NDA"); // Pages and roles appear once processing finishes. var ready = await client.Templates.GetAsync(template.Id); var pageImage = await client.Templates.DownloadPageAsync(ready.Id, ready.Pages[0].Id); var templates = await client.Templates.ListAsync(new Dictionary { ["search"] = "nda", }); await client.Templates.UpdateAsync(template.Id, new UpdateTemplateRequest { Name = "Mutual NDA v2", Message = "Please review and sign.", }); // Instantiate: bind existing signers to the template's roles. var fromTemplate = await client.Documents.CreateFromTemplateAsync( template.Id, [new TemplateSigner { RoleId = ready.Roles[0].Id, Id = signer.Id }], new CreateDocumentFromTemplateOptions { Name = "NDA — Acme", ExpiresAt = "2026-12-31T23:59:59Z", EditorFields = [new TemplateEditorField { FieldId = fieldId, Value = "Acme Inc." }], }); await client.Templates.DeleteAsync(template.Id); ``` -------------------------------- ### SetForDocumentAsync usage example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/tag-resource.md Example of calling SetForDocumentAsync to replace a document's tags with a single tag. ```csharp var tags = await client.Tags.SetForDocumentAsync(documentId, new[] { urgentTag.Id }); ``` -------------------------------- ### AssinafyClient.Create Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md API-key shorthand for creating an AssinafyClient with an API key and optional account ID. ```APIDOC ## AssinafyClient.Create ### Description API-key shorthand for creating an AssinafyClient with an API key and optional account ID. ### Method Create ### Parameters - **apiKey** (string) - Required - API key for authentication. - **accountId** (string) - Optional - Default account ID. - **configure** (Action) - Optional - Configuration delegate. ``` -------------------------------- ### POST /v1/verify - Example Payload Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example request payload for verifying the OTP code. Contains the verification code. ```json { "verification-code": "123456" } ``` -------------------------------- ### GetUserInfoAsync usage example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/oauth-resource.md Example of retrieving user info and printing the sub, name, and email claims. Throws OAuthException with insufficient_scope if the token lacks openid, and SerializationException if no sub claim is returned. ```csharp var who = await client.OAuth.GetUserInfoAsync(); Console.WriteLine($"{who.Sub} · {who.Name} · {who.Email}"); ``` -------------------------------- ### UpdateSubscriptionAsync usage example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/webhook-resource.md Example of updating the oldest webhook subscription with events, active flag, URL, and email. ```csharp var sub = await client.Webhooks.UpdateSubscriptionAsync(new UpdateWebhookSubscriptionRequest { Events = ["document_ready", "document_certified"], IsActive = true, Url = "https://myapp.example.com/webhooks/assinafy", Email = "ops@example.com", }); ``` -------------------------------- ### SignAsync usage example Source: https://github.com/assinafy/csharp-sdk/blob/main/_autodocs/api-reference/signing-resource.md Example of calling SignAsync with a single SignAssignmentValue containing item, field, page, and value. ```csharp await client.Signing.SignAsync(documentId, assignmentId, accessCode, [new SignAssignmentValue { ItemId = item.Id, FieldId = item.Field!.Id, PageId = pageId, Value = "value" }]); ``` -------------------------------- ### POST /v1/users/api-keys Example Request Payload Source: https://github.com/assinafy/csharp-sdk/blob/main/docs/API.md Example request payload for POST /v1/users/api-keys, containing the user's password. ```json { "password": "password" } ```