Trades

This section describes the trade object as well as the endpoints that allow you to create, query and manipulate trades:

The following sections describe the trade object and continue to describe each of the endpoints in greater detail.

Trade object

Example awaiting_transfer_in trade object buying 2.41526674 BTC for 1,000.00 USD

{
  "id": 113475347,
  "traderId": 754035,
  "traderEmail": "[email protected]",
  "state": "awaiting_transfer_in",
  "inCurrency": "USD",
  "outCurrency": "BTC",
  "inAmount": 1000.00,
  "outAmountExpected": 2.41526674,
  "transferIn": {
    "currency": "USD",
    "sendAmount": 1000.00,
    "receiveAmount": 1000.00,
    "medium": "card",
    "details": {
      "redirectUrl": "https://provider.com/payment/d3aab081-7c5b-4ddb-b28b-c82cc8642a18"
    }
  },
  "transferOut": {
    "currency": "BTC",
    "medium": "blockchain",
    "sendAmount": 2.41526674,
    "receiveAmount": 2.41526674,
    "details": {
      "account": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
    }
  },
  "quoteExpireTime": "2016-04-01T12:38:19Z",
  "updateTime": "2016-04-01T12:27:36Z",
  "createTime": "2016-04-01T12:23:19Z"
}

Example completed trade object buying 2.41551728 BTC for 1,000.00 USD

{
  "id": 113475347,
  "traderId": 754035,
  "traderEmail": "[email protected]",
  "state": "completed",
  "inCurrency": "USD",
  "outCurrency": "BTC",
  "inAmount": 1000.00,
  "outAmount": 2.41551728,
  "transferIn": {
    "currency": "USD",
    "sendAmount": 1000.00,
    "receiveAmount": 1000.00,
    "medium": "card",
    "details": {
      "redirectUrl": "https://provider.com/payment/d3aab081-7c5b-4ddb-b28b-c82cc8642a18"
    }
  },
  "transferOut": {
    "currency": "BTC",
    "medium": "blockchain",
    "sendAmount": 2.41526674,
    "receiveAmount": 2.41526674,
    "details": {
       // Trader's bitcoin address that has received the 2.41551728 BTC
      "account": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
      // The BTC transaction that sent out the BTC to the above address
      "transaction": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
    }
  },
  "updateTime": "2016-04-01T12:27:36Z",
  "createTime": "2016-04-01T12:23:19Z"
}

Example completed trade object selling 2.41551728 BTC for 1,000.00 USD

{
  "id": 113475348,
  "traderId": 754035,
  "traderEmail": "[email protected]",
  "state": "completed",
  "inCurrency": "BTC",
  "outCurrency": "USD",
  "inAmount": 2.41551728,
  "outAmount": 1000.00,
  "transferIn": {
    "currency": "BTC",
    "sendAmount": 2.41551728,
    "receiveAmount": 2.41551728,
    "medium": "blockchain",
    "details": {
      // Coinify's bitcoin address to where the trader sent the 2.41551728 BTC
      "account": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
      "paymentUri": "bitcoin:1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa?amount=2.41551728",
      // The BTC transaction that sent out the BTC to the above address
      "transaction": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
    }
  },
  "transferOut": {
    "currency": "USD",
    "sendAmount": 1000.00,
    "receiveAmount": 1000.00,
    "medium": "bank",
    "mediumReceiveAccountId": 12345 // Reference to the traders bank account
  },
  "updateTime": "2016-04-01T12:27:36Z",
  "createTime": "2016-04-01T12:23:19Z"
}

The following table defines the fields of a trade object:

KeyTypeDescription
idIntegerUnique ID for this trade
traderIdIntegerReference to the trader that created the trade
traderEmailStringEmail address of trader that created the trade
stateTrade stateThe current state of the trade
inCurrencyStringCurrency (ISO 4217) denominating inAmount.
outCurrencyStringCurrency (ISO 4217) denominating outAmount or outAmountExpected.
inAmountFloatThe amount of inAmount that this trade covers. Is always positive.
outAmountFloat(Optional) The amount of outCurrency that this trade resulted in. Is always positive. NOTE: This field is only defined if the state of the trade is completed. For all other states, see the outAmountExpected field.
outAmountExpectedFloatThe amount of outCurrency that this trade is expected to result in. Is always positive.
transferInTransfer objectObject describing how we (Coinify) will receive/have received the money to fund the trade.
transferOutTransfer objectObject describing how we (Coinify) will send/have sent the result of the trade back to the trader.
quoteExpireTimeISO 8601 time(Optional) The time when the price quote underlying this trade expires. NOTE: This field is only defined in the following states: awaiting_transfer_in, processing, reviewing, payment_authorized.
updateTimeISO 8601 timeThe time when the trade was last updated.
createTimeISO 8601 timeTimestamp for when this trade was first created

Trade states

