# Cancel Order DELETE https://api-gateway-stg.transak.com/api/v2/orders/{orderid} The **Cancel Order** is an **authenticated API** that allows users to **cancel an existing order** before payment is completed. This API is useful for cases where **users change their mind, enter incorrect details, or experience payment issues**. Once an order is **successfully canceled**, it cannot be **reversed**, and a new order must be placed. Reference: https://docs.transak.com/api/whitelabel/orders/cancel-order ## OpenAPI Specification ```yaml openapi: 3.1.0 info: title: whitelabel-api version: 1.0.0 paths: /api/v2/orders/{orderid}: delete: operationId: cancel-order summary: Cancel Order description: >- The **Cancel Order** is an **authenticated API** that allows users to **cancel an existing order** before payment is completed. This API is useful for cases where **users change their mind, enter incorrect details, or experience payment issues**. Once an order is **successfully canceled**, it cannot be **reversed**, and a new order must be placed. tags: - subpackage_orders parameters: - name: orderid in: path description: orderId is the id received from the API - `api/v2/orders` required: true schema: type: string default: 467b702d-81c4-4f05-aff2-31ef7ebcc83c - name: cancelReason in: query description: Reason to Cancel the order required: true schema: type: string default: User requested cancellation - name: authorization in: header description: >- Authorization token is the accessToken received from the API -` api/v2/auth/verify` required: true schema: type: string default: USER_AUTHORIZATION_TOKEN - name: x-user-identifier in: header description: >- Your authenticated user Email Id address. Note: This is applicable only for [Auth Reliance Flows](/features/auth-reliance) required: false schema: type: string default: USER_EMAIL_ID - name: x-access-token in: header description: > Your Partner Access Token. Please refer [here](/guides/how-to-create-partner-access-token) for a tutorial on generating your access token. Note: This is applicable only for [Auth Reliance Flows](/features/auth-reliance) required: false schema: type: string default: YOUR_ACCESS_TOKEN responses: '200': description: 200 - Success content: application/json: schema: $ref: '#/components/schemas/Orders_cancel-order_Response_200' '400': description: 400 - Invalid Order id content: application/json: schema: $ref: '#/components/schemas/Cancel-orderRequestBadRequestError' '401': description: 401 - Unauthorized content: application/json: schema: $ref: '#/components/schemas/Cancel-orderRequestUnauthorizedError' '500': description: 500 - Internal Server Error content: application/json: schema: $ref: '#/components/schemas/Cancel-orderRequestInternalServerError' servers: - url: https://api-gateway-stg.transak.com components: schemas: ApiV2OrdersOrderidDeleteResponsesContentApplicationJsonSchemaDataPaymentDetailsItemsFieldsItems: type: object properties: name: type: string value: type: string required: - name - value title: >- ApiV2OrdersOrderidDeleteResponsesContentApplicationJsonSchemaDataPaymentDetailsItemsFieldsItems ApiV2OrdersOrderidDeleteResponsesContentApplicationJsonSchemaDataPaymentDetailsItems: type: object properties: currency: type: string id: type: string name: type: string fields: type: array items: $ref: >- #/components/schemas/ApiV2OrdersOrderidDeleteResponsesContentApplicationJsonSchemaDataPaymentDetailsItemsFieldsItems required: - currency - id - name - fields title: >- ApiV2OrdersOrderidDeleteResponsesContentApplicationJsonSchemaDataPaymentDetailsItems ApiV2OrdersOrderidDeleteResponsesContentApplicationJsonSchemaDataCardPaymentDataPgDataPaymentOptionsItemsFieldsItems: type: object properties: name: type: string value: type: string required: - name - value title: >- ApiV2OrdersOrderidDeleteResponsesContentApplicationJsonSchemaDataCardPaymentDataPgDataPaymentOptionsItemsFieldsItems ApiV2OrdersOrderidDeleteResponsesContentApplicationJsonSchemaDataCardPaymentDataPgDataPaymentOptionsItems: type: object properties: currency: type: string id: type: string name: type: string fields: type: array items: $ref: >- #/components/schemas/ApiV2OrdersOrderidDeleteResponsesContentApplicationJsonSchemaDataCardPaymentDataPgDataPaymentOptionsItemsFieldsItems required: - currency - id - name - fields title: >- ApiV2OrdersOrderidDeleteResponsesContentApplicationJsonSchemaDataCardPaymentDataPgDataPaymentOptionsItems ApiV2OrdersOrderidDeleteResponsesContentApplicationJsonSchemaDataCardPaymentDataPgData: type: object properties: liquidityProvider: type: string status: type: string beneficiaryName: type: string paymentOptions: type: array items: $ref: >- #/components/schemas/ApiV2OrdersOrderidDeleteResponsesContentApplicationJsonSchemaDataCardPaymentDataPgDataPaymentOptionsItems required: - liquidityProvider - status - beneficiaryName - paymentOptions title: >- ApiV2OrdersOrderidDeleteResponsesContentApplicationJsonSchemaDataCardPaymentDataPgData ApiV2OrdersOrderidDeleteResponsesContentApplicationJsonSchemaDataCardPaymentData: type: object properties: orderId: type: string paymentId: type: string pgData: $ref: >- #/components/schemas/ApiV2OrdersOrderidDeleteResponsesContentApplicationJsonSchemaDataCardPaymentDataPgData liquidityProvider: type: string updatedAt: type: string required: - orderId - paymentId - pgData - liquidityProvider - updatedAt title: >- ApiV2OrdersOrderidDeleteResponsesContentApplicationJsonSchemaDataCardPaymentData ApiV2OrdersOrderidDeleteResponsesContentApplicationJsonSchemaData: type: object properties: orderId: type: string walletAddress: type: string status: type: string fiatCurrency: type: string partnerUserId: type: string cryptoCurrency: type: string isBuyOrSell: type: string fiatAmount: type: integer ipAddress: type: string amountPaid: type: integer paymentMethod: type: string walletLink: type: string quoteId: type: string orderProcessingType: type: string addressAdditionalData: type: boolean network: type: string conversionPrice: type: number format: double cryptoAmount: type: number format: double totalFeeInFiat: type: integer fiatAmountInUsd: type: number format: double countryCode: type: string paymentDetails: type: array items: $ref: >- #/components/schemas/ApiV2OrdersOrderidDeleteResponsesContentApplicationJsonSchemaDataPaymentDetailsItems autoExpiresAt: type: string campaignAmount: type: integer campaignAmountInUsd: type: integer tfPerOff: type: integer aTtlFees: type: integer aTskFees: type: integer stateCode: type: string orderChannelType: type: string tokenContractAddress: type: string userKycType: type: string cardPaymentData: $ref: >- #/components/schemas/ApiV2OrdersOrderidDeleteResponsesContentApplicationJsonSchemaDataCardPaymentData lastNotifiedAt: type: string cancelReason: type: string required: - orderId - walletAddress - status - fiatCurrency - partnerUserId - cryptoCurrency - isBuyOrSell - fiatAmount - ipAddress - amountPaid - paymentMethod - walletLink - quoteId - orderProcessingType - addressAdditionalData - network - conversionPrice - cryptoAmount - totalFeeInFiat - fiatAmountInUsd - countryCode - paymentDetails - autoExpiresAt - campaignAmount - campaignAmountInUsd - tfPerOff - aTtlFees - aTskFees - stateCode - orderChannelType - tokenContractAddress - userKycType - cardPaymentData - lastNotifiedAt - cancelReason title: ApiV2OrdersOrderidDeleteResponsesContentApplicationJsonSchemaData Orders_cancel-order_Response_200: type: object properties: data: $ref: >- #/components/schemas/ApiV2OrdersOrderidDeleteResponsesContentApplicationJsonSchemaData required: - data title: Orders_cancel-order_Response_200 ApiV2OrdersOrderidDeleteResponsesContentApplicationJsonSchemaError: type: object properties: statusCode: type: integer message: type: string required: - statusCode - message title: ApiV2OrdersOrderidDeleteResponsesContentApplicationJsonSchemaError Cancel-orderRequestBadRequestError: type: object properties: error: $ref: >- #/components/schemas/ApiV2OrdersOrderidDeleteResponsesContentApplicationJsonSchemaError required: - error title: Cancel-orderRequestBadRequestError Cancel-orderRequestUnauthorizedError: type: object properties: error: $ref: >- #/components/schemas/ApiV2OrdersOrderidDeleteResponsesContentApplicationJsonSchemaError required: - error title: Cancel-orderRequestUnauthorizedError Cancel-orderRequestInternalServerError: type: object properties: error: $ref: >- #/components/schemas/ApiV2OrdersOrderidDeleteResponsesContentApplicationJsonSchemaError required: - error title: Cancel-orderRequestInternalServerError ``` ## SDK Code Examples ```python Success import requests url = "https://api-gateway-stg.transak.com/api/v2/orders/467b702d-81c4-4f05-aff2-31ef7ebcc83c" querystring = {"cancelReason":"User requested cancellation"} headers = { "authorization": "USER_AUTHORIZATION_TOKEN", "x-user-identifier": "USER_EMAIL_ID", "x-access-token": "YOUR_ACCESS_TOKEN" } response = requests.delete(url, headers=headers, params=querystring) print(response.json()) ``` ```javascript Success const url = 'https://api-gateway-stg.transak.com/api/v2/orders/467b702d-81c4-4f05-aff2-31ef7ebcc83c?cancelReason=User+requested+cancellation'; const options = { method: 'DELETE', headers: { authorization: 'USER_AUTHORIZATION_TOKEN', 'x-user-identifier': 'USER_EMAIL_ID', 'x-access-token': 'YOUR_ACCESS_TOKEN' } }; 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-gateway-stg.transak.com/api/v2/orders/467b702d-81c4-4f05-aff2-31ef7ebcc83c?cancelReason=User+requested+cancellation" req, _ := http.NewRequest("DELETE", url, nil) req.Header.Add("authorization", "USER_AUTHORIZATION_TOKEN") req.Header.Add("x-user-identifier", "USER_EMAIL_ID") req.Header.Add("x-access-token", "YOUR_ACCESS_TOKEN") 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-gateway-stg.transak.com/api/v2/orders/467b702d-81c4-4f05-aff2-31ef7ebcc83c?cancelReason=User+requested+cancellation") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Delete.new(url) request["authorization"] = 'USER_AUTHORIZATION_TOKEN' request["x-user-identifier"] = 'USER_EMAIL_ID' request["x-access-token"] = 'YOUR_ACCESS_TOKEN' 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.delete("https://api-gateway-stg.transak.com/api/v2/orders/467b702d-81c4-4f05-aff2-31ef7ebcc83c?cancelReason=User+requested+cancellation") .header("authorization", "USER_AUTHORIZATION_TOKEN") .header("x-user-identifier", "USER_EMAIL_ID") .header("x-access-token", "YOUR_ACCESS_TOKEN") .asString(); ``` ```php Success request('DELETE', 'https://api-gateway-stg.transak.com/api/v2/orders/467b702d-81c4-4f05-aff2-31ef7ebcc83c?cancelReason=User+requested+cancellation', [ 'headers' => [ 'authorization' => 'USER_AUTHORIZATION_TOKEN', 'x-access-token' => 'YOUR_ACCESS_TOKEN', 'x-user-identifier' => 'USER_EMAIL_ID', ], ]); echo $response->getBody(); ``` ```csharp Success using RestSharp; var client = new RestClient("https://api-gateway-stg.transak.com/api/v2/orders/467b702d-81c4-4f05-aff2-31ef7ebcc83c?cancelReason=User+requested+cancellation"); var request = new RestRequest(Method.DELETE); request.AddHeader("authorization", "USER_AUTHORIZATION_TOKEN"); request.AddHeader("x-user-identifier", "USER_EMAIL_ID"); request.AddHeader("x-access-token", "YOUR_ACCESS_TOKEN"); IRestResponse response = client.Execute(request); ``` ```swift Success import Foundation let headers = [ "authorization": "USER_AUTHORIZATION_TOKEN", "x-user-identifier": "USER_EMAIL_ID", "x-access-token": "YOUR_ACCESS_TOKEN" ] let request = NSMutableURLRequest(url: NSURL(string: "https://api-gateway-stg.transak.com/api/v2/orders/467b702d-81c4-4f05-aff2-31ef7ebcc83c?cancelReason=User+requested+cancellation")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "DELETE" 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() ```