# Create Sell Order POST https://api-stg.transak.com/ledger/v1/sell Content-Type: application/json Create a sell order for the selected quote. The API also generates the payload and signature used by the Ledger device to verify transaction data with the corresponding private/public key pair. Reference: https://docs.transak.com/api/ledger-off-ramp/create-sell-order ## OpenAPI Specification ```yaml openapi: 3.1.0 info: title: ledger-off-ramp-api version: 1.0.0 paths: /sell: post: operationId: create-sell-order summary: Create Sell Order description: >- Create a sell order for the selected quote. The API also generates the payload and signature used by the Ledger device to verify transaction data with the corresponding private/public key pair. tags: - '' parameters: - name: x-api-key in: header description: Transak API key available from the Transak Dashboard. required: true schema: type: string responses: '200': description: Sell order created successfully. content: application/json: schema: $ref: '#/components/schemas/SellResponse' '400': description: Missing or invalid request. content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '500': description: Internal server error. content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' requestBody: content: application/json: schema: $ref: '#/components/schemas/SellRequest' servers: - url: https://api-stg.transak.com/ledger/v1 - url: https://api.transak.com/ledger/v1 components: schemas: SellRequest: type: object properties: quoteId: type: string description: Quote identifier returned from the quote endpoint. amount: type: string description: Sell amount in crypto units. refundAddress: type: string description: Refund wallet address. fromCryptoCurrency: type: string description: Ledger-formatted crypto currency identifier. toFiatCurrency: type: string description: Fiat currency code. payloadCryptoCurrency: type: string description: Asset identifier used in the signed Ledger payload. nonce: type: string description: Nonce used for device-side verification. required: - quoteId - amount - refundAddress - fromCryptoCurrency - toFiatCurrency - payloadCryptoCurrency - nonce title: SellRequest ProviderSignature: type: object properties: payload: type: string description: Encoded payload to be verified by the Ledger device. signature: type: string description: Signature corresponding to the generated payload. required: - payload - signature title: ProviderSignature SellResponse: type: object properties: sellId: type: string format: uuid description: Sell order identifier generated by the wrapper. amount: type: string description: Confirmed sell amount. payinAddress: type: string description: Deposit address where the user must send crypto. createdAt: type: string format: date-time description: Sell order creation timestamp. providerFees: type: string description: Provider fee charged for the sell order. referralFees: type: string description: Referral fee charged for the sell order. providerSig: $ref: '#/components/schemas/ProviderSignature' required: - sellId - amount - payinAddress - createdAt - providerFees - referralFees - providerSig title: SellResponse ErrorResponseError: type: object properties: messageKey: type: string message: type: string required: - messageKey - message title: ErrorResponseError ErrorResponse: type: object properties: error: $ref: '#/components/schemas/ErrorResponseError' required: - error title: ErrorResponse securitySchemes: ApiKeyAuth: type: apiKey in: header name: x-api-key description: Transak API key available from the Transak Dashboard. ``` ## SDK Code Examples ```python success import requests url = "https://api-stg.transak.com/ledger/v1/sell" headers = { "x-api-key": "", "Content-Type": "application/json" } response = requests.post(url, headers=headers) print(response.json()) ``` ```javascript success const url = 'https://api-stg.transak.com/ledger/v1/sell'; const options = { method: 'POST', headers: {'x-api-key': '', 'Content-Type': 'application/json'}, body: undefined }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go success package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api-stg.transak.com/ledger/v1/sell" req, _ := http.NewRequest("POST", url, nil) req.Header.Add("x-api-key", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby success require 'uri' require 'net/http' url = URI("https://api-stg.transak.com/ledger/v1/sell") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["x-api-key"] = '' request["Content-Type"] = 'application/json' response = http.request(request) puts response.read_body ``` ```java success import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api-stg.transak.com/ledger/v1/sell") .header("x-api-key", "") .header("Content-Type", "application/json") .asString(); ``` ```php success request('POST', 'https://api-stg.transak.com/ledger/v1/sell', [ 'headers' => [ 'Content-Type' => 'application/json', 'x-api-key' => '', ], ]); echo $response->getBody(); ``` ```csharp success using RestSharp; var client = new RestClient("https://api-stg.transak.com/ledger/v1/sell"); var request = new RestRequest(Method.POST); request.AddHeader("x-api-key", ""); request.AddHeader("Content-Type", "application/json"); IRestResponse response = client.Execute(request); ``` ```swift success import Foundation let headers = [ "x-api-key": "", "Content-Type": "application/json" ] let request = NSMutableURLRequest(url: NSURL(string: "https://api-stg.transak.com/ledger/v1/sell")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ```python request import requests url = "https://api-stg.transak.com/ledger/v1/sell" payload = { "quoteId": "e8720a2a-2b19-4674-a68f-f4fc3d065c64", "amount": "68.99", "refundAddress": "tb1qrefundaddressexample", "fromCryptoCurrency": "bitcoin_testnet", "toFiatCurrency": "EUR", "payloadCryptoCurrency": "BTC", "nonce": "123456" } headers = { "x-api-key": "", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript request const url = 'https://api-stg.transak.com/ledger/v1/sell'; const options = { method: 'POST', headers: {'x-api-key': '', 'Content-Type': 'application/json'}, body: '{"quoteId":"e8720a2a-2b19-4674-a68f-f4fc3d065c64","amount":"68.99","refundAddress":"tb1qrefundaddressexample","fromCryptoCurrency":"bitcoin_testnet","toFiatCurrency":"EUR","payloadCryptoCurrency":"BTC","nonce":"123456"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go request package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api-stg.transak.com/ledger/v1/sell" payload := strings.NewReader("{\n \"quoteId\": \"e8720a2a-2b19-4674-a68f-f4fc3d065c64\",\n \"amount\": \"68.99\",\n \"refundAddress\": \"tb1qrefundaddressexample\",\n \"fromCryptoCurrency\": \"bitcoin_testnet\",\n \"toFiatCurrency\": \"EUR\",\n \"payloadCryptoCurrency\": \"BTC\",\n \"nonce\": \"123456\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("x-api-key", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby request require 'uri' require 'net/http' url = URI("https://api-stg.transak.com/ledger/v1/sell") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["x-api-key"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"quoteId\": \"e8720a2a-2b19-4674-a68f-f4fc3d065c64\",\n \"amount\": \"68.99\",\n \"refundAddress\": \"tb1qrefundaddressexample\",\n \"fromCryptoCurrency\": \"bitcoin_testnet\",\n \"toFiatCurrency\": \"EUR\",\n \"payloadCryptoCurrency\": \"BTC\",\n \"nonce\": \"123456\"\n}" response = http.request(request) puts response.read_body ``` ```java request import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api-stg.transak.com/ledger/v1/sell") .header("x-api-key", "") .header("Content-Type", "application/json") .body("{\n \"quoteId\": \"e8720a2a-2b19-4674-a68f-f4fc3d065c64\",\n \"amount\": \"68.99\",\n \"refundAddress\": \"tb1qrefundaddressexample\",\n \"fromCryptoCurrency\": \"bitcoin_testnet\",\n \"toFiatCurrency\": \"EUR\",\n \"payloadCryptoCurrency\": \"BTC\",\n \"nonce\": \"123456\"\n}") .asString(); ``` ```php request request('POST', 'https://api-stg.transak.com/ledger/v1/sell', [ 'body' => '{ "quoteId": "e8720a2a-2b19-4674-a68f-f4fc3d065c64", "amount": "68.99", "refundAddress": "tb1qrefundaddressexample", "fromCryptoCurrency": "bitcoin_testnet", "toFiatCurrency": "EUR", "payloadCryptoCurrency": "BTC", "nonce": "123456" }', 'headers' => [ 'Content-Type' => 'application/json', 'x-api-key' => '', ], ]); echo $response->getBody(); ``` ```csharp request using RestSharp; var client = new RestClient("https://api-stg.transak.com/ledger/v1/sell"); var request = new RestRequest(Method.POST); request.AddHeader("x-api-key", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"quoteId\": \"e8720a2a-2b19-4674-a68f-f4fc3d065c64\",\n \"amount\": \"68.99\",\n \"refundAddress\": \"tb1qrefundaddressexample\",\n \"fromCryptoCurrency\": \"bitcoin_testnet\",\n \"toFiatCurrency\": \"EUR\",\n \"payloadCryptoCurrency\": \"BTC\",\n \"nonce\": \"123456\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift request import Foundation let headers = [ "x-api-key": "", "Content-Type": "application/json" ] let parameters = [ "quoteId": "e8720a2a-2b19-4674-a68f-f4fc3d065c64", "amount": "68.99", "refundAddress": "tb1qrefundaddressexample", "fromCryptoCurrency": "bitcoin_testnet", "toFiatCurrency": "EUR", "payloadCryptoCurrency": "BTC", "nonce": "123456" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api-stg.transak.com/ledger/v1/sell")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```