---
name: dfns
description: Build on DFNS, the API-first wallets-as-a-service platform. Use when writing code that creates wallets or keys, transfers assets, signs or broadcasts transactions, sets up policies and approvals, authenticates service accounts or end users, or receives webhooks through the DFNS API or SDKs.
public: true
---

# DFNS

DFNS is an API-first wallets-as-a-service platform. Its REST API and SDKs create wallets and keys, move assets, sign and broadcast transactions, and enforce policies across many blockchain networks.

- Documentation index: https://docs.dfns.co/llms.txt
- Current API specification: https://docs.dfns.co/openapi.yaml (files under `/openapi-versions/` are archives of past releases)
- Any documentation page is available as Markdown by adding `.md` to its URL.

## Rules

- Use an official SDK rather than raw HTTP. The SDKs sign requests for you.
- Check every endpoint, field and enum value against `openapi.yaml`. Do not guess paths.
- Send requests to the API host of the organization's region. Paths in the docs are relative to it.
- Never use `appId` or the `X-DFNS-APPID` header. Applications are deprecated and the header has no effect.
- Never commit a service account's private key or token. Load them from a secrets manager or the environment.

| Region | API host | Networks |
| --- | --- | --- |
| Europe (default) | `https://api.dfns.io` | Mainnet and testnet |
| UAE | `https://api.uae.dfns.io` | Mainnet and testnet |
| Sandbox | `https://api.dfns-sandbox.io` | Testnet only |

## SDKs

Each SDK has one method per endpoint, named after the endpoint's `operationId` in `openapi.yaml` (camelCase in TypeScript and Java, snake_case in Python and Rust), grouped by domain: `dfns.wallets.transferAsset(...)`.

| SDK | Install |
| --- | --- |
| TypeScript (server) | `npm i @dfns/sdk @dfns/sdk-keysigner` |
| Python | `pip install dfns_sdk` |
| Go | `go get github.com/dfns/dfns-sdk-go/v2` |
| Rust | `cargo add dfns-sdk-rust` |
| Java | Built from source, see https://docs.dfns.co/sdks/backend/java/index.md |

Frontend SDKs (browser TypeScript, React Native, Flutter, Kotlin, Swift) handle passkey signing and login in web and mobile apps: https://docs.dfns.co/sdks/frontend/index.md

```ts
import { DfnsApiClient } from '@dfns/sdk'
import { AsymmetricKeySigner } from '@dfns/sdk-keysigner'

const dfns = new DfnsApiClient({
  baseUrl: 'https://api.dfns.io',
  orgId: 'or-...',
  authToken: process.env.DFNS_AUTH_TOKEN!,
  signer: new AsymmetricKeySigner({
    credId: 'cr-...',
    privateKey: process.env.DFNS_PRIVATE_KEY!,
  }),
})

const wallet = await dfns.wallets.createWallet({ body: { network: 'EthereumSepolia' } })
```

## Authentication

Every request carries `Authorization: Bearer <token>`. Get the token from one of:

- **Service account**, for backend code. Register a public key (RSA 2048 or larger, ECDSA P-256, or Ed25519, as a PEM `BEGIN PUBLIC KEY` block; OpenSSH format is rejected). The token is shown once. It is valid for 2 years by default, which is also the maximum, and requests fail with `401` once it expires. https://docs.dfns.co/guides/developers/service-account.md
- **Personal access token**, to automate actions tied to a specific user. https://docs.dfns.co/guides/developers/personal-access-token.md
- **User login** with a passkey, and **delegated login** for your own end users. https://docs.dfns.co/api-reference/auth/login-flows.md

## User Action Signing

Requests that change state (create a wallet, transfer, sign, create a policy, and so on) also need a single-use User Action token in the `X-DFNS-USERACTION` header. In `openapi.yaml` these operations list the `userActionSignature` security requirement.

1. `POST /auth/action/init` returns a challenge. Its `challengeIdentifier` expires after 15 minutes and works once.
2. Sign the challenge with one of the credentials in `allowCredentials`.
3. `POST /auth/action` with the signature returns the User Action token.
4. Send the original request with the token in `X-DFNS-USERACTION`.

