POST
/
v1
/
refunds
/
Typescript (SDK)
import { Polar } from "@polar-sh/sdk";

const polar = new Polar({
  accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});

async function run() {
  const result = await polar.refunds.create({
    orderId: "<value>",
    reason: "customer_request",
    amount: 90,
  });

  console.log(result);
}

run();
{
  "created_at": "2023-11-07T05:31:56Z",
  "modified_at": "2023-11-07T05:31:56Z",
  "id": "<string>",
  "metadata": {},
  "status": "pending",
  "reason": "duplicate",
  "amount": 123,
  "tax_amount": 123,
  "currency": "<string>",
  "organization_id": "<string>",
  "order_id": "<string>",
  "subscription_id": "<string>",
  "customer_id": "<string>",
  "revoke_benefits": true
}

Authorizations

Authorization
string
header
required

You can generate an Organization Access Token from your organization's settings.

Body

application/json
order_id
string<uuid4>
required
reason
enum<string>
required
Available options:
duplicate,
fraudulent,
customer_request,
service_disruption,
satisfaction_guarantee,
other
amount
integer
required

Amount to refund in cents. Minimum is 1.

Required range: x > 0
metadata
object

Key-value object allowing you to store additional information.

The key must be a string with a maximum length of 40 characters. The value must be either:

  • A string with a maximum length of 500 characters
  • An integer
  • A floating-point number
  • A boolean

You can store up to 50 key-value pairs.

comment
string | null

An internal comment about the refund.

revoke_benefits
boolean
default:false

Should this refund trigger the associated customer benefits to be revoked?

Note: Only allowed in case the order is a one-time purchase. Subscriptions automatically revoke customer benefits once the subscription itself is revoked, i.e fully canceled.

Response

Successful Response

created_at
string<date-time>
required

Creation timestamp of the object.

modified_at
string<date-time> | null
required

Last modification timestamp of the object.

id
string<uuid4>
required

The ID of the object.

metadata
object
required
status
enum<string>
required
Available options:
pending,
succeeded,
failed,
canceled
reason
enum<string>
required
Available options:
duplicate,
fraudulent,
customer_request,
service_disruption,
satisfaction_guarantee,
other
amount
integer
required
tax_amount
integer
required
currency
string
required
organization_id
string<uuid4>
required
order_id
string<uuid4>
required
subscription_id
string<uuid4> | null
required
customer_id
string<uuid4>
required
revoke_benefits
boolean
required