The following table lists all possible states of a trade (the state property):

StateDescription
awaiting_transfer_in(Starting state) Trade was successfully created, and is waiting for trader's payment
payment_authorized(Only if transferIn.medium = 'card') We have reserved trade.inAmount on customers card. Followed immediately by processing if trader has performed Mandatory onboarding steps and the quote is not expired.
processingTrade has received the trader's payment, and we are processing the trade.
completed(Ending state) Trade completed successfully.
cancelled(Ending state) Trade cancelled.
rejected(Ending state) Trade was rejected.
expired(Ending state) Trade expired before it completed.
Aside from the completed state, there is also a nearly-identical completed_test state, which is used instead of completed if the trade was paid for with a test payment. See the section on testing for more information.

The states, as well as the possible transitions between them, are visualized in this diagram:

Transfer object

Each trade has two transfer objects - transferIn and transferOut - which contain details about how Coinify will receive money from the trader, and how Coinify will send money back to the trader, respectively.

Each transfer object contains the following keys:

KeyTypeDescription
currencyStringCurrency (ISO 4217) that this transfer is/will be denominated in.
sendAmountFloatAmount that is/will be sent to this transfer. Denominated in currency. Is always positive.
receiveAmountFloatAmount that this transfer will result in. Denominated in currency. Is always positive and equal to or smaller then sendAmount. The difference between the sendAmount and the receiveAmount will be the fee of the transfer.
mediumStringTransfer medium. The medium transferring the currency.
mediumReceiveAccountIdIntegerReference to our internal accounts. Note at the moment we only have internal bank accounts.
detailsMedium detailsInformation relevant for this medium

Transfer media

MediumDescription
blockchainBlockchain - Transfer on a public blockchain, such as Bitcoin. NOTE: The currency field of the transfer object will determine which blockchain currency.
cardCard - Card payment.
bankBank - Bank account payment. If transfer is incoming we sent our own bank details as the details object. And if transfer is outgoing its the details of the traders bank account.

Blockchain

Details object
KeyTypeDescription
accountStringAccount receiving the money in this transfer (blockchain address).
accountSignatureStringHMAC-SHA-256 signature signing the account value. Only defined if a shared secret has been established with Coinify.
memoStringOptional memo for currencies where memo/destination tag is supported.
transactionStringTransaction sending the money in this transfer. Only defined if money has been sent.
refundAccountStringAccount to refund the money in this transfer in case of failure. Only defined if currency != 'BTC'.
refundAccountSignatureStringHMAC-SHA-256 signature signing the refundAccount value. Only defined if refundAccount is defined and a shared secret has been established with Coinify.
paymentUriStringPayment URI scheme to generate QR code.

Card

Details object

Below, a description of the request/response objects for creating a trade.

Request object
KeyTypeDescription
returnUrlStringThe return URL to which the user to be sent back after the payment has been created. Can be provided when creating a trade.
Reponse object
KeyTypeDescription
redirectUrlStringSource URL to process the payment.
returnUrlStringThe return URL to which the user to be sent back after the payment has been created.

Bank

Details object
Details for the bank transfer is populated automatically for incoming transfers, where the trader needs to send money to our account. If the transfer is outgoing, you must specify the accountId for the traders bank account to use.
KeyTypeDescription
referenceTextStringText that the bank transfer must contain in order for Coinify to correctly register what trade it concerns.
accountObjectObject with additional information about the bank account.
currencyStringCurrency of the bank account.
typeBank account typeType of the bank account
bicStringFor sepa and international its the SWIFT / BIC number and for danish accounts its the REG number. Optional in case of domestic bank tansfers.
numberStringFor sepa and international it's the IBAN (International Bank Account Number). For danish accounts, it's the BBAN (Basic Bank Account Number). Optional in case of domestic bank transfers.
domesticAccountNumberStringAccount Number for domestic transfers. (Optional)
regNoStringReg. No. used for some domestic transfers. (Optional)
routingCodeStringRouting Code used for some domestic transfers. (Optional)
sortCodeStringSort Code used for some domestic transfers. (Optional)
bsbStringBSB used for some domestic transfers. (Optional)
bankObjectObject with additional information about the bank.
nameStringName of the bank.
addressObjectObject with information about the address of the bank.
    →streetStringStreet address.
    →zipcodeStringZip/Postal code.
    →cityStringCity.
    →stateStringState.
    →countryStringISO 3166-1 alpha-2 country code
holderObjectObject with additional information about the bank account holder.
nameStringName of the bank account holder.
addressObjectObject with information about the address of the account holder.
    →streetStringStreet address.
    →zipcodeStringZip/Postal code.
    →cityStringCity.
    →stateStringState.
    →countryStringISO 3166-1 alpha-2 country code

Payment methods

This section contains information about different methods to buy/sell blockchain currencies.