The SDKs run these steps for you when the client has a signer. When the key is not on your backend (an end user's passkey, an external KMS), use the delegated client (`DfnsDelegatedApiClient` in TypeScript): each such method splits into `...Init`, which returns the challenge to sign, and `...Complete`, which takes the signed challenge. https://docs.dfns.co/guides/developers/signing-requests.md

## Core endpoints

| Task | Request | operationId |
| --- | --- | --- |
| Create a wallet | `POST /wallets` | `createWallet` |
| List wallets | `GET /wallets` | `listWallets` |
| Get a wallet | `GET /wallets/{walletId}` | `getWallet` |
| Get balances | `GET /wallets/{walletId}/assets` | `getWalletAssets` |
| Transfer an asset | `POST /wallets/{walletId}/transfers` | `transferAsset` |
| Get a transfer | `GET /wallets/{walletId}/transfers/{transferId}` | `getTransfer` |
| Sign and broadcast a transaction | `POST /wallets/{walletId}/transactions` | `signAndBroadcastTransaction` |
| Create a key | `POST /keys` | `createKey` |
| Generate a signature | `POST /keys/{keyId}/signatures` | `generateSignature` |
| Create a policy | `POST /v2/policies` | `createPolicy` |
| List approvals | `GET /v2/policy-approvals` | `listApprovals` |
| Approve or deny | `POST /v2/policy-approvals/{approvalId}/decisions` | `createApprovalDecision` |
| Assign a permission | `POST /permissions/{permissionId}/assignments` | `assignPermission` |
| Create a service account | `POST /auth/service-accounts` | `createServiceAccount` |
| Create a webhook | `POST /webhooks` | `createWebhook` |
| List webhook events | `GET /webhooks/{webhookId}/events` | `listWebhookEvents` |
| Register an end user | `POST /auth/registration/delegated` | `createDelegatedRegistrationChallenge` |
| Log in an end user | `POST /auth/login/delegated` | `delegatedLogin` |

## Decisions

- **Transfer Asset or Sign and Broadcast.** Use Transfer Asset to send native tokens and token assets (ERC-20, ERC-721, SPL and others). Use Sign and Broadcast for a transaction you build yourself, such as a contract call or a deployment. Policy amount limits are evaluated on Transfer Asset requests only; Sign and Broadcast and Generate Signature requests always trigger them. https://docs.dfns.co/core-concepts/policies.md
- **Organization-managed or delegated wallets.** Policies apply only to organization-managed wallets. Delegated wallets bypass the policy engine: the end user holds full signing authority. https://docs.dfns.co/advanced/delegated-wallets.md

## Policies

- Every activity is allowed by default. Policies add restrictions with a `Block` or `RequestApproval` action, and `Block` wins. There is no `Allow` action.
- To deny by default, create a catch-all policy with the `AlwaysTrigger` rule and the `Block` action, then permit specific cases as the policies page describes.
- Scope a policy with its filters, for example wallet tags. Wallets outside the scope keep the default allow-all behavior.
- `TransactionAmountLimit`, `TransactionAmountLimitNominal` and `TransactionRecipientWhitelist` only evaluate plain value transfers. When the amount or recipient cannot be inferred (a swap, a contract call, a raw signature request), they fail closed and trigger.

## Idempotency

Set `externalId` on transfers, transactions and signature requests. Re-sending the same request with the same `externalId` returns `200` with the entity created the first time. Re-using an `externalId` with a different body or wallet returns `409`. https://docs.dfns.co/api-reference/idempotency.md

## Webhooks

- Verify every event: the `X-DFNS-WEBHOOK-SIGNATURE` header is `sha256=<hex>`, an HMAC-SHA256 of the received payload keyed with the webhook secret.
- The secret is returned only once, in the Create Webhook response. To roll it, create a new webhook and delete the old one.
- DFNS keeps webhook events for 31 days.

https://docs.dfns.co/guides/developers/webhooks.md

## Rate limits

Limits apply per organization over a 60-second window. A `429` response carries `Retry-After`; back off for that many seconds. https://docs.dfns.co/api-reference/rate-limits.md
