Skip to main content
POST
/
allocations
Create Allocation
curl --request POST \
  --url https://api.dfns.io/allocations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --header 'X-DFNS-USERACTION: <api-key>' \
  --data '{
  "externalId": "ext-123",
  "sourceAsset": {
    "kind": "Erc20",
    "contract": "0x6b175474e89094c44da98b954eedeac495271d0f",
    "amount": "1000000000000000000"
  },
  "targetAsset": {
    "kind": "Erc20",
    "contract": "0x5d3a536e4d6dbd6114cc1ead35777bab948e3643",
    "amount": "32000000000000000000"
  },
  "slippageBps": 50,
  "walletId": "wa-4g991-s29to-9hrq4nbuto6ih33b",
  "protocol": "0fns"
}'
{
  "id": "allctn-6a3ku-bn8d7-8u5rs1oukojms7k8",
  "walletId": "wa-3l3cj-l8mq7-8q78f9nopq7f1qjv",
  "protocol": "0fns",
  "amount": {
    "kind": "Erc20",
    "contract": "0x0A7660979A67E4bC51E750C628C8479ff9F458aE",
    "amount": "1000000000",
    "metadata": {
      "network": "EthereumSepolia",
      "name": "0fns",
      "symbol": "0fnsSepolia",
      "decimals": 6,
      "tid": "erc20:0x0A7660979A67E4bC51E750C628C8479ff9F458aE"
    }
  },
  "rewards": {
    "kind": "Erc20",
    "contract": "0x0A7660979A67E4bC51E750C628C8479ff9F458aE",
    "amount": "5000000",
    "metadata": {
      "network": "EthereumSepolia",
      "name": "0fns",
      "symbol": "0fnsSepolia",
      "decimals": 6,
      "tid": "erc20:0x0A7660979A67E4bC51E750C628C9479ff9F458aE"
    }
  },
  "dateCreated": "2025-10-09T10:57:55.758Z"
}

Authentication

✅ Organization User (CustomerEmployee)
❌ Delegated User (EndUser)
✅ Service Account

Required Permissions

Allocations:Create: Always required.

Authorizations

Authorization
string
header
required

Bearer Token: Used to authenticate API requests. More details how to generate the token: Authentication flows

X-DFNS-USERACTION
string
header
required

User Action Signature: Used to sign the change-inducing API requests. More details how to generate the token: User Action Signing flows

Body

application/json

Request body for creating a allocation investment. Different protocols may have different requirements. Request body for creating a allocation investment using the 0fns protocol.

walletId
string
required

Wallet id.

Maximum length: 64
Example:

"wa-5pfuu-9euek-h0odgb6snva8ph3k"

protocol
enum<string>
required

Ofns protocol

Available options:
0fns
sourceAsset
object
required
targetAsset
object
required
slippageBps
number
required

The slippage tolerance for this trade in basis point (BPS). Slippage tolerance defines the maximum price difference you're willing to accept during a trade from the estimated quote, ensuring you still receive at least a minimum number of tokens if the price shifts. One basis point equals one-hundredth of a percentage point, or 0.01%.

externalId
string

An optional external identifier provided by the client to ensure idempotency and prevent duplicate operations.

Response

200 - application/json

Success

A allocation investment representing funds deposited to earn interest from a DeFi protocol.

id
string
required

Unique identifier for the allocation investment.

Maximum length: 64
Example:

"allctn-7mnn0-rltpq-9bvps60gjm09td0j"

walletId
string
required

Wallet id.

Maximum length: 64
Example:

"wa-5pfuu-9euek-h0odgb6snva8ph3k"

protocol
enum<string>
required

The DeFi protocol used for allocation generation. Currently supports OFNS protocol

Available options:
0fns
amount
object
required

The total amount currently invested in this allocation.

  • Native Asset
  • EVM Fungible Token (ERC-20)
rewards
object
required

The total rewards earned so far in this allocation.

  • Native Asset
  • EVM Fungible Token (ERC-20)
dateCreated
string<date-time>
required

ISO 8601 date (must be UTC). ISO 8601 date. When the allocation was created.

Example:

"2023-04-14T20:41:28.715Z"

actions
object[]
required