FX Cancel an order
Cancel an order
Cancels a `waiting_approval` or `pending` order whose debit is not in progress. Cancelling does not return money that was already debited; contact support for that. The request has no body.
Api-Key
Path parameters
NameDescription
order_idThe
order_id returned when the order was createdHeaders
NameDescription
Idempotency-Key1 to 255 printable ASCII characters. A retry with the same key within 24 hours returns the first response, including a 400. After you correct a request, send a new key.
Response
Returns 200 OK. The order is cancelled
NameDescription
dataShow 2 child attributesobject
idstatusPossible values:
cancellederrorErrors
| Status | Meaning |
|---|---|
| 200 | The order is cancelled |
| 400 | The order is not found, already final, or its debit is in progress |
Was this page helpful? Yes No
Previous
Request
cURLJavaScriptPythonGoRubyPHPJavaC#cURL
curl --request POST \
--url 'https://api.gravv.xyz/v1/fx/orders/2d4f6a8c-1b3d-4e5f-8a7b-9c0d1e2f3a4b/cancel' \
--header 'Api-Key: <api-key>' \
--header 'Idempotency-Key: usd-xaf-order-1042'
const response = await fetch('https://api.gravv.xyz/v1/fx/orders/2d4f6a8c-1b3d-4e5f-8a7b-9c0d1e2f3a4b/cancel', {
method: 'POST',
headers: {
'Api-Key': '<api-key>',
'Idempotency-Key': 'usd-xaf-order-1042',
},
});
const data = await response.json();
console.log(response.status, data);
import requests
url = "https://api.gravv.xyz/v1/fx/orders/2d4f6a8c-1b3d-4e5f-8a7b-9c0d1e2f3a4b/cancel"
headers = {
"Api-Key": "<api-key>",
"Idempotency-Key": "usd-xaf-order-1042",
}
response = requests.post(url, headers=headers)
print(response.status_code)
print(response.json())
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
req, err := http.NewRequest("POST", "https://api.gravv.xyz/v1/fx/orders/2d4f6a8c-1b3d-4e5f-8a7b-9c0d1e2f3a4b/cancel", nil)
if err != nil {
panic(err)
}
req.Header.Set("Api-Key", "<api-key>")
req.Header.Set("Idempotency-Key", "usd-xaf-order-1042")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
panic(err)
}
fmt.Println(res.Status)
fmt.Println(string(body))
}
require "net/http"
require "uri"
uri = URI("https://api.gravv.xyz/v1/fx/orders/2d4f6a8c-1b3d-4e5f-8a7b-9c0d1e2f3a4b/cancel")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
request = Net::HTTP::Post.new(uri)
request["Api-Key"] = "<api-key>"
request["Idempotency-Key"] = "usd-xaf-order-1042"
response = http.request(request)
puts response.code
puts response.body
<?php
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'https://api.gravv.xyz/v1/fx/orders/2d4f6a8c-1b3d-4e5f-8a7b-9c0d1e2f3a4b/cancel',
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Api-Key: <api-key>',
'Idempotency-Key: usd-xaf-order-1042',
],
]);
$response = curl_exec($ch);
if ($response === false) {
throw new RuntimeException(curl_error($ch));
}
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch);
echo $status, PHP_EOL, $response, PHP_EOL;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.gravv.xyz/v1/fx/orders/2d4f6a8c-1b3d-4e5f-8a7b-9c0d1e2f3a4b/cancel"))
.header("Api-Key", "<api-key>")
.header("Idempotency-Key", "usd-xaf-order-1042")
.method("POST", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode());
System.out.println(response.body());
}
}
using System.Net.Http;
using System.Text;
using var client = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Post, "https://api.gravv.xyz/v1/fx/orders/2d4f6a8c-1b3d-4e5f-8a7b-9c0d1e2f3a4b/cancel");
request.Headers.TryAddWithoutValidation("Api-Key", "<api-key>");
request.Headers.TryAddWithoutValidation("Idempotency-Key", "usd-xaf-order-1042");
using var response = await client.SendAsync(request);
Console.WriteLine((int)response.StatusCode);
Console.WriteLine(await response.Content.ReadAsStringAsync());
Responseapplication/json
200400OK
{
"data": {
"id": "2d4f6a8c-1b3d-4e5f-8a7b-9c0d1e2f3a4b",
"status": "cancelled"
},
"error": null
}
{
"data": null,
"error": "order cannot be cancelled in status: completed"
}