The currently available payment methods are:

  • Buy crypto currency with bank transfer - (in) bank, (out) blockchain
  • Buy crypto currency with card transfer - (in) card, (out) blockchain
  • Sell bitcoins to bank transfer - (in) blockchain, (out) bank

Payment method object

The object represents a single payment method, containing the information about how and with what currencies the money
transfer can and should be performed, and optionally the fees that are going to be applied to the amounts.

KeyTypeDescription
inMediumStringThe medium for the in transfer of the trade - by what way the customer pays
outMediumStringThe medium for the out transfer of the trade - what way the customer receives funds
inCurrenciesListThe possible currencies in which the incoming amount can be made, optionally filtered by request arguments
outCurrenciesListThe possible currencies in which the outgoing amount can be made, optionally filtered by request arguments
inFixedFeesObjectObject of inCurrencies and fixed fees for each currency for the in transfer.
inPercentageFeeFloatPercentage fee for the in transfer.
minimumInFeesObjectMinimum fee for the in transfer.
outFixedFeesObjectObject of outCurrencies and fixed fees for each currency for the out transfer.
outPercentageFeeFloatPercentage fee for the out transfer.
minimumOutFeesObjectMinimum fee for the out transfer.
minimumInAmountsObjectObject of inCurrencies and the minimum limit for each.
limitInAmountsObjectObject of inCurrencies and the trader's current limit for each currency, based on the current limits of the trader. Note: Only included for authenticated requests.
canTradeBooleanCan this trader create new trades for this payment method? Note: Only included for authenticated requests. If inCurrency, inAmount, outCurrency and outAmount are all provided in request, this value determines if a trade with the specific amounts/currencies can be made. Otherwise, this value determines if any trade can be made with this payment method.
cannotTradeReasonsList(Optional) List of reason objects why the trader cannot create new trades (why canTrade is false). Note: Only included for authenticated requests if canTrade is false.
inCurrencyString(Optional, if inCurrency parameter provided) Echo of inCurrency parameter.
inAmountFloat(Optional, if inAmount parameter provided) Echo of inAmount parameter.
outCurrencyString(Optional, if outCurrency parameter provided) Echo of outCurrency parameter.
outAmountFloat(Optional, if outAmount parameter provided) Echo of outAmount parameter.

cannotTradeReason object

This object represents a reason for why a trader cannot create a trade with a given payment method. The only field that is always present in the object is the reasonCode. Depending on the value of the reasonCode, other reason-specific fields may be present in the object.

KeyTypeDescription
reasonCodeStringMachine-readable code for the reason why the trade cannot create a trade. See Possible reasonCodes for a list of possible values
Possible reasonCodes

reasonCode valueDescriptionExtra fields
forced_delayTrader must wait until a specific time before creating tradedelayEnd (string): ISO-8601 timestamp for when the delay is over.
trade_in_progressTrader must wait until a specific trade has completedtradeId (integer): ID of trade that must be completed
limits_exceededCreating trade would exceed the trader's limitsNone
country_not_supportedTrading is not currently supported in the trader's country. See supported countries for querying a partner's supported countries.None

List payment methods

Example response for GET /trades/payment-methods (authenticated)

