curl --request POST \
--url https://api.cnaught.com/v1/orders/{id}/cancel \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.cnaught.com/v1/orders/{id}/cancel"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.cnaught.com/v1/orders/{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.cnaught.com/v1/orders/{id}/cancel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$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.cnaught.com/v1/orders/{id}/cancel"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
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.cnaught.com/v1/orders/{id}/cancel")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cnaught.com/v1/orders/{id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": "Gre28Fc35bt3",
"order_number": "47726-53238-46633-33562-7433",
"created_on": "2022-08-01T18:00:00.000000Z",
"metadata": "Customer metadata",
"description": "On behalf of Jane Smith",
"amount_kg": 10.5,
"state": "cancelled",
"price_usd_cents": 2350,
"certificate_public_url": null,
"certificate_download_public_url": null
}{
"title": "Authorization has been denied for this request",
"status": 401
}{
"type": "https://api.cnaught.com/v1/errors/forbidden",
"title": "Order xyz has already been cancelled",
"status": 403
}{
"type": "https://api.cnaught.com/v1/errors/not-found",
"title": "Could not find order",
"status": 404
}{
"type": "https://api.cnaught.com/v1/errors/idempotency-concurrent-requests",
"title": "Concurrent request in flight with same idempotency key",
"status": 409
}{
"type": "https://api.cnaught.com/v1/errors/idempotency-changed-payload",
"title": "Previous request submitted with same idempotency key had different payload",
"status": 422
}Cancel Order
When cancelling an order that has been fulfilled, a credit for the price of the order will be applied to the current invoice. This means that it is possible for the credit for a cancellation to appear on the invoice of the following billing period. For example, if a billing period ends between when the order was placed and when it is cancelled, then the credit will be applied to the latter billing period rather than the one during which the order was placed.
curl --request POST \
--url https://api.cnaught.com/v1/orders/{id}/cancel \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.cnaught.com/v1/orders/{id}/cancel"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.cnaught.com/v1/orders/{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.cnaught.com/v1/orders/{id}/cancel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$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.cnaught.com/v1/orders/{id}/cancel"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
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.cnaught.com/v1/orders/{id}/cancel")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cnaught.com/v1/orders/{id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": "Gre28Fc35bt3",
"order_number": "47726-53238-46633-33562-7433",
"created_on": "2022-08-01T18:00:00.000000Z",
"metadata": "Customer metadata",
"description": "On behalf of Jane Smith",
"amount_kg": 10.5,
"state": "cancelled",
"price_usd_cents": 2350,
"certificate_public_url": null,
"certificate_download_public_url": null
}{
"title": "Authorization has been denied for this request",
"status": 401
}{
"type": "https://api.cnaught.com/v1/errors/forbidden",
"title": "Order xyz has already been cancelled",
"status": 403
}{
"type": "https://api.cnaught.com/v1/errors/not-found",
"title": "Could not find order",
"status": 404
}{
"type": "https://api.cnaught.com/v1/errors/idempotency-concurrent-requests",
"title": "Concurrent request in flight with same idempotency key",
"status": 409
}{
"type": "https://api.cnaught.com/v1/errors/idempotency-changed-payload",
"title": "Previous request submitted with same idempotency key had different payload",
"status": 422
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Headers
If present, will only cancel the order if it belongs to the subaccount with given id.
If present, a unique identifier that allows you to retry a request multiple times while only performing the action once. See Idempotency for more info.
Path Parameters
ID of order to cancel
"Gre28Fc35bt3"
Response
Order Details
Identifier that can be used to retrieve the order details
"Gre28Fc35bt3"
Hex representation derived from the order id that will be shown on the certificate
"47726-53238-46633-33562-7433"
Timestamp of when the order was created (in UTC)
Optional metadata that was provided with the order
512"internal_order_id=12345"
Optional public description for the order that will be shown on the certificate, as provided when order was placed
512"on behalf of Jane Smith"
Amount of credits purchased, in kg of CO₂e
10.5
The current state of the order.
placed- the order has been placed, and is waiting to be matched against available credits in our system.fulfilled- the order has been fulfilled by matching it against available credits in our system, which have been retired.canceled- the order has been canceled
placed, fulfilled, cancelled Amount charged for the credits purchased, in USD cents
2350
Callback URL to invoke when status of the order changes, if specified in the order
URL for the publicly accessible page showing order details and the certificate. This will be null if the order state is cancelled
"https://registry.cnaught.com/orders/ABCDE"
URL for downloading the certificate PDF. This will be null if the order state is cancelled
"https://registry.cnaught.com/api/certificates/ABCDE/pdf"
For fulfilled orders, a list of the projects that were used to fulfill the order
Show child attributes
Show child attributes
Id of the checkout session whose completion resulted in the creation of this order. Null if the order did not originate from a checkout session.
"zpQ6QSNRQh"