Skip to main content

Request signing

All state-changing requests made to the Dfns API must be cryptographically signed. The SDK handles this automatically when you configure a signer.
For a detailed explanation of request signing and User Action Challenges, see Signing requests.

Authentication tokens

The client requires a valid AuthToken. See Required headers for details on obtaining tokens.

KeySigner configuration

The KeySigner signs challenges using your private key. It supports Ed25519, ECDSA (secp256k1, P-256), and RSA keys.
import "github.com/dfns/dfns-sdk-go/v2/signer"

keySigner, err := signer.NewKeySigner(
    "cr-...",                  // credential ID
    string(privateKeyPEM),     // PEM-encoded private key
)
ParameterDescription
credentialIDID of the credential registered with your token. Find it in the Dfns Dashboard under Settings > Service Accounts or Settings > Personal Access Tokens.
privateKeyPEMPEM-formatted private key associated with the public key you registered when creating your PAT or Service Account. Supports PKCS#8, PKCS#1 (RSA), and SEC 1 (EC) formats.

Available API domains

The client provides typed access to all Dfns API domains:
DomainDescription
client.WalletsWallet creation, listing, and management
client.KeysKey management operations
client.PoliciesPolicy rules and approvals
client.PermissionsAccess control and permissions
client.WebhooksWebhook configuration
client.SignersSigner management
client.StakingStaking operations
client.NetworksNetwork information
client.ExchangesExchange integrations
client.FeeSponsorsFee sponsorship
client.SwapsToken swap operations
client.AgreementsAgreement management
client.AllocationsAllocation management
client.AuthAuthentication helpers

Error handling

import (
    "errors"
    "fmt"

    dfns "github.com/dfns/dfns-sdk-go/v2"
)

_, err := client.Wallets.GetWallet(ctx, "invalid-wallet-id")
if err != nil {
    var apiErr *dfns.APIError
    if errors.As(err, &apiErr) {
        fmt.Printf("API Error (status %d): %s\n", apiErr.StatusCode, apiErr.Body)
    }
}
Last modified on March 13, 2026