[
    {
      "inMedium": "bank",
      "outMedium": "blockchain",
      "inCurrencies": ["DKK", "EUR", "USD", "GBP", "CHF"],
      "outCurrencies": ["BTC", "ETH", "BSV", "BCH", "XLM", "DASH", "NANO"],
      "inFixedFees": {
        "DKK": 0,
        "EUR": 0,
        "USD": 0,
        "GBP": 0,
        "CHF": 0
      },
      "inPercentageFee": 0.75,
      "minimumInFees": {
        "DKK": 49.00,
        "EUR": 4.99,
        "USD": 4.99,
        "GBP": 4.99,
        "CHF": 4.99
      },
      "outFixedFees": {
        "BTC": 0.0002,
        "ETH": 0,
        "BSV": 0,
        "BCH": 0,
        "XLM": 0,
        "DASH": 0,
        "NANO": 0
      },
      "outPercentageFee": 0,
      "minimumInAmounts": {
        "DKK": 933.38,
        "EUR": 125,
        "USD": 140.17,
        "GBP": 111.35,
        "CHF": 140.08
      },
      "limitInAmounts": {
        "DKK": 7500.86,
        "EUR": 1000.00,
        "USD": 1200.50,
        "GBP": 8000.00,
        "CHF": 800.00
      },
      "canTrade": true
    },
    {
      "inMedium": "blockchain",
      "outMedium": "bank",
      "inCurrencies": ["BTC", "ETH", "BSV", "BCH", "XLM", "DASH", "NANO"],
      "outCurrencies": ["DKK", "EUR", "USD", "GBP", "CHF"],
      "inFixedFees": {
        "BTC": 0,
        "ETH": 0,
        "BSV": 0,
        "BCH": 0,
        "XLM": 0,
        "DASH": 0,
        "NANO": 0
      },
      "inPercentageFee": 0,
      "outFixedFees": {
        "DKK": 40.00,
        "EUR": 5.40,
        "USD": 6.10,
        "GBP": 3.70,
        "CHF": 4.90
      },
      "minimumOutFees": {
        "DKK": 49.00,
        "EUR": 4.99,
        "USD": 4.99,
        "GBP": 4.99,
        "CHF": 4.99
      },
      "outPercentageFee": 1,
      "minimumInAmounts": {
        "BTC": 0.01530498,
        "ETH": 0.514718127075,
        "BSV": 0.65349743,
        "BCH": 0.32362399,
        "XLM": 1077.1290499,
        "DASH": 1.77,
        "NANO": 231.41
      },
      "limitInAmounts": {
        "BTC": 0.1224398,
        "ETH": 4.117745016597,
        "BSV": 5.2279794,
        "BCH": 2.58899193,
        "XLM": 8617.0323993,
        "DASH": 15.2,
        "NANO": 1249.23
      },
      "canTrade": true
    },
    {
      "inMedium": "card",
      "outMedium": "blockchain",
      "inCurrencies": ["DKK", "EUR", "USD", "GBP", "CHF"],
      "outCurrencies": ["BTC", "ETH", "BSV", "BCH", "XLM", "DASH", "NANO"],
      "inFixedFees": {
        "DKK": 0,
        "EUR": 0,
        "USD": 0,
        "GBP": 0,
        "CHF": 0
      },
      "inPercentageFee": 3.5,
      "minimumInFees": {
        "DKK": 49.00,
        "EUR": 4.99,
        "USD": 4.99,
        "GBP": 4.99,
        "CHF": 4.99
      },
      "outFixedFees": {
        "BTC": 0.0002,
        "ETH": 0,
        "BSV": 0,
        "BCH": 0,
        "XLM": 0,
        "DASH": 0,
        "NANO": 0
      },
      "outPercentageFee": 0,
      "minimumInAmounts": {
        "DKK": 149.34,
        "EUR": 20,
        "USD": 22.43,
        "GBP": 17.82,
        "CHF": 22.41
      },
      "limitInAmounts": {
        "DKK": 746.71,
        "EUR": 100,
        "USD": 112.14,
        "GBP": 89.08,
        "CHF": 112.06
      },
      "canTrade": false,
      "cannotTradeReasons": [
        {
          "reasonCode": "forced_delay",
          "delayEnd": "2016-04-01T12:27:36Z"
        }
      ]
    }
]

GET https://app-api.coinify.com/trades/payment-methods

This endpoint returns a list of payment methods objects, available for creating and paying for trades.

If you want know which network/chain does a particular supported cryptocurrency belong to, please find the list here.

Response
HTTP Response codeError codeJSON data
200 OKSuccess, response as shown to the right.
400 Bad requestinvalid_argumentError, interpreting the request (wrong input values for query parameters).
500 Internal errorinternal_errorError, an internal error happened.

Request trade price quote

Example request for POST /trades/quote

// This request is saying: "I want to buy BTC for 1,000.00 USD. How much BTC will I get?"
{
  "baseCurrency": "USD",
  "quoteCurrency": "BTC",
  "baseAmount": -1000.00
}

Example response for POST /trades/quote

// This response is saying "We'll give you 2.41551728 BTC for 1,000.00 USD"
{
  "id": 123456,
  "baseCurrency": "USD",
  "quoteCurrency": "BTC",
  "baseAmount": -1000.00,
  "quoteAmount": 2.41551728,
  "issueTime": "2016-04-01T11:47:24Z",
  "expiryTime": "2016-04-01T12:02:24Z"
}

POST https://app-api.coinify.com/trades/quote

Before actually creating a trade, you (as a trader) have the option of getting a price quote (i.e. an offer for a specific exchange rate) that is valid for a short period of time. When creating a trade you can reference a price quote and trade using the rate given in the quote.

Currently, when purchasing BTC and paying with a credit card, the price quote is valid for 15 minutes after being issued. For other currencies and payment methods the quote is only indicative. The price quote is only valid for the trader that requested it. You will receive an error if you try to create a trade using a price quote requested by another trader.
Request object

The parameters in the request object are as follows:

ParameterTypeDefaultDescription
baseCurrencyStringRequiredRelative to what currency (ISO 4217) do you want a price quote? Denominates baseAmount.
quoteCurrencyStringRequiredWhat currency (ISO 4217) do you want the price quote in?
baseAmountFloatRequiredAmount to get a price quote for. Denominated in baseCurrency.
transferInObjectEmpty objectAn object describing how Coinify will receive the money for this transfer.
mediumStringnullTransfer medium
transferOutObjectEmpty objectAn object describing how Coinify will send the result of the trade to the trader.
mediumStringnullTransfer medium
Request object examples

