Cancel Order
curl --request POST \
--url https://api.prime.coinbase.com/v1/portfolios/{portfolio_id}/orders/{order_id}/cancelimport requests
url = "https://api.prime.coinbase.com/v1/portfolios/{portfolio_id}/orders/{order_id}/cancel"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.prime.coinbase.com/v1/portfolios/{portfolio_id}/orders/{order_id}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.prime.coinbase.com/v1/portfolios/{portfolio_id}/orders/{order_id}/cancel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.prime.coinbase.com/v1/portfolios/{portfolio_id}/orders/{order_id}/cancel"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.prime.coinbase.com/v1/portfolios/{portfolio_id}/orders/{order_id}/cancel")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.prime.coinbase.com/v1/portfolios/{portfolio_id}/orders/{order_id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_body{
"id": "82c879c1-84e1-44ed-a8c2-1ac239cf09ad"
}Orders
Cancel Order
Cancel an order. (Filled orders cannot be canceled.)
POST
/
v1
/
portfolios
/
{portfolio_id}
/
orders
/
{order_id}
/
cancel
Cancel Order
curl --request POST \
--url https://api.prime.coinbase.com/v1/portfolios/{portfolio_id}/orders/{order_id}/cancelimport requests
url = "https://api.prime.coinbase.com/v1/portfolios/{portfolio_id}/orders/{order_id}/cancel"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.prime.coinbase.com/v1/portfolios/{portfolio_id}/orders/{order_id}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.prime.coinbase.com/v1/portfolios/{portfolio_id}/orders/{order_id}/cancel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.prime.coinbase.com/v1/portfolios/{portfolio_id}/orders/{order_id}/cancel"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.prime.coinbase.com/v1/portfolios/{portfolio_id}/orders/{order_id}/cancel")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.prime.coinbase.com/v1/portfolios/{portfolio_id}/orders/{order_id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_body{
"id": "82c879c1-84e1-44ed-a8c2-1ac239cf09ad"
}Use the Prime SDK or CLI to test this endpoint by following the quickstart guide and running with the following examples
For more information, please visit the Prime Java SDK.For more information, please visit the Prime .NET SDK.For more information, please visit the Prime Go SDK.For more information, please visit the Prime Python SDK.For more information, please visit the Prime CLI.For more information, please visit the Prime TS SDK.
- Java
- .NET
- Go
- Python
- CLI
- TS/JS
OrdersService ordersService = PrimeServiceFactory.cancelOrdersService(client);
CancelOrderRequest request = new CancelOrderRequest.Builder()
.portfolioId("PORTFOLIO_ID_HERE")
.orderId("ORDER_ID_HERE")
.build());
CancelOrderResponse orderResponse = ordersService.cancelOrder(request);
var ordersService = new OrdersService(client);
var request = new CancelOrderRequest("PORTFOLIO_ID_HERE", "ORDER_ID_HERE");
var cancelOrderResponse = orderService.CancelOrder(request);
ordersService := orders.NewOrdersService(client)
request := &orders.CancelOrderRequest{
PortfolioId: "PORTFOLIO_ID_HERE",
OrderId: "ORDER_ID_HERE",
}
response, err := ordersService.CancelOrder(context.Background(), request)
prime_client = PrimeClient(credentials)
request = CancelOrderRequest(
portfolio_id="PORTFOLIO_ID_HERE",
order_id="ORDER_ID_HERE",
)
response = prime_client.cancel_order(request)
primectl cancel-order --help
const ordersService = new OrdersService(client);
orderService.cancelOrder({
portfolioId: 'PORTFOLIO_ID_HERE',
orderId: 'ORDER_ID_HERE',
}).then(async (response) => {
console.log('Order canceled: ', response);
})
Path Parameters
The ID of the portfolio under which the order was placed
The order ID generated by Coinbase upon order submission
Response
200 - application/json
A successful response.
The unique UUID for the order
Example:
"82c879c1-84e1-44ed-a8c2-1ac239cf09ad"
Was this page helpful?
⌘I