Refunds
Refund payments received through Payment Links or UPL. A refund works like a payment link in reverse. You create a refund, which gives you a refund link whose recipient is the original payer. The agent then pays that link over x402 (usually with a mandate), and the funds go back to the payer.
All management endpoints require Authorization: Bearer <agent-jwt>.
Refund flow overview
Agent FluxA API
|-- POST /refunds/initiate --->|
|<-- refundUrl (plr_…) --------|
|-- GET refundUrl ------------>|
|<-- 402 (payTo = payer) ------|
|-- sign (x402V3Payment) ----->|
|-- GET refundUrl + X-Payment->|
|<-- 200 { refund.txHash } ----|- Initiate. Call
POST /api/payment-links/refunds/initiatewith the originalpaymentId. The refund starts aspendingand you get arefundUrlthat's valid for 24 hours. - Get the 402.
GETtherefundUrl. The 402 response haspayToset to the original payer's address. - Pay. Sign the payment (for example with
x402V3Paymentand a USDC mandate) and send it in theX-Paymentheader. - Done. The refund becomes
settled.
TIP
In a refund link, payTo is the original payer. That is the key difference from a normal payment link.
Refund status
status | Meaning |
|---|---|
pending | Created and waiting for you to pay the refund link. refundUrl is set only in this state. |
processing | A refund payment was submitted and is being confirmed. Don't pay again. |
settled | The refund was paid to the original payer. refundTxHash is set. |
failed | The refund didn't go through. |
expired | The refund link expired before it was paid. |
cancelled | You cancelled the refund. |
Treat any other value as processing.
Initiate refund
POST/api/payment-links/refunds/initiateBearer agent-jwtcurl -X POST https://walletapi.fluxapay.xyz/api/payment-links/refunds/initiate \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $JWT_TOKEN" \
-d '{
"paymentId": 43,
"amount": "1000000",
"reason": "Customer requested refund"
}'Request fields
| Field | Type | Required | Description |
|---|---|---|---|
paymentId | number | Yes | ID of the original payment: id from Received payments or Get payments for a link. |
amount | string | No | Refund amount in atomic units. Leave it out for a full refund of what's still refundable. |
reason | string | No | Reason for the refund. It's shown in the refund link's description. |
Response (201)
{
"refundId": "plr_abc123xyz456",
"refundUrl": "https://walletapi.fluxapay.xyz/refundlink/plr_abc123xyz456",
"paymentId": 43,
"amount": "1000000",
"currency": "USDC",
"network": "base",
"refundFrom": "0xLinkOwnerAddress",
"refundTo": "0xOriginalPayerAddress",
"refundType": "full",
"reason": "Customer requested refund",
"status": "pending",
"expiresAt": "2026-10-28T12:00:00.000Z",
"createdAt": "2026-10-27T12:00:00.000Z"
}Error responses
| Status | Body | When |
|---|---|---|
| 400 | { "error": "paymentId is required ..." } | paymentId is missing or invalid. |
| 400 | { "error", "code": "credits_refund_unsupported" } | Credits payments can't be refunded. |
| 400 | { "error": "Only settled payments can be refunded" } | The original payment hasn't completed. |
| 400 | { "error": "Cannot refund: original payer address is unknown" } | The payer can't be identified. |
| 400 | { "error": "Refund amount exceeds remaining refundable amount", "originalAmount", "totalRefunded", "remainingRefundable", "requestedAmount" } | Over-refund. |
| 404 | { "error": "Payment not found or does not belong to you" } | Unknown payment, or a payment this agent didn't receive. |
| 409 | { "error": "An active refund already exists for this payment", "existingRefundId", "existingStatus", "existingAmount" } | Each payment can have only one open refund at a time. Finish or cancel it first. |
Example over-refund body:
{
"error": "Refund amount exceeds remaining refundable amount",
"originalAmount": "5000000",
"totalRefunded": "3000000",
"remainingRefundable": "2000000",
"requestedAmount": "3000000"
}Public refund link endpoint (x402)
GET/refundlink/:refundIdThis is a public endpoint and needs no authentication. Paying this URL sends the funds back to the original payer.
Step 1: Get the refund payment requirements
curl -i https://walletapi.fluxapay.xyz/refundlink/plr_abc123xyz456Response (402 Payment Required):
{
"error": "Payment Required",
"x402Version": 1,
"accepts": [
{
"scheme": "exact",
"network": "eip155:8453",
"maxAmountRequired": "1000000",
"resource": "/refundlink/plr_abc123xyz456",
"description": "Refund: Customer requested refund",
"mimeType": "application/json",
"outputSchema": {},
"payTo": "0xOriginalPayerAddress",
"maxTimeoutSeconds": 60,
"asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"extra": { "name": "USD Coin", "version": "2" }
}
]
}Step 2: Submit the refund payment
Sign the payment, for example by passing these fields to x402V3Payment with a mandate. Then retry the same GET with the result in the X-Payment header (Payment-Signature is also accepted).
curl -i https://walletapi.fluxapay.xyz/refundlink/plr_abc123xyz456 \
-H "X-Payment: $X_PAYMENT_B64"Outcomes
| Status | Body | What to do |
|---|---|---|
200 | { "status": "success", "refund": { "refundId", "txHash", "amount", "currency", "refundTo" } } | Done. The receipt is also in the X-Payment-Response header. |
202 | { "error": "Refund settlement result is unknown", "status": "processing" } | The refund is being confirmed. Don't pay again. Poll Get refund detail. |
402 | { "error": "Refund payment failed", "reason": "..." } | The payment was rejected. The refund stays pending. Sign a new payment and retry. Use reason for logs only. |
404 | { "error": "Refund link not found" } | Unknown refund. |
410 | { "error": "...", "status": "settled" | "processing" | "failed" | "expired" | "cancelled" } | The refund can no longer be paid. |
Example 200:
{
"status": "success",
"refund": {
"refundId": "plr_abc123xyz456",
"txHash": "0xRefundTxHash...",
"amount": "1000000",
"currency": "USDC",
"refundTo": "0xOriginalPayerAddress"
}
}List refunds
GET/api/payment-links/refundsBearer agent-jwtList refunds created by this agent, newest first.
curl "https://walletapi.fluxapay.xyz/api/payment-links/refunds?limit=20&offset=0" \
-H "Authorization: Bearer $JWT_TOKEN"| Param | Type | Default | Description |
|---|---|---|---|
limit | number | 20 | Maximum number of results (up to 100). |
offset | number | 0 | Pagination offset. |
Response (200)
{
"refunds": [
{
"refundId": "plr_abc123xyz456",
"refundUrl": null,
"paymentId": 43,
"linkId": "pl_abc123",
"sourceType": "payment_link",
"amount": "1000000",
"currency": "USDC",
"network": "base",
"refundFrom": "0xLinkOwnerAddress",
"refundTo": "0xOriginalPayerAddress",
"status": "settled",
"refundTxHash": "0xRefundTxHash...",
"refundType": "full",
"reason": "Customer requested refund",
"originalAmount": "1000000",
"originalTxHash": "0xOriginalTxHash...",
"agentName": "My Agent",
"expiresAt": "2026-10-28T12:00:00.000Z",
"createdAt": "2026-10-27T12:00:00.000Z"
}
]
}Response fields
| Field | Type | Description |
|---|---|---|
refundId | string | Refund ID (plr_…). |
refundUrl | string | null | Refund link. Set only while pending. |
paymentId | number | ID of the original payment. |
linkId | string | null | Payment Link ID, or null for UPL payments. |
sourceType | string | payment_link or unify_payment_link. |
amount | string | Refund amount in atomic units. |
currency / network | string | Currency and network. |
refundFrom | string | Your receiving address, which the original payment went to. |
refundTo | string | Refund recipient (the original payer). |
status | string | See Refund status. |
refundTxHash | string | null | On-chain refund transaction hash. |
refundType | string | full or partial. |
reason | string | null | Refund reason. |
originalAmount | string | Amount of the original payment. |
originalTxHash | string | null | Transaction hash of the original payment. |
agentName | string | null | Name of the agent that started the refund. |
expiresAt | string | When the refund link expires (ISO 8601). |
createdAt | string | When the refund was created (ISO 8601). |
Get refund detail
GET/api/payment-links/refunds/:refundIdBearer agent-jwtcurl https://walletapi.fluxapay.xyz/api/payment-links/refunds/plr_abc123xyz456 \
-H "Authorization: Bearer $JWT_TOKEN"Response (200): the same shape as one entry in the list response. Returns 404 if the refund doesn't exist or wasn't created by this agent.
Cancel refund
POST/api/payment-links/refunds/:refundId/cancelBearer agent-jwtCancel a refund that hasn't been paid yet. Only pending refunds can be cancelled.
curl -X POST https://walletapi.fluxapay.xyz/api/payment-links/refunds/plr_abc123xyz456/cancel \
-H "Authorization: Bearer $JWT_TOKEN"Response (200):
{
"success": true,
"refundId": "plr_abc123xyz456",
"status": "cancelled",
"updatedAt": "2026-10-27T12:05:00.000Z"
}| Status | Body | When |
|---|---|---|
| 404 | { "error": "Refund not found" } | Unknown refund. |
| 409 | { "error": "Only pending refunds can be cancelled", "status": "..." } | The refund is no longer pending. |
| 409 | { "error": "Refund has already expired", "status": "expired" } | The refund link expired. |
| 409 | { "error": "Refund can no longer be cancelled", "status": "..." } | A payment for the refund arrived while you were cancelling. |
