Skip to main content
POST
/
subscriptions
/
{subscription_id}
/
refunds
Create a Refund
curl --request POST \
  --url https://sandbox.cashfree.com/pg/subscriptions/{subscription_id}/refunds \
  --header 'Content-Type: application/json' \
  --header 'x-api-version: <x-api-version>' \
  --header 'x-client-id: <api-key>' \
  --header 'x-client-secret: <api-key>' \
  --data '
{
  "subscription_id": "test-subs-id",
  "payment_id": "test-payment-id",
  "refund_id": "dummy-test-refund-id",
  "refund_amount": 10,
  "refund_note": "full refund",
  "refund_speed": "INSTANT",
  "cf_payment_id": 1234235
}
'
import requests

url = "https://sandbox.cashfree.com/pg/subscriptions/{subscription_id}/refunds"

payload = {
"subscription_id": "test-subs-id",
"payment_id": "test-payment-id",
"refund_id": "dummy-test-refund-id",
"refund_amount": 10,
"refund_note": "full refund",
"refund_speed": "INSTANT",
"cf_payment_id": 1234235
}
headers = {
"x-api-version": "<x-api-version>",
"x-client-id": "<api-key>",
"x-client-secret": "<api-key>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {
'x-api-version': '<x-api-version>',
'x-client-id': '<api-key>',
'x-client-secret': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
subscription_id: 'test-subs-id',
payment_id: 'test-payment-id',
refund_id: 'dummy-test-refund-id',
refund_amount: 10,
refund_note: 'full refund',
refund_speed: 'INSTANT',
cf_payment_id: 1234235
})
};

fetch('https://sandbox.cashfree.com/pg/subscriptions/{subscription_id}/refunds', 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://sandbox.cashfree.com/pg/subscriptions/{subscription_id}/refunds",
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([
'subscription_id' => 'test-subs-id',
'payment_id' => 'test-payment-id',
'refund_id' => 'dummy-test-refund-id',
'refund_amount' => 10,
'refund_note' => 'full refund',
'refund_speed' => 'INSTANT',
'cf_payment_id' => 1234235
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-version: <x-api-version>",
"x-client-id: <api-key>",
"x-client-secret: <api-key>"
],
]);

$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://sandbox.cashfree.com/pg/subscriptions/{subscription_id}/refunds"

payload := strings.NewReader("{\n \"subscription_id\": \"test-subs-id\",\n \"payment_id\": \"test-payment-id\",\n \"refund_id\": \"dummy-test-refund-id\",\n \"refund_amount\": 10,\n \"refund_note\": \"full refund\",\n \"refund_speed\": \"INSTANT\",\n \"cf_payment_id\": 1234235\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("x-api-version", "<x-api-version>")
req.Header.Add("x-client-id", "<api-key>")
req.Header.Add("x-client-secret", "<api-key>")
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://sandbox.cashfree.com/pg/subscriptions/{subscription_id}/refunds")
.header("x-api-version", "<x-api-version>")
.header("x-client-id", "<api-key>")
.header("x-client-secret", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"subscription_id\": \"test-subs-id\",\n \"payment_id\": \"test-payment-id\",\n \"refund_id\": \"dummy-test-refund-id\",\n \"refund_amount\": 10,\n \"refund_note\": \"full refund\",\n \"refund_speed\": \"INSTANT\",\n \"cf_payment_id\": 1234235\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://sandbox.cashfree.com/pg/subscriptions/{subscription_id}/refunds")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-version"] = '<x-api-version>'
request["x-client-id"] = '<api-key>'
request["x-client-secret"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"subscription_id\": \"test-subs-id\",\n \"payment_id\": \"test-payment-id\",\n \"refund_id\": \"dummy-test-refund-id\",\n \"refund_amount\": 10,\n \"refund_note\": \"full refund\",\n \"refund_speed\": \"INSTANT\",\n \"cf_payment_id\": 1234235\n}"

response = http.request(request)
puts response.read_body
{
  "payment_id": "pay8643",
  "cf_payment_id": "863782648",
  "refund_id": "refund2",
  "cf_refund_id": "ref_212",
  "refund_amount": 100,
  "refund_note": "test",
  "refund_speed": "INSTANT",
  "refund_status": "INITIALIZED"
}
{
"message": "bad URL, please check API documentation",
"help": "Check latest errors and resolution from Merchant Dashboard API logs: https://bit.ly/4glEd0W Help Document: https://bit.ly/4eeZYO9",
"code": "request_failed",
"type": "invalid_request_error"
}
{
"message": "authentication Failed",
"code": "request_failed",
"type": "authentication_error"
}
{
"message": "something is not found",
"help": "Check latest errors and resolution from Merchant Dashboard API logs: https://bit.ly/4glEd0W Help Document: https://bit.ly/4eeZYO9",
"code": "something_not_found",
"type": "invalid_request_error"
}
{
"message": "something is not found",
"help": "Check latest errors and resolution from Merchant Dashboard API logs: https://bit.ly/4glEd0W Help Document: https://bit.ly/4eeZYO9",
"code": "request_invalid",
"type": "idempotency_error"
}
{
"message": "Too many requests from IP. Check headers",
"code": "request_failed",
"type": "rate_limit_error"
}
{
"message": "internal Server Error",
"help": "Check latest errors and resolution from Merchant Dashboard API logs: https://bit.ly/4glEd0W Help Document: https://bit.ly/4eeZYO9",
"code": "internal_error",
"type": "api_error"
}

Authorizations

x-client-id
string
header
required

Client app ID. You can find your app id in the Merchant Dashboard.

x-client-secret
string
header
required

Client secret key. You can find your secret key in the Merchant Dashboard.

Headers

x-api-version
string
default:2025-01-01
required

API version to be used.

x-request-id
string

Request ID for the API call. Can be used to resolve tech issues. Communicate this in your tech related queries to Cashfree.

x-idempotency-key
string<UUID>

An idempotency key is a unique identifier you include with your API call. If the request fails or times out, you can safely retry it using the same key to avoid duplicate actions.

Path Parameters

subscription_id
string
required

Provide the Subscription ID using which the subscription was created.

Body

application/json

Request parameters to create a subscription refund.

subscription_id
string
required

A unique ID passed by merchant for identifying the subscription.

payment_id
string
required

A unique ID passed by merchant for identifying the transaction.

refund_id
string
required

A unique ID passed by merchant for identifying the refund.

refund_amount
number<float64>
required

The amount to be refunded. Can be partial or full amount of the payment.

cf_payment_id
number<int64>

Cashfree subscription payment reference number.

refund_note
string

Refund note for merchant reference. To simulate refund status in Sandbox, pass SUCCESS, FAILED, PENDING, or ACTIVE in the refund_note field. This is a case-sensitive parameter.

refund_speed
string

Refund speed. Can be INSTANT or STANDARD. UPI supports only STANDARD refunds, Enach and Pnach supports only INSTANT refunds.

Response

Success response for creating a subscription refund.

payment_id
string

A unique ID passed by merchant for identifying the transaction.

cf_payment_id
string

Cashfree subscription payment reference number.

refund_id
string

A unique ID passed by merchant for identifying the refund.

cf_refund_id
string

Cashfree subscription payment refund reference number.

refund_amount
number<float64>

The refund amount.

refund_note
string

Refund note for merchant reference.

refund_speed
string

Refund speed. Can be INSTANT or NORMAL.

refund_status
string

Status of the refund. Can be INITIALIZED, SUCCESS, CANCEL, PENDING or FAILED.