--- url: https://docs.youcan.shop/youcan-pay/refunds/create.md --- # Create a Refund Refund all or part of a transaction. **Required scope (OAuth only):** `create-refund` ## Parameters | Parameter | Type | Description | | --- | --- | --- | | `transaction_id` | string required | The unique identifier of the transaction to refund. | | `amount` | number required | The amount to refund, in the transaction's own currency and minor units. | | `reason` | string required | Accepted values: `duplicate`, `fraudulent`, `requested-by-customer`. | | `note` | string optional | An optional note about the refund. | ## Returns Returns the created refund object if the request was successful. ## Request **Endpoint:** `https://youcanpay.com/api/v2/refunds` **Method:** `POST` ```bash $ curl --location --request POST 'https://youcanpay.com/api/v2/refunds' \ --form 'transaction_id="10e7691c-14a2-4936-833b-ec154c817ce9"' \ --form 'amount="6000"' \ --form 'reason="requested-by-customer"' \ --form 'note="Customer changed their mind"' \ --header 'Accept: application/json' \ -u 'YOUR_PRIVATE_KEY:' ``` ## Response ```json { "object": "v2.refund", "id": "83cd9f6d-481a-49c4-9cc1-954c065e6063", "transaction_id": "10e7691c-14a2-4936-833b-ec154c817ce9", "amount": { "amount": "60.00", "currency": "MAD", "localized": "MAD 60.00" }, "status": "pending", "is_processed": false, "reason": "requested-by-customer", "note": "Customer changed their mind", "processed_at": "2024-01-29 15:15:12" } ``` ## Errors | Error | Description | | --- | --- | | Transaction not found | The `transaction_id` doesn't match any transaction on your account. | | Fully refunded | The transaction has already been fully refunded. | | Exceeds available balance | The requested `amount` is greater than what's available to refund. | | Not refundable | The transaction is a CashPlus transaction, has already been paid out, or is otherwise not eligible for refund. |