Vývojářský portál
Motiv

Create Intent Order#

Submit a signed intent order to the OKX DEX intent protocol. Before calling this endpoint, obtain a quote with mode=intent or mode=auto via Get Quotes, then sign the returned signData object using the user's wallet (EIP-712).

Request URL#

POST
https://web3.okx.com/api/v6/dex/aggregator/intent/create-order

Request Parameters#

ParameterTypeRequiredDescription
chainIndexStringYesUnique identifier for the chain. e.g., 1: Ethereum. See more here.
fromTokenAddressStringYesThe contract address of the token to be sold. Must match signData.message.fromTokenAddress from the quote response.
toTokenAddressStringYesThe contract address of the token to be bought. Must match signData.message.toTokenAddress from the quote response.
fromTokenAmountStringYesThe sell amount in minimal divisible units. Must match signData.message.fromTokenAmount from the quote response.
toTokenAmountStringYesThe minimum receive amount in minimal divisible units. Derived from signData.message.toTokenAmount in the quote response with slippage applied.
userWalletAddressStringYesThe wallet address of the order owner. Must match signData.message.owner from the quote response.
validToIntegerYesUnix timestamp (seconds) at which the order expires. Must match signData.message.validTo from the quote response.
swapReceiverAddressStringNoThe wallet address to receive the output tokens. Defaults to userWalletAddress if not provided. Must match signData.message.receiver from the quote response.
quoteIdStringYesThe unique quote identifier returned by the Get Quotes endpoint.
appDataStringYesApp data hash from signData.message.appData in the quote response.
signatureStringYesThe EIP-712 signature of the signData object from the quote response, signed by the user's private key.
commissionInfosArrayNoCommission configuration list. Each entry defines a referrer address and fee for a specific token direction. Use the values from signData.message.commissionInfos in the quote response.
feePercentStringNoFee amount multiplied by 10^9. e.g., 30000000 represents 0.3%. Use the same values from quote response.
referrerWalletAddressStringNoThe wallet address to receive the commission. Use the same values from quote response.
flagStringNoA bitmap encoding fee routing rules including token direction (fromToken or toToken) and other constraints. Use the value from signData.message.commissionInfos[].flag in the quote response.

Response Parameters#

ParameterTypeDescription
orderUidStringThe unique identifier of the successfully created intent order. Use this ID to query order status or cancel the order.

Request Example#

shell
curl --location --request POST 'https://web3.okx.com/api/v6/dex/aggregator/intent/create-order' \
--header 'OK-ACCESS-KEY: 37c541a1-****-****-****-10fe7a038418' \
--header 'OK-ACCESS-SIGN: leaV********3uw=' \
--header 'OK-ACCESS-PASSPHRASE: 1****6' \
--header 'OK-ACCESS-TIMESTAMP: 2023-10-18T12:21:41.274Z' \
--header 'Content-Type: application/json' \
--data-raw '{
  "chainIndex": "1",
  "fromTokenAddress": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
  "toTokenAddress": "0xdac17f958d2ee523a2206206994597c13d831ec7",
  "fromTokenAmount": "100000",
  "toTokenAmount": "95432",
  "userWalletAddress": "0x5B38Da6a701c568545dCfcB03FcB875f56beddC4",
  "validTo": 1893456000,
  "swapReceiverAddress": "0x5B38Da6a701c568545dCfcB03FcB875f56beddC4",
  "quoteId": "10000000000000001",
  "appData": "0xa1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2",
  "signature": "0x1234567890abcdef...",
  "commissionInfos": [
    {
      "feePercent": "30000000",
      "flag": "86412300000000000000000000000000000000000000000000000000000000000000",
      "referrerWalletAddress": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
    },
    {
      "feePercent": "10000000",
      "flag": "86567800000000000000000000000000000000000000000000000000000000000000",
      "referrerWalletAddress": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8"
    }
  ]
}'

Response Example#

json
{
    "code": "0",
    "data": [
        {
            "orderUid": "0xa1b2c3d4e5f6789012345678901234567890123456789012345678901234567890ab"
        }
    ],
    "msg": ""
}