Crypto Buy/Sell

Overview

The general workflow for crypto trades will look like the following:

  1. Pull the market price for the crypto your end user is looking to buy/sell from our API.
  2. Give the end user the ability to confirm a trade after looking at the market price.
  3. Call the Fortress API to initiate a trade
  4. Monitor the webhooks sent for a change in the status of a trade.
  5. Once completed, update your front end with the new balance for the end user.

❗️

Testnet Tokens

When testing trades in sandbox, please keep amounts low (greater than $15 but less than $30) as testnet tokens are in limited supply. Once finished testing, please "sell" the tokens so we can maintain a steady supply for all integrators in sandbox.

Lets review each step a bit more.

1. Pull the market price

GET /api/trust/v1/crypto-currency/crypto-currency-price/{network}/{currency}

//Sample Response

{ 
"price": {
  "buy": 21489.79,
  "sell": 21457.19
  }
}

Note: The API can return zero values for buy or sell market prices. Zero dollar value trades ($0.00) will not be executed.

2. Allow the end user to confirm that they want the trade after presenting them the market price.

3. Initiate a trade using the API

POST /api/trust/v1/trades

//Sample Request

{
     "accountId": "A3CA08AB-3058-4C3C-81E7-51DA24B171FF", 
     "type": "market", //only "market" is available at this time
     "from": {
          "asset": "usd",
          "amount": 100 
      },
     "to": {
          "asset": "eth",
          "network": "mainnet"
      },
     "comment": "Any Comment Here" 
}

OR

POST /api/trust/v1/trades

// Sample Request

{
     "accountId": "A3CA08AB-3058-4C3C-81E7-51DA24B171FF", 
     "type": "market", //only "market" is availbable at this time
     "from": {
          "asset": "eth",
          "network": "mainnet" 
          "amount": 100 
      },
     "to": {
          "asset": "usd" 
      },
     "comment": "Any Comment Here" 
}

👍

All in one

The trades endpoint facilitates both buys and sells by designating the from and to fields.

4. Monitor webhooks

An integrator will receive one webhook when the buy/sell crypto transaction is moved to the Processing status and another webhook when the settlement process is completed. Here are a list of the status's available for the trades endpoint:

  • Pending (the buy/sell crypto request is created)

  • InProgress (the buy/sell crypto request is in progress and has executed at a particular price, pending incoming crypto/fiat is displayed in an account balance)

  • Completed (settlement process is completed)

  • Aborted (processing of the buy/sell crypto request is failed)

5. Once a trade is completed, update your front end with the new balance

GET /custodial-accounts/{custodialAccountId}/balances

//Sample Response

{ 
"data": [ 
   {
   "assetType": "cryptoCurrency",
   "assetFiatType": "eth",
   "network": "mainnet",
   "disbursable": .001,
   "locked": 0,
   "pending": 0,
   "total": .001 
   } 
 ]
}

📘

Crypto Trading Settlement Times

Trades are executed almost immediately, but settlement for those trades take up to one business day. Contact


What’s Next