The following table exemplifies how baseCurrency and quoteCurrency should be interpreted.

baseCurrencyquoteCurrencybaseAmountInterpretation
"USD""BTC"123.45I want to buy 123.45 USD for BTC.
"USD""BTC"-123.45I want to sell 123.45 USD for BTC.
"BTC""USD"1.5I want to buy 1.5 BTC for USD.
"BTC""USD"-1.5I want to sell 1.5 BTC for USD.
Response object

The success response object contains the following fields:

KeyTypeDescription
idIntegerPrice quote identifier. Pass this identifier to the create trade endpoint to claim the offer. Note: Not included if anonymous (un-authenticated) request.
baseCurrencyStringCurrency (ISO 4217) denominating baseAmount, the known amount.
quoteCurrencyStringCurrency (ISO 4217) denominating quoteAmount, the unknown amount.
baseAmountFloatHow much of baseCurrency does this quote apply for?
quoteAmountFloatHow much of quoteCurrency is this quote? This is the "result", the price quote.
transferInObjecttransferIn object, only returned if provided in request
mediumStringTransfer medium
feeAmountFloatTransfer fee (Will be added on the trade)
currencyStringCurrency
transferOutObjecttransferOut object, only returned if provided in request
mediumStringTransfer medium
feeAmountFloatTransfer fee (Will be added on the trade)
currencyStringCurrency
issueTimeISO 8601 timeTimestamp for when this price quote was issued.
expiryTimeISO 8601 timeTimestamp for when this price quote expires.
Response
HTTP Response codeJSON data
201 CreatedSuccess, A Price quote created and returned object as shown to the right
401 UnauthorizedError, access token missing.

Get price quote details

Example response (buy) for GET /trades/quote/:id/details?transferInMedium=card&transferOutMedium=blockchain

{
  "transferIn": {
    "currency": "EUR",
    "isMinimumHandlingFeeApplied": false,
    "isMaximumHandlingFeeApplied": false,
    "sendAmount": 103.25,
    "receiveAmount": 100,
    "totalFee": 3.25,
    "partnerFee": 3, // Not present if partner fee is not enabled
    "handlingFee": 0.25
  },
  "transferOut": {
    "currency": "ETH",
    "sendAmount": 0.009582,
    "receiveAmount": 0.008582,
    "networkFee": 0.001 // Not present if no network fee
  },
  "exchangeRate": 10436.23
}

Example response (buy) for GET /trades/quote/:id/details?transferInMedium=card&transferOutMedium=blockchain&promoCode=12314code4321

{
  "transferIn": {
    "currency": "EUR",
    "isMinimumHandlingFeeApplied": false,
    "isMaximumHandlingFeeApplied": false,
    "sendAmount": 103.25,
    "receiveAmount": 100,
    "totalFee": 3.25,
    "partnerFee": 3, // Not present if partner fee is not enabled
    "handlingFee": 0.25
  },
  "transferOut": {
    "currency": "ETH",
    "sendAmount": 0.009582,
    "receiveAmount": 0.008582,
    "networkFee": 0.001, // Not present if no network fee
    "promoCodeValue": {
      "amount": 10,
      "currency": "EUR"
    },
    "promoCodeRedeemedAmount": {
      "amount": 0.001,
      "currency": "ETH"
    }
  },
  "exchangeRate": 10436.23
}

Example response (sell) for GET /trades/quote/:id/details?transferInMedium=blockchain&transferOutMedium=bank

{
  "transferIn": {
    "currency": "BTC",
    "sendAmount": 0.009582,
    "receiveAmount": 0.009582
  },
  "transferOut": {
    "currency": "EUR",
    "isMinimumHandlingFeeApplied": false,
    "isMaximumHandlingFeeApplied": false,
    "sendAmount": 103.25,
    "receiveAmount": 100,
    "totalFee": 3.25,
    "partnerFee": 3, // Not present if partner fee is not enabled
    "handlingFee": 0.25
  },
  "exchangeRate": 10775.41
}

GET https://app-api.coinify.com/trades/quote/:id/details

Endpoint should be used to get an overview of fees and amounts, before creating the trade

Request

The parameters in the request object are as follows:

ParameterTypeDefaultDescription
transferInMediumStringRequiredTransfer medium
transferOutMediumStringRequiredTransfer medium
promoCodeStringOptionalUsed to validate if promo quote is valid and get new amounts

Response (buy)

