Skip to main content

Sell On OTC

Creates an OTC offer to sell quantity tokens from one of the user's wallets at unit_price per token. The call is asynchronous: it records a user transaction (type = 6, create OTC offer) and answers with its transaction_id. Poll Get User Transaction until status is 3 (done) or 4 (error); the offer shows up in List User OTC Offers only once it is confirmed on chain.

wallet_id is required and names the wallet whose holding backs the offer and that signs it. It must be this user's wallet and sit on the token's chain. The wallet must have enough free tokens: its remaining quantity minus what its open OTC offers and open secondary-market listings already commit.

Required permission: otc:trade

Request​

POST /v2/users/{user_id}/otcs/tokens/{token_id}/sell

Parameters​

NameTypeInDescription
user_idstringpathRequired. Seller's user ID
token_idstringpathRequired. Token ID

Headers​

NameDescription
AuthorizationRequired. Bearer <access_token>
Content-TypeRequired. application/json

Body​

FieldTypeRequiredDescription
wallet_idstringYesSeller's wallet (wallets._id) whose holding backs the offer and that signs it. Must belong to the user and sit on the token's chain
quantityintegerYesWhole tokens to offer, at least 1
currency_token_idstringYesCurrency the offer is priced in (currency_tokens._id)
unit_pricestringYesPrice of one token in that currency, not the total. Greater than zero, with no more decimals than the currency has. See Amounts and Percentages

Example​

curl --request POST \
--url '{{baseUrl}}/v2/users/680c02896d91ca0145cfeb81/otcs/tokens/68ae06cfcccf4e8fc19362d1/sell' \
--header 'Authorization: Bearer <access_token>' \
--header 'Content-Type: application/json' \
--data '{
"wallet_id": "6a89b68e0c46ca4c941271aa",
"quantity": 3,
"currency_token_id": "6913307ec95e268b239b2d8b",
"unit_price": "1.1"
}'

Response​

{
"transaction_id": "6913872755654191dede37da"
}

Response Fields​

FieldTypeDescription
transaction_idstringUser transaction that creates the offer. Poll it with Get User Transaction

Errors​

StatusCodeDescription
40010015Validation failed (wallet_id, quantity, currency_token_id), or unit_price is missing, zero, malformed or finer than the currency's decimals — see details
40010016user_id, token_id or wallet_id is not a valid 24-character hex id
40010001Token not found (domain 5)
40010015Domain 1: wallet does not belong to this user on this network — the wallet does not exist, is not this user's, or is on another chain
40011002The wallet does not hold enough free tokens for this offer (domain 11)
40410001Currency token not found (domain 15)
50010000Unexpected server-side failure

See Errors for the error format and common codes.