Gifts
Redeem Gift Subscription
Redeem a gift code to activate a subscription for a recipient customer.
POST
/
v1
/
gifts
/
redeem
Redeem a gift code
curl --request POST \
--url https://billing.example.com/v1/gifts/redeem \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "<string>",
"recipient_customer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
'import requests
url = "https://billing.example.com/v1/gifts/redeem"
payload = {
"code": "<string>",
"recipient_customer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
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({
code: '<string>',
recipient_customer_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a'
})
};
fetch('https://billing.example.com/v1/gifts/redeem', 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/redeem",
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([
'code' => '<string>',
'recipient_customer_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
]),
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://billing.example.com/v1/gifts/redeem"
payload := strings.NewReader("{\n \"code\": \"<string>\",\n \"recipient_customer_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\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://billing.example.com/v1/gifts/redeem")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"<string>\",\n \"recipient_customer_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/gifts/redeem")
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 \"code\": \"<string>\",\n \"recipient_customer_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"plan_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "trialing",
"current_period_start": "2023-11-07T05:31:56Z",
"current_period_end": "2023-11-07T05:31:56Z",
"cancel_at_period_end": true,
"canceled_at": "2023-11-07T05:31:56Z",
"cancellation_reason": "<string>",
"cancellation_feedback": "<string>",
"billing_anchor": "2023-11-07T05:31:56Z",
"billing_anchor_type": "<string>",
"billing_anchor_day": 123,
"payment_terms": "<string>",
"coupon_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"reference_id": "<string>",
"mandate_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"razorpay_subscription_id": "<string>",
"stripe_subscription_id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
code | string | Yes | The unique gift code to redeem (e.g. GIFT-AB12-CD34-EF56). |
recipient_customer_id | string (UUID) | Yes | The ID of the customer who will receive the subscription. |
Example Request
curl -X POST https://api.recurso.dev/v1/gifts/redeem \
-H "Authorization: Bearer rsk_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"code": "GIFT-AB12-CD34-EF56",
"recipient_customer_id": "cust_a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}'
Response
Returns the subscription object created from the redeemed gift.{
"id": "sub_9f8e7d6c5b4a3210",
"object": "subscription",
"customer_id": "cust_a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"plan_id": "plan_pro_monthly",
"status": "active",
"gift_code": "GIFT-AB12-CD34-EF56",
"gifted_by": "cust_f0e1d2c3-b4a5-6789-0abc-def123456789",
"current_period_start": "2026-06-23T00:00:00Z",
"current_period_end": "2026-12-23T00:00:00Z",
"cancel_at_period_end": true,
"created_at": "2026-06-23T10:15:30Z",
"updated_at": "2026-06-23T10:15:30Z"
}
Each gift code can only be redeemed once. Attempting to redeem an already-used code
returns a
422 validation error.Gift subscriptions automatically expire at the end of the gifted period. The
cancel_at_period_end flag is set to true by default. The recipient can convert
to a paid subscription before the gift period ends.Authorizations
Tenant API key obtained from POST /auth/register or POST /v1/developer/keys.
Response
The subscription created by the redemption.
Available options:
trialing, active, past_due, paused, canceled, unpaid ⌘I
Redeem a gift code
curl --request POST \
--url https://billing.example.com/v1/gifts/redeem \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "<string>",
"recipient_customer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
'import requests
url = "https://billing.example.com/v1/gifts/redeem"
payload = {
"code": "<string>",
"recipient_customer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
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({
code: '<string>',
recipient_customer_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a'
})
};
fetch('https://billing.example.com/v1/gifts/redeem', 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/redeem",
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([
'code' => '<string>',
'recipient_customer_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
]),
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://billing.example.com/v1/gifts/redeem"
payload := strings.NewReader("{\n \"code\": \"<string>\",\n \"recipient_customer_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\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://billing.example.com/v1/gifts/redeem")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"<string>\",\n \"recipient_customer_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/gifts/redeem")
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 \"code\": \"<string>\",\n \"recipient_customer_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"plan_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "trialing",
"current_period_start": "2023-11-07T05:31:56Z",
"current_period_end": "2023-11-07T05:31:56Z",
"cancel_at_period_end": true,
"canceled_at": "2023-11-07T05:31:56Z",
"cancellation_reason": "<string>",
"cancellation_feedback": "<string>",
"billing_anchor": "2023-11-07T05:31:56Z",
"billing_anchor_type": "<string>",
"billing_anchor_day": 123,
"payment_terms": "<string>",
"coupon_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"reference_id": "<string>",
"mandate_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"razorpay_subscription_id": "<string>",
"stripe_subscription_id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}