KeyTypeDescription
transferInObject
sendAmountNumberThe amount the end-user has to send to complete the trade.
receiveAmountNumberThe amount Coinify system will receive, without the fees.
currencyStringThe currency denomination of sendAmount and receiveAmount
handlingFeeNumberThe fee we charge for the payment
partnerFeeNumberPartner fee (only present if enabled for partner)
totalFeeNumberHandling fee + partner fee, same as the difference between sendAmount and receiveAmount
isMinimumHandlingFeeAppliedBooleanTrue if handling fee is the same as the minimum fee
isMaximumHandlingFeeAppliedBooleanTrue if handling fee is the same as the maximum fee
transferOutObject
currencyString
sendAmountNumberThe amount before network fee
receiveAmountNumberThe amount the trader receives
networkFeeNumberNetwork fee for the transaction
promoCodeValueObject{amount, currency} of the promo code value in FIAT (only present if promoCode is provided)
promoCodeRedeemedAmountObject{amount, currency} of the promo code value in Crypto (only present if promoCode is provided)
exchangeRateNumberExchange rate used for this trade

Response (sell)

KeyTypeDescription
transferInObject
currencyString
sendAmountNumberThe amount the trader has to pay
receiveAmountNumberThe amount we receive without the fees
transferOutObject
currencyString
sendAmountNumberThe amount we send without the fee
receiveAmountNumberThe amount the trader receives after fees are subtracted
handlingFeeNumberThe fee we charge for the payout
partnerFeeNumberPartner fee (only present if enabled for partner)
totalFeeNumberHandling fee + partner fee, same as the difference between sendAmount and receiveAmount
isMinimumHandlingFeeAppliedBooleanTrue if handling fee is the same as the minimum fee
isMaximumHandlingFeeAppliedBooleanTrue if handling fee is the same as the maximum fee
exchangeRateNumberExchange rate used for this trade

Create trade

Example request for POST /trades, using a valid price quote

{
  "priceQuoteId": 123456,
  "transferIn": {
    "medium": "card"
  },
  "transferOut": {
    "medium": "blockchain",
    "details": {
      "account": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
    }
  },
  "partnerContext": {
    "clientId": 123,
    "refId": 12
  }
}

Example response for the above request

{
  "id": 113475347,
  "traderId": 754035,
  "traderEmail": "[email protected]",
  "state": "awaiting_transfer_in",
  "inCurrency": "USD",
  "outCurrency": "BTC",
  "inAmount": 1000.00,
  "outAmountExpected": 2.41526674,
  "transferIn": {
    "currency": "USD",
    "sendAmount": 1000.00,
    "receiveAmount": 1000.00,
    "medium": "card",
    "details": {
      "redirectUrl": "https://provider.com/payment/d3aab081-7c5b-4ddb-b28b-c82cc8642a18"
    }
  },
  "transferOut": {
    "currency": "BTC",
    "medium": "blockchain",
    "sendAmount": 2.41526674,
    "receiveAmount": 2.41526674,
    "details": {
      // Trader's bitcoin address that will receive approx. 2.41526674 BTC if trade completes
      "account": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
    }
  },
  "quoteExpireTime": "2016-04-01T12:38:19Z",
  "updateTime": "2016-04-01T12:27:36Z",
  "createTime": "2016-04-01T12:23:19Z"
}

Example request for POST /trades (buy bitcoins for bank transfer)

{
  "priceQuoteId": 123456,
  "transferIn": {
    "medium": "bank"
  },
  "transferOut": {
    "medium": "blockchain",
    "details": {
      "account": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
    }
  }
}

Example response for the above request

{
  "id": 113475347,
  "traderId": 754035,
  "traderEmail": "[email protected]",
  "state": "awaiting_transfer_in",
  "inCurrency": "USD",
  "outCurrency": "BTC",
  "inAmount": 1000.00,
  "outAmountExpected": 2.41526674,
  "transferIn": {
    "currency": "USD",
    "sendAmount": 1000.00,
    "receiveAmount": 1000.00,
    "medium": "bank",
    "details": { // Information about where the user should sent the money
       "account": {
         "currency": "DKK", // Currency of the bank account
         "bic": "HIASDMIASD", // Account bic/swift/reg number depending on the type
         "number": "1234-34235-3324-2342" // Account number
       },
       "bank": {
         "name": "Bank name", // Name of the bank
         "address": { // Address of the bank
           "street": "123 Example Street",
           "zipcode": "12345",
           "city": "Exampleville",
           "state": "CA",
           "country": "US"
         }
       },
       "holder": {
         "name": "John Doe", // Name of the account holder
         "address": { // Address of the account holder
           "street": "123 Example Street",
           "zipcode": "12345",
           "city": "Exampleville",
           "state": "CA",
           "country": "US"
         }
       }
    }
  },
  "transferOut": {
    "currency": "BTC",
    "medium": "blockchain",
    "sendAmount": 2.41526674,
    "receiveAmount": 2.41526674,
    "details": {
      // Trader's bitcoin address that will receive approx. 2.41526674 BTC if trade completes
      "account": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
    }
  },
  "quoteExpireTime": "2016-04-01T12:38:19Z",
  "updateTime": "2016-04-01T12:27:36Z",
  "createTime": "2016-04-01T12:23:19Z"
}

POST https://app-api.coinify.com/trades

