post
/premium/refund-latestRefund latest purchase
Refunds the authenticated user's most recent paid invoice if it is within 3 days and the user is not in a 30-day cooldown. If the invoice was tied to a subscription, the subscription is cancelled immediately.
self_serve_refund_latest_purchase
Responses
200
Success
json
{
"type": "object",
"properties": {
"invoice_id": {
"type": "string"
},
"payment_intent_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
},
"charge_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
},
"refund_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
},
"refunded_amount_cents": {
"type": "integer",
"format": "int53"
},
"invoice_amount_paid_cents": {
"type": "integer",
"format": "int53"
},
"currency": {
"type": "string"
},
"subscription_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"description": "Subscription that was cancelled along with the refund, when applicable"
}
},
"required": [
"invoice_id",
"payment_intent_id",
"charge_id",
"refund_id",
"refunded_amount_cents",
"invoice_amount_paid_cents",
"currency",
"subscription_id"
]
}400
Bad Request - The request was malformed or contained invalid data
json
{
"type": "object",
"properties": {
"code": {
"$ref": "#/components/schemas/APIErrorCode"
},
"message": {
"type": "string",
"description": "Human-readable error message"
},
"errors": {
"type": "array",
"description": "Field-specific validation errors",
"items": {
"$ref": "#/components/schemas/ValidationErrorItem"
}
}
},
"required": [
"code",
"message"
]
}401
Unauthorized - Authentication is required or the token is invalid
json
{
"type": "object",
"properties": {
"code": {
"$ref": "#/components/schemas/APIErrorCode"
},
"message": {
"type": "string",
"description": "Human-readable error message"
},
"errors": {
"type": "array",
"description": "Field-specific validation errors",
"items": {
"$ref": "#/components/schemas/ValidationErrorItem"
}
}
},
"required": [
"code",
"message"
]
}403
Forbidden - You do not have permission to perform this action
json
{
"type": "object",
"properties": {
"code": {
"$ref": "#/components/schemas/APIErrorCode"
},
"message": {
"type": "string",
"description": "Human-readable error message"
},
"errors": {
"type": "array",
"description": "Field-specific validation errors",
"items": {
"$ref": "#/components/schemas/ValidationErrorItem"
}
}
},
"required": [
"code",
"message"
]
}429
Too Many Requests - You are being rate limited
json
{
"type": "object",
"properties": {
"code": {
"type": "string",
"enum": [
"RATE_LIMITED"
]
},
"message": {
"type": "string"
},
"retry_after": {
"type": "number",
"description": "Seconds to wait before retrying"
},
"global": {
"type": "boolean",
"description": "Whether this is a global rate limit"
}
},
"required": [
"code",
"message",
"retry_after"
]
}500
Internal Server Error - An unexpected error occurred
json
{
"type": "object",
"properties": {
"code": {
"$ref": "#/components/schemas/APIErrorCode"
},
"message": {
"type": "string",
"description": "Human-readable error message"
},
"errors": {
"type": "array",
"description": "Field-specific validation errors",
"items": {
"$ref": "#/components/schemas/ValidationErrorItem"
}
}
},
"required": [
"code",
"message"
]
}