Creating a Sell Order
The sell order can be initiated either by first creating a quote and then initiating the transaction, or by passing the quote input details along with the transaction initiation request, which will immediately create a quote and execute the transaction.
Please note that if Partner is custodying crypto with Coinme, then sourceWalletAddress can be left blank. If Partner is NOT custodying with Coinme and is selling from an external wallet, then Partner must provide the sourceWalletAddress (wallet the funds are sold from)
Complete a sell transaction using a specified customerId and quoteId
In this use case, the quote is first created using the Quotes endpoint. The Quotes endpoint will contain a quoteId which then needs to be passed in to initiate a sell transaction. The use case for this is when a partner wishes to first display the quote to the end user and ask for the end user's approval before initiating the transaction, since the quote contains various info, such as fees, coin price, etc.
Sample API Request for SELL with previously created quote: POST
URL: https://caas-staging.coinme.com/services/transaction
headers:
"Authorization":"asdfghj", //authorization token, required
'User-Agent: partnerapi' //required
Request body:
{
"customerId": "654987321", //required
"partnerTransactionId":"34567890", //optional, automatically generated if not provided
"quoteId":"1006491596889587712", //Quote Identifier refering to the specific crypto quote, required
"paymentMethodId": "12345", //optional. required if using Coinme digital payment processing
"sourceWalletAddress": "34ohqFagYAdWKARd5m26R1ML6WZMbDniYh", // source wallet address - indicates from what wallet address is crypto sent, required
"tags": "A_TAG", //optional, tags can be used to mark a transaction with unique keywords
"webSessionId": "123123" //optional, field is required only if partner is provisioned to have Coinme digital transaction processing screend by a security provider and only if partner is using a providerId that supports digital payment processing
}
Complete a sell transaction using a specified customerId
This flow supports a use case where the partner wishes to execute a sell without the end user's explicit approval. In this case, no quote was previously created using the Quotes endpoints. Instead, the information normally passed in the Quotes endpoint is now passed in here and Coinme's system will immediately execute the transaction based on the given inputs.
The Quote and Transaction endpoint currently only supports stablecoins such as USDC and USDT
Sample API Request for SELL without previously created quote: POST
URL: https://caas-staging.coinme.com/services/quote-and-transaction
headers:
"Authorization":"asdfghj", //authorization token,required
'User-Agent: partnerapi' //required
Request body:
{
"customerId": "654987321", //required
"partnerTransactionId":"34567890", //optional, automatically generated if not provided
"quoteInput": { //details required to create a quote
"debitCurrencyCode":"USD", //required
"creditCurrencyCode":"BTC", //required
"amountValue": "100", //required
"amountCurrencyCode": "USD", //required
"providerId": "451231563453", //optional, should be specified only if fiat settlement is done through Coinme
"locationReference": "9821392", //optional, should be specified only if fiat settlement is done through Coinme and requires a physical location
"gpsCoordinates": { //optional, alternative to "locationReference"
"latitude": "-78.617716",
"longitude": "62.936942"
},
"cryptoSettlementType": "EXTERNAL" //valid values are INTERNAL and EXTERNAL, specifies if the crypto will be deposited in Coinme's crypto wallet or an external wallet
"chain": "BTC" //optional - if partner is provisioned to use only one chain with the specific crypto, then this parameter is not required. If partner is provisioned to use more than 1 chain for same crypto, then this value is required
},
"paymentMethodId": "12345", //optional. required if using Coinme digital payment processing
"sourceWalletAddress": "34ohqFagYAdWKARd5m26R1ML6WZMbDniYh", // source wallet address - indicates from what wallet address is crypto sent, required
"tags": "A_TAG", //optional, tags can be used to mark a transaction with unique keywords
"webSessionId": "123123" //optional, field is required only if partner is provisioned to have Coinme digital transaction processing screend by a security provider and only if partner is using a providerId that supports digital payment processing
}
Sample API Response for SELL:
The same response is returned for both sell with and without previously created quote
Successful Response:
{
"data":
{
"partnerTransactionId":"34567890",
"creditCurrencyUnitPrice":"0.1301574906",
"creditCurrencyUnitPriceCode":"USD/DOGE",
"debitCurrencyUnitPrice":"7.683",
"debitCurrencyUnitPriceCode":"DOGE/USD",
"creditCurrencyAmount":"100", // Amount value requested by User
"creditCurrencyCode":"USD",
"debitCurrencyAmount":"749.0925",
"debitCurrencyCode":"DOGE",
"totalFees":"2.5", // exchange fee value
"feeCurrencyCode":"USD", // exchange fee currency code
"feesMap":{
"exchangeFee":"2.5",
"processingFee":"0",
"blockchainFee": "0.4" // present if request for quote had cryptoSettlementType: EXTERNAL
},
"spreadAmount":"0.117",
"spreadCurrencyCode":"USD"
},
"errorResponse": null
}
Failure Response:
{
"data": null,
"errorResponse": {
"httpStatus":"200",
"timestamp":"2022-02-01T18:59:28.297Z", //UTC
"path":"/services/transaction POST", //The error code is just a sample showing the structure of the error code.
"errorData": [
{
"errorCode":"123-123-123-123",
"message":"Invalid QuoteId"
}
]
}
After a sell transaction has been initiated and processed, the partner must retrieve the on-chain transaction hash and pass the hash to the Submit Blockchain Transaction ID endpoint.
Sample API Request: PUT
URL: https://caas-staging.coinme.com/services/transaction/submit-blockchain-id
Headers:
{
"Authorization": "asdfghj", //required, authorization token
"User-Agent": "partnerapi" //required
}
Request Body:
{
"partnerTransactionId": "trxID", // ID of the sell transaction from the transaction endpoint, required
"blockchainTransactionId": "blockchain transaction id", //required
"refundWalletAddress": "theirRefundWalletAddress" // optional, address on which to execute refund to in case of transaction failure
}
Successful Response:
{
"partnerTransactionId": "txn-1234-abcd-5678" //identifies the transaction in Coinme's system for which the blockchain transaction ID is being submitted
}
Failure Response:
{
"data": null,
"errorResponse": {
"httpStatus":"200",
"timestamp":"2022-02-01T18:59:28.297Z", //UTC
"path":"/services/submit-blockchain-id PUT", //The error code is just a sample showing the structure of the error code.
"errorData": [
{
"errorCode":"123-123-123-123",
"message":"Invalid Blockchain Hash"
}
]
}
Error Codes (Transaction)
| Error Code | Error Message |
|---|---|
| 280-500-352-000 | Internal error occurred, please try again or contact support |
| 280-400-352-500 | Header/Field cannot be null or empty |
| 280-400-352-502 | Partner transaction id must be a unique non-empty string value |
| 280-400-352-503 | Request is containing duplicate tags |
| 280-404-352-901 | Unable to find quoteId <quote_id> |
| 280-404-352-902 | CustomerId does not match the quoteId |
| 109-412-151-045 | <user tier> Customer would exceed daily sell limit (<error code>). Available amount: <available amount> |
| 280-412-352-903 | SSN is not collected/verified |
| 280-400-352-667 | Required request header <headerName> for method parameter type <typeName> is not present |
| 280-500-352-907 | Unable to resolve quote GPS coordinates |
| 280-500-352-911 | No supported crypto settlement policies were found for partner {partnerId} and provider {providerId}! |
| 280-500-352-912 | Crypto settlement type {type} for order type {order_type}, partner {partnerId} and provider {providerId} is NOT supported! |
| 280-500-352-913 | externalCustodyCreditInfo.walletAddress is required for buy order and EXTERNAL crypto settlement |
| 280-400-352-914 | Wallet address {walletAddress} does not pass trm check |
| 280-400-352-916 | sourceWalletAddress is required for external sell |
Error messages for errors that occur while retrieving quote based on the given quoteId in the request.
| Error Code | Error Message |
|---|---|
| 171-500-201-000 | Internal error occurred, please try again or contact support |
| 171-404-201-905 | Unable to fetch UserQuoteData with id <quote_id>, quote expired or doesn't exist |
Error messages for errors that occur while retrieving partner data:
| Error Code | Error Message |
|---|---|
| 101-500-317-000 | Internal error occurred, please try again or contact support |
| 101-404-317-704 | PartnerProfile resource not found with identifier: <partner_id> |
Error messages for errors that occur while retrieving Customer data:
| Error Code | Error Message |
|---|---|
| 140-500-317-000 | Internal error occurred, please try again or contact support |
| 140-404-317-704 | AccountProfile resource not found with identifier: <account_id> |
Error Codes (Submit Blockchain ID)
| Error Code | Error Message |
|---|---|
| 480-500-352-000 | Internal error occurred, please try again or contact support |
| 480-400-352-382 | Transaction authorization failed |
Updated 3 days ago