The Create trade endpoint allows a trader to trade crypto for fiat, or vice-versa.

On success, the endpoint returns the newly created trade object.

The endpoint supports the following directions:

  • Buy crypto currency with card (transferIn.medium == "card" and transferOut.medium == "blockchain")
  • Buy crypto currency with bank transfer (transferIn.medium == "bank" and transferOut.medium == "blockchain")
  • Sell bitcoins and receive money by bank transfer (transferIn.medium == "blockchain" and transferOut.medium == "bank")

🚧

Important

Even though it is possible to create trades for all the traders. A trader has to be approved to complete their trades, see Trader section.

You have to provide the ID of a existing price quote (priceQuoteId.


Request object

The parameters in the request object are as follows:

ParameterTypeDefaultDescription
priceQuoteIdIntegerRequiredIdentifier of valid price quote to base the trade on. Passing an invalid price quote will result in an error.
transferInObjectRequiredAn object describing how Coinify will receive the money for this transfer.
mediumStringRequiredTransfer medium.
detailsObjectOptionalCan be used to supply returnUrl for medium=card. Transfer details.
transferOutObjectRequiredAn object describing how Coinify will send the result of the trade to the trader.
mediumStringRequiredTransfer medium.
mediumReceiveAccountIdIntegerRequired if medium is bankBank account of the trader.
detailsObjectRequired if medium is blockchainTransfer details
partnerContextJSONOptionalPartner context which will be returned in trade webhooks. Can be one of object, array, string, number, true, false as defined here https://www.json.org/json-en.html
HTTP Response codeJSON data
201 CreatedSuccess, object returned, as shown to the right
401 UnauthorizedError, access token missing.

List trades

Example response for GET /trades

[
  {
    "id": 113475347,
    "traderId": 754035,
    "traderEmail": "[email protected]",
    "state": "awaiting_transfer_in",
    "inCurrency": "USD",
    "outCurrency": "BTC",
    "inAmount": 1000.00,
    "outAmountExpected": 2.41526674,
    "transferIn": {
      "currency": "USD",
      "sendAmount": 1000.00,
      "receiveAmount": 1000.00,
      "medium": "card",
      "details": {
        "redirectUrl": "https://provider.com/payment/d3aab081-7c5b-4ddb-b28b-c82cc8642a18"
      }
    },
    "transferOut": {
      "currency": "BTC",
      "medium": "blockchain",
      "sendAmount": 2.41526674,
      "receiveAmount": 2.41526674,
      "details": {
        // Trader's bitcoin address that will receive approx. 2.41526674 BTC if trade completes
        "account": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
      }
    },
    "quoteExpireTime": "2016-04-01T12:38:19Z",
    "updateTime": "2016-04-01T12:27:36Z",
    "createTime": "2016-04-01T12:23:19Z"
  },
  {
    // Next trade...
  }
]

GET https://app-api.coinify.com/trades

Response

This endpoint lists all trade objects belonging to the authorized trader.

The trades are ordered by id (highest first).

HTTP Response codeJSON data
200 OKSuccess, response as shown to the right.
400 Bad requestError interpreting the request.
404 Not foundError, trades that belong to the provided trader were not found.
Query parameters
ParameterTypeDescription
limitStringLimit used for pagination (default: 100, max: 100)
offsetStringOffset used for pagination (default: 0)
trade_stateStringReturn only trades in specific state(s) (optional: will include all states by default)

Get trade information

Example response for GET /trades/113475347

{
  "id": 113475347,
  "traderId": 754035,
  "traderEmail": "[email protected]",
  "state": "awaiting_transfer_in",
  "inCurrency": "USD",
  "outCurrency": "BTC",
  "inAmount": 1000.00,
  "outAmountExpected": 2.41526674,
  "transferIn": {
    "currency": "USD",
    "sendAmount": 1000.00,
    "receiveAmount": 1000.00,
    "medium": "card",
    "details": {
      "redirectUrl": "https://provider.com/payment/d3aab081-7c5b-4ddb-b28b-c82cc8642a18"
    }
  },
  "transferOut": {
    "currency": "BTC",
    "medium": "blockchain",
    "sendAmount": 2.41526674,
    "receiveAmount": 2.41526674,
    "details": {
      // Trader's bitcoin address that will receive approx. 2.41526674 BTC if trade completes
      "account": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
    }
  },
  "quoteExpireTime": "2016-04-01T12:38:19Z",
  "updateTime": "2016-04-01T12:27:36Z",
  "createTime": "2016-04-01T12:23:19Z"
}

GET https://app-api.coinify.com/trades/<id>

This endpoint returns a trade object for the trade with ID <id>.

Response

See trade object.

HTTP Response codeJSON data
200 OKSuccess, response as shown to the right.
400 Bad requestError interpreting the request.
404 Not foundError, trade is not found (no trade with such ID exists or no trade with such ID that belongs to the provided trader).

Cancel trade

Example response for PATCH /trades/113475347/cancel

{
  "id": 113475347,
  "traderId": 754035,
  "traderEmail": "[email protected]",
  // State is now "cancelled"
  "state": "cancelled",
  "inCurrency": "USD",
  "outCurrency": "BTC",
  "inAmount": 1000.00,
  "outAmountExpected": 2.41526674,
  "transferIn": {
    "currency": "USD",
    "sendAmount": 1000.00,
    "receiveAmount": 1000.00,
    "medium": "card",
    "details": {
      "redirectUrl": "https://provider.com/payment/d3aab081-7c5b-4ddb-b28b-c82cc8642a18"
    }
  },
  "transferOut": {
    "currency": "BTC",
    "medium": "blockchain",
    "sendAmount": 2.41526674,
    "receiveAmount": 2.41526674,
    "details": {
      "account": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
    }
  },
  "updateTime": "2016-04-01T12:34:37Z",
  "createTime": "2016-04-01T12:23:19Z"
}

PATCH https://app-api.coinify.com/trades/<id>/cancel

This endpoint cancels the trade in the awaiting_transfer_in state and returns a trade object for the cancelled trade.

Request object

This endpoint requires no request body

Response

See trade object.

HTTP Response codeJSON data
200 OKSuccess, response as shown to the right.
400 Bad requestError trade not cancellable.
404 Not foundError, trade is not found (no trade with such ID exists or no trade with such ID that belongs to the provided trader).

Testing

This section explains how you can complete trades that you create in the Sandbox environment.

Before being able to complete the trades, make sure you have succesfully completed these actions and provided the following mandatory trader information:

This section contains the following endpoints that allow you to test the full end-to-end trade flow:

Force complete trade

Example request for POST /trades/113475347/test/complete-trade

{
  "details": {
    "account": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
  },
  "amount": 200.00, // Transfer out amount of the fake transaction
  "currency": "EUR" // Transfer out currency of the amount
}

POST https://app-api.sandbox.coinify.com/trades/<id>/test/complete-trade

This endpoint will complete a newly created trade which is in the awaiting_transfer_in state.
Provide the ID of the trade in the <id> path parameter to complete the specific.

This endpoint is for testing and does not work in production.

Request object

The parameters in the request object are optional and are use to validate the trade if they are sent:

ParameterTypeDefaultDescription
amountFloat(Optional)Transfer out receive amount of the trade.
currencyString(Optional)Currency of the amount.
detailsMedium details(Optional)Information relevant for this medium
Details object
In the details you must specify the account of the transfer out. If the referenced trade is not in the awaiting_transfer_in state, or if the amount is not the same as the stated in the transfer, the endpoint will return a 500 Internal Error error.

Response

This endpoint returns 204 No Content if the trade is completed successfully.

HTTP Response codeJSON data
204 No ContentSuccess, empty response.
400 Bad requestError interpreting the request.
500 Server errorError error has occurred parsing the data.

Complete trade with a test Card payment

Use the following test cards to complete a Buy trade via card payment.

Card NumberName on cardExpected Result
4761344136141390FL-BRW1Card payment Successful
4000000000001000Any nameCard payment Successful
Use if the above card doesn't work
4761344136141390CL-BRW1Challenge flow (3DS)
4000164166749263FL-BRW1Do not honour
5001638548736201FL-BRW1Declined
4000128449498204ERR-BRW1Error

Complete trade with a fake bank transaction

Example request for POST /trades/113475347/test/bank-transfer

{
  "sendAmount": 200.00, // Amount of the fake transaction
  "currency": "EUR" // Currency of the amount
}

POST https://app-api.sandbox.coinify.com/trades/<id>/test/bank-transfer

This endpoint creates a fake bank transfer for the trade with ID <id> and processes the trade as if a real bank transfer had occurred.

This endpoint is for testing and does not work in production.

Request object

The parameters in the request object are as follows:

ParameterTypeDefaultDescription
sendAmountIntegerRequiredAmount sent from the trader's bank account. This corresponds to the transferIn.sendAmount of the trade.
currencyStringRequiredCurrency of the amount.
If the referenced trade is not in the awaiting_transfer_in state or the transferIn.medium is not bank, the endpoint will return a 400 Bad Request error.

Response

This endpoint returns 204 No Content if the fake bank transfer creation succeeded.

HTTP Response codeJSON data
204 No ContentSuccess, empty response.
400 Bad requestError interpreting the request.
500 Server errorError error has occurred parsing the data.

Complete/Skip KYC

In the sandbox environment it is possible to automatically approve an identification-attempt by including state: 'approved' in the request object.
See example on the right or follow a more detailed explanation in this article.

Example of request to approve identification attempt

{
  "returnUrl": "https://mypage.com/ida_complete",
  "state": "approved"
}