Gifts
Cancel Gift
Cancel a purchased-but-unredeemed gift, crediting the buyer if they paid or voiding the open purchase invoice if they did not.
POST
/
v1
/
gifts
/
{id}
/
cancel
Cancel an unredeemed gift (buyer gets account credit)
curl --request POST \
--url https://billing.example.com/v1/gifts/{id}/cancel \
--header 'Authorization: Bearer <token>'import requests
url = "https://billing.example.com/v1/gifts/{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://billing.example.com/v1/gifts/{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://billing.example.com/v1/gifts/{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://billing.example.com/v1/gifts/{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://billing.example.com/v1/gifts/{id}/cancel")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/gifts/{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{
"data": {
"gift": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"code": "<string>",
"plan_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"buyer_customer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"recipient_email": "<string>",
"status": "purchased",
"redeemed_by_customer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"redeemed_at": "2023-11-07T05:31:56Z",
"duration_months": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
},
"credit_note": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"invoice_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"entity_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"reference": "<string>",
"amount": 123,
"subtotal": 123,
"tax_amount": 123,
"igst_amount": 123,
"cgst_amount": 123,
"sgst_amount": 123,
"tax_type": "<string>",
"hsn_code": "<string>",
"balance": 123,
"currency": "<string>",
"status": "issued",
"reason": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"customer": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"email": "jsmith@example.com",
"name": "<string>",
"phone": "<string>",
"tax_id": "<string>",
"billing_address": {
"line1": "<string>",
"line2": "<string>",
"postal_code": "<string>",
"city": "<string>",
"state": "<string>",
"zip": "<string>",
"country": "<string>"
},
"ledger_account_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"gstin": "<string>",
"tax_type": "<string>",
"place_of_supply": "<string>",
"tax_exempt": true,
"tax_exemption_number": "<string>",
"tax_exemption_code": "<string>",
"tax_exemption_expires_at": "2023-12-25",
"referral_code": "<string>",
"risk_score": 50,
"risk_factors": {},
"card_brand": "<string>",
"card_last4": "<string>",
"card_exp_month": 123,
"card_exp_year": 123,
"card_token_id": "<string>",
"card_fingerprint": "<string>",
"created_at": "2023-11-07T05:31:56Z"
}
},
"invoice_voided": true
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}Cancels a gift that was purchased but not
yet redeemed, and settles the buyer’s money according to the state of the
purchase invoice after the cancel:
No request body.
Errors use the standard envelope — see Errors.
- Invoice paid — a spendable adjustment credit note for the purchase
amount is issued to the buyer through the normal credit-note path, so
approval governance and ledger postings apply. The note is returned as
credit_noteand can be tracked with Get Credit Note. - Invoice still open — nothing was collected, so the invoice is voided
instead and
invoice_voidedistrue. No credit is issued. - Invoice already void or canceled (for example, voided by hand earlier)
— nothing is owed, so nothing is credited or voided:
credit_noteis omitted andinvoice_voidedisfalse. This is a normal200, not an error.
status: "canceled" and its code can no longer be
redeemed. The transition from purchased to canceled is atomic and happens
exactly once: a redeemed gift cannot be canceled, and a second cancel is
refused, so the buyer credit can never issue twice. Gifts purchased before
invoice linking existed carry no invoice_id; cancelling one changes the
status but neither credits nor voids anything.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string (UUID) | Yes | Gift ID (path). Must belong to your tenant — see List Gifts |
Example Request
curl -X POST https://api.recurso.dev/v1/gifts/6f1c2a9e-8b4d-4e7f-a3c5-9d0e1f2a3b4c/cancel \
-H "Authorization: Bearer $API_KEY"
Response
A paid gift returns the canceled gift and the buyer’s credit note. For an open (unpaid) giftcredit_note is omitted and invoice_voided is true.
When the purchase invoice was already void or canceled, or the gift has no
invoice_id, both are absent/false and only gift carries information.
{
"data": {
"gift": {
"id": "6f1c2a9e-8b4d-4e7f-a3c5-9d0e1f2a3b4c",
"tenant_id": "2b9e1c44-7d3a-4f6b-8e21-5c0d9a7f1b33",
"code": "GIFT-QN7XL3MTKW",
"plan_id": "b1c2d3e4-f5a6-4b7c-8d9e-0f1a2b3c4d5e",
"buyer_customer_id": "a8b9c0d1-e2f3-4a5b-6c7d-8e9f0a1b2c3d",
"recipient_email": "priya.sharma@example.com",
"status": "canceled",
"redeemed_by_customer_id": null,
"redeemed_at": null,
"invoice_id": "d2e3f4a5-b6c7-4d8e-9f0a-1b2c3d4e5f60",
"duration_months": 12,
"created_at": "2026-06-20T09:15:00Z",
"updated_at": "2026-09-04T11:42:07Z"
},
"credit_note": {
"id": "c7d8e9f0-a1b2-4c3d-8e4f-5a6b7c8d9e01",
"tenant_id": "2b9e1c44-7d3a-4f6b-8e21-5c0d9a7f1b33",
"customer_id": "a8b9c0d1-e2f3-4a5b-6c7d-8e9f0a1b2c3d",
"invoice_id": "d2e3f4a5-b6c7-4d8e-9f0a-1b2c3d4e5f60",
"amount": 5880000,
"balance": 5880000,
"currency": "INR",
"status": "issued",
"reason": "Gift GIFT-QN7XL3MTKW canceled — purchase credited",
"type": "adjustment",
"refund_status": "none",
"created_at": "2026-09-04T11:42:07Z",
"updated_at": "2026-09-04T11:42:07Z"
},
"invoice_voided": false
}
}
Fields
| Field | Type | Description |
|---|---|---|
gift | object | The gift after cancellation |
gift.id | string (UUID) | Gift ID |
gift.tenant_id | string (UUID) | Owning tenant |
gift.code | string | Redemption code; no longer redeemable |
gift.plan_id | string (UUID) | The plan the gift would have activated |
gift.buyer_customer_id | string (UUID) | The customer who bought the gift and receives the credit |
gift.recipient_email | string | Intended recipient |
gift.status | string | Always canceled after this call. Other gift states are purchased and redeemed |
gift.redeemed_by_customer_id / gift.redeemed_at | string, null | Always null — only unredeemed gifts can be canceled |
gift.invoice_id | string (UUID) | The buyer’s purchase invoice the credit or void was applied against; omitted for gifts purchased before invoice linking |
gift.duration_months | integer | Length of the gifted subscription |
gift.created_at / gift.updated_at | string (RFC 3339) | Timestamps |
credit_note | object | The spendable adjustment credit issued to the buyer when the purchase invoice was paid. Omitted otherwise. Same shape as Get Credit Note: amount and balance in minor units, status may be pending_approval when credit-note approval governance is on |
invoice_voided | boolean | true when the purchase invoice was still open and was voided instead of credited. false when a credit note was issued, when the invoice was already void or canceled, or when the gift has no linked invoice |
Errors
| Status | Code | When | Fix |
|---|---|---|---|
400 | validation_failed | id is not a valid UUID | Pass the gift’s UUID |
401 | unauthorized | Missing or invalid API key / session | Send Authorization: Bearer $API_KEY |
404 | not_found | No gift with that ID in your tenant | Check the ID against List Gifts |
409 | conflict | The gift is already redeemed, or already canceled | Nothing to do — a redeemed gift stays with its recipient; a canceled gift has already been settled |
424 | internal_error | The gift was canceled but issuing the buyer’s credit failed | Issue a manual credit note to the buyer for the purchase amount — the cancel has taken effect and will not be retried |
500 | internal_error | Loading the gift, flipping its status, or resolving its purchase invoice after the flip failed. The body is always the fixed message internal error — it does not say whether the status flip took effect; the detail is only in the API logs | Re-read the gift via List Gifts: if it is still purchased, retry; if it is already canceled, the cancel took effect but the purchase invoice may still be open or paid — void or credit it manually |
503 | internal_error | Credit issuance is not wired on this deployment, so a paid gift cannot be canceled | Enable the credit-note service on the API |
⌘I
Cancel an unredeemed gift (buyer gets account credit)
curl --request POST \
--url https://billing.example.com/v1/gifts/{id}/cancel \
--header 'Authorization: Bearer <token>'import requests
url = "https://billing.example.com/v1/gifts/{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://billing.example.com/v1/gifts/{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://billing.example.com/v1/gifts/{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://billing.example.com/v1/gifts/{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://billing.example.com/v1/gifts/{id}/cancel")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/gifts/{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{
"data": {
"gift": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"code": "<string>",
"plan_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"buyer_customer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"recipient_email": "<string>",
"status": "purchased",
"redeemed_by_customer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"redeemed_at": "2023-11-07T05:31:56Z",
"duration_months": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
},
"credit_note": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"invoice_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"entity_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"reference": "<string>",
"amount": 123,
"subtotal": 123,
"tax_amount": 123,
"igst_amount": 123,
"cgst_amount": 123,
"sgst_amount": 123,
"tax_type": "<string>",
"hsn_code": "<string>",
"balance": 123,
"currency": "<string>",
"status": "issued",
"reason": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"customer": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"email": "jsmith@example.com",
"name": "<string>",
"phone": "<string>",
"tax_id": "<string>",
"billing_address": {
"line1": "<string>",
"line2": "<string>",
"postal_code": "<string>",
"city": "<string>",
"state": "<string>",
"zip": "<string>",
"country": "<string>"
},
"ledger_account_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"gstin": "<string>",
"tax_type": "<string>",
"place_of_supply": "<string>",
"tax_exempt": true,
"tax_exemption_number": "<string>",
"tax_exemption_code": "<string>",
"tax_exemption_expires_at": "2023-12-25",
"referral_code": "<string>",
"risk_score": 50,
"risk_factors": {},
"card_brand": "<string>",
"card_last4": "<string>",
"card_exp_month": 123,
"card_exp_year": 123,
"card_token_id": "<string>",
"card_fingerprint": "<string>",
"created_at": "2023-11-07T05:31:56Z"
}
},
"invoice_voided": true
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}