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
)
| Parameter | Description |
|---|
credentialID | ID of the credential registered with your token. Find it in the Dfns Dashboard under Settings > Service Accounts or Settings > Personal Access Tokens. |
privateKeyPEM | PEM-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:
| Domain | Description |
|---|
client.Wallets | Wallet creation, listing, and management |
client.Keys | Key management operations |
client.Policies | Policy rules and approvals |
client.Permissions | Access control and permissions |
client.Webhooks | Webhook configuration |
client.Signers | Signer management |
client.Staking | Staking operations |
client.Networks | Network information |
client.Exchanges | Exchange integrations |
client.FeeSponsors | Fee sponsorship |
client.Swaps | Token swap operations |
client.Agreements | Agreement management |
client.Allocations | Allocation management |
client.Auth | Authentication 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