Invoices
Cancel an Invoice
Only invoices in sent/overdue status can be cancelled.
POST
/
v1
/
invoices
/
{id}
/
cancel
Cancel an Invoice
curl --request POST \
--url https://api.bookeeping.ai/public-api/v1/invoices/{id}/cancel \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"cancellationReason": "<string>"
}
'import requests
url = "https://api.bookeeping.ai/public-api/v1/invoices/{id}/cancel"
payload = { "cancellationReason": "<string>" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({cancellationReason: '<string>'})
};
fetch('https://api.bookeeping.ai/public-api/v1/invoices/{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.bookeeping.ai/public-api/v1/invoices/{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_POSTFIELDS => json_encode([
'cancellationReason' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.bookeeping.ai/public-api/v1/invoices/{id}/cancel"
payload := strings.NewReader("{\n \"cancellationReason\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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.bookeeping.ai/public-api/v1/invoices/{id}/cancel")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"cancellationReason\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.bookeeping.ai/public-api/v1/invoices/{id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"cancellationReason\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"message": "<string>",
"metaData": {
"warnings": [
"<string>"
]
},
"data": {
"_id": "<string>",
"projectId": "<string>",
"invoiceId": "<string>",
"discount": {
"value": 123
},
"amount": 123,
"invoiceDate": "2023-11-07T05:31:56Z",
"dueDate": "2023-11-07T05:31:56Z",
"currency": "<string>",
"lineItems": [
{
"id": "<string>",
"name": "<string>",
"quantity": 123,
"unitPrice": 123,
"tax": {
"value": 123
},
"discount": {
"value": 123
},
"description": "<string>"
}
],
"note": "<string>",
"calculated": {
"grandTotal": 123,
"tax": 123,
"discount": 123,
"subTotal": 123
},
"attachments": [
"<string>"
],
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"purchaseOrderId": "<string>",
"counterParty": {
"_id": "<string>",
"accountName": "<string>",
"accountNumber": "<string>",
"email": "jsmith@example.com",
"phone": "<string>",
"otherEmails": [
"jsmith@example.com"
],
"address": {
"city": "<string>",
"country": "<string>",
"state": "<string>",
"cca2": "<string>",
"line1": "<string>",
"line2": "<string>",
"postalCode": "<string>"
}
},
"convertedAmount": 123,
"convertedCurrency": "<string>",
"sendDate": "2023-11-07T05:31:56Z",
"sendBy": "<string>",
"cancellationReason": "<string>",
"cancellationDate": "2023-11-07T05:31:56Z",
"cancellationBy": "<string>",
"paidMarkedBy": "<string>",
"paidMarkedDate": "2023-11-07T05:31:56Z",
"attachedTransactionId": "<string>",
"payViaStripeAccountConnectionId": "<string>"
}
}{
"error": "BadRequestError",
"message": "<string>"
}{
"error": "UnauthorizedError",
"message": "<string>"
}{
"error": "ConflictError",
"message": "<string>"
}{
"error": "TooManyRequestsError",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}Authorizations
API key for authentication. Get your key from the Dashboard > Settings > API Access.
Path Parameters
The id of the invoice. Expected to be a valid object id like 666666666666666666666666
Pattern:
^[0-9A-Fa-f]{24}$Body
application/json
The reason for cancellation
⌘I
Cancel an Invoice
curl --request POST \
--url https://api.bookeeping.ai/public-api/v1/invoices/{id}/cancel \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"cancellationReason": "<string>"
}
'import requests
url = "https://api.bookeeping.ai/public-api/v1/invoices/{id}/cancel"
payload = { "cancellationReason": "<string>" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({cancellationReason: '<string>'})
};
fetch('https://api.bookeeping.ai/public-api/v1/invoices/{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.bookeeping.ai/public-api/v1/invoices/{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_POSTFIELDS => json_encode([
'cancellationReason' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.bookeeping.ai/public-api/v1/invoices/{id}/cancel"
payload := strings.NewReader("{\n \"cancellationReason\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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.bookeeping.ai/public-api/v1/invoices/{id}/cancel")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"cancellationReason\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.bookeeping.ai/public-api/v1/invoices/{id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"cancellationReason\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"message": "<string>",
"metaData": {
"warnings": [
"<string>"
]
},
"data": {
"_id": "<string>",
"projectId": "<string>",
"invoiceId": "<string>",
"discount": {
"value": 123
},
"amount": 123,
"invoiceDate": "2023-11-07T05:31:56Z",
"dueDate": "2023-11-07T05:31:56Z",
"currency": "<string>",
"lineItems": [
{
"id": "<string>",
"name": "<string>",
"quantity": 123,
"unitPrice": 123,
"tax": {
"value": 123
},
"discount": {
"value": 123
},
"description": "<string>"
}
],
"note": "<string>",
"calculated": {
"grandTotal": 123,
"tax": 123,
"discount": 123,
"subTotal": 123
},
"attachments": [
"<string>"
],
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"purchaseOrderId": "<string>",
"counterParty": {
"_id": "<string>",
"accountName": "<string>",
"accountNumber": "<string>",
"email": "jsmith@example.com",
"phone": "<string>",
"otherEmails": [
"jsmith@example.com"
],
"address": {
"city": "<string>",
"country": "<string>",
"state": "<string>",
"cca2": "<string>",
"line1": "<string>",
"line2": "<string>",
"postalCode": "<string>"
}
},
"convertedAmount": 123,
"convertedCurrency": "<string>",
"sendDate": "2023-11-07T05:31:56Z",
"sendBy": "<string>",
"cancellationReason": "<string>",
"cancellationDate": "2023-11-07T05:31:56Z",
"cancellationBy": "<string>",
"paidMarkedBy": "<string>",
"paidMarkedDate": "2023-11-07T05:31:56Z",
"attachedTransactionId": "<string>",
"payViaStripeAccountConnectionId": "<string>"
}
}{
"error": "BadRequestError",
"message": "<string>"
}{
"error": "UnauthorizedError",
"message": "<string>"
}{
"error": "ConflictError",
"message": "<string>"
}{
"error": "TooManyRequestsError",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}