Create refund for checkout session
Creates a refund against a completed or partially refunded checkout session.
curl -X POST "https://api.example.com/api/v1/sessions/6a2fca3f-fffd-4f3a-8eaf-11af4e21aa7b/refunds" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: example_string" \
-H "Authorization: Bearer YOUR_API_TOKEN (JWT)" \
-d '{
"amount": 45.01,
"reason": "REQUESTED_BY_CUSTOMER",
"lineItems": [
{
"name": "Wireless Headphones",
"sku": "WH-100",
"quantity": 1,
"unitPrice": 119
}
]
}'
import requests
import json
url = "https://api.example.com/api/v1/sessions/6a2fca3f-fffd-4f3a-8eaf-11af4e21aa7b/refunds"
headers = {
"Content-Type": "application/json",
"Idempotency-Key": "example_string",
"Authorization": "Bearer YOUR_API_TOKEN (JWT)"
}
data = {
"amount": 45.01,
"reason": "REQUESTED_BY_CUSTOMER",
"lineItems": [
{
"name": "Wireless Headphones",
"sku": "WH-100",
"quantity": 1,
"unitPrice": 119
}
]
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
const response = await fetch("https://api.example.com/api/v1/sessions/6a2fca3f-fffd-4f3a-8eaf-11af4e21aa7b/refunds", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "example_string",
"Authorization": "Bearer YOUR_API_TOKEN (JWT)"
},
body: JSON.stringify({
"amount": 45.01,
"reason": "REQUESTED_BY_CUSTOMER",
"lineItems": [
{
"name": "Wireless Headphones",
"sku": "WH-100",
"quantity": 1,
"unitPrice": 119
}
]
})
});
const data = await response.json();
console.log(data);
package main
import (
"fmt"
"net/http"
"bytes"
"encoding/json"
)
func main() {
data := []byte(`{
"amount": 45.01,
"reason": "REQUESTED_BY_CUSTOMER",
"lineItems": [
{
"name": "Wireless Headphones",
"sku": "WH-100",
"quantity": 1,
"unitPrice": 119
}
]
}`)
req, err := http.NewRequest("POST", "https://api.example.com/api/v1/sessions/6a2fca3f-fffd-4f3a-8eaf-11af4e21aa7b/refunds", bytes.NewBuffer(data))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Idempotency-Key", "example_string")
req.Header.Set("Authorization", "Bearer YOUR_API_TOKEN (JWT)")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("Response Status:", resp.Status)
}
require 'net/http'
require 'json'
uri = URI('https://api.example.com/api/v1/sessions/6a2fca3f-fffd-4f3a-8eaf-11af4e21aa7b/refunds')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Content-Type'] = 'application/json'
request['Idempotency-Key'] = 'example_string'
request['Authorization'] = 'Bearer YOUR_API_TOKEN (JWT)'
request.body = '{
"amount": 45.01,
"reason": "REQUESTED_BY_CUSTOMER",
"lineItems": [
{
"name": "Wireless Headphones",
"sku": "WH-100",
"quantity": 1,
"unitPrice": 119
}
]
}'
response = http.request(request)
puts response.body
{
"refundId": "3d72f30c-2977-44bf-b2e8-ff09b9b3216d",
"sessionId": "6a2fca3f-fffd-4f3a-8eaf-11af4e21aa7b",
"status": "PENDING",
"amount": 45.01,
"currency": "USD",
"reason": "REQUESTED_BY_CUSTOMER",
"failureReason": "PAYMENT_FAILED",
"createdAt": "2026-04-24T12:30:00.000Z"
}
{
"refundId": "3d72f30c-2977-44bf-b2e8-ff09b9b3216d",
"sessionId": "6a2fca3f-fffd-4f3a-8eaf-11af4e21aa7b",
"status": "PENDING",
"amount": 45.01,
"currency": "USD",
"reason": "REQUESTED_BY_CUSTOMER",
"failureReason": "PAYMENT_FAILED",
"createdAt": "2026-04-24T12:30:00.000Z"
}
{
"error": "Bad Request",
"message": "Missing required header: Idempotency-Key",
"statusCode": 400
}
{
"error": "Bad Request",
"message": [
"amount must not be less than 0.01"
],
"statusCode": 400
}
{
"error": "Unauthorized",
"message": "Authentication required. Please provide a valid API token",
"code": 401
}
{
"error": "Not Found",
"message": "The requested resource was not found",
"code": 404
}
{
"error": "Conflict",
"message": "The request conflicts with the current state of the resource",
"code": 409,
"details": "Resource already exists"
}
{
"message": "This idempotency key was already used with different request parameters",
"statusCode": 422,
"code": "IDEMPOTENCY_KEY_MISMATCH"
}
{
"message": "Session is not in a refundable state",
"statusCode": 422
}
{
"message": "Requested amount exceeds remaining refundable balance",
"statusCode": 422
}
{
"error": "Internal Server Error",
"message": "An unexpected error occurred on the server",
"code": 500,
"requestId": "req_1234567890"
}
{
"message": "Bad Gateway",
"statusCode": 502
}
{
"error": "Error",
"message": "Request timed out.",
"code": 504
}
/api/v1/sessions/{sessionId}/refundsTarget server for requests. Edit to use your own host.
Bearer token (JWT) - just enter the token, "Bearer" prefix will be added automatically
Checkout session ID.
The media type of the request body
Client-generated unique key used to safely retry refund creation. Can be any opaque string up to 255 characters.
Refund amount in major currency units; must not exceed remaining refundable balance. When omitted, refunds the full remaining balance for the session.
Optional refund reason.
Request Preview
Response
Response will appear here after sending the request
Authentication
Bearer token (JWT). Authentication token required.
Path Parameters
Headers
Client-generated unique key used to safely retry refund creation. Can be any opaque string up to 255 characters.
Body
Refund amount in major currency units; must not exceed remaining refundable balance. When omitted, refunds the full remaining balance for the session.
45.01