> ## Documentation Index
> Fetch the complete documentation index at: https://dodopayments-mintlify-external-integration-datafast-autosen.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Refund

> Create a refund for a payment.



## OpenAPI

````yaml post /refunds
openapi: 3.1.0
info:
  title: public
  description: ''
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
  version: 1.61.5
servers:
  - url: https://test.dodopayments.com/
    description: Test Mode Server Host
  - url: https://live.dodopayments.com/
    description: Live Mode Server Host
security: []
tags:
  - name: Products
  - name: Payments
  - name: Subscriptions
  - name: Addons
  - name: Customers
  - name: Refunds
  - name: Disputes
  - name: Events
  - name: License Keys
  - name: Licenses
  - name: Discounts
  - name: Meters
  - name: Outgoing Webhooks
  - name: Checkout
  - name: Webhook Events
paths:
  /refunds:
    post:
      tags:
        - Refunds
      operationId: create_refund_handler
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateRefundRequest'
        required: true
      responses:
        '200':
          description: Refund successfully initiated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RefundResponse'
        '400':
          description: Invalid Request Parameters
        '422':
          description: Invalid Request Object or Parameters
        '500':
          description: Something went wrong :(
      security:
        - API_KEY: []
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import DodoPayments from 'dodopayments';


            const client = new DodoPayments({
              bearerToken: 'My Bearer Token',
            });


            const refund = await client.refunds.create({ payment_id:
            'payment_id' });


            console.log(refund.business_id);
        - lang: Python
          source: |-
            from dodopayments import DodoPayments

            client = DodoPayments(
                bearer_token="My Bearer Token",
            )
            refund = client.refunds.create(
                payment_id="payment_id",
            )
            print(refund.business_id)
        - lang: Go
          source: |
            package main

            import (
              "context"
              "fmt"

              "github.com/dodopayments/dodopayments-go"
              "github.com/dodopayments/dodopayments-go/option"
            )

            func main() {
              client := dodopayments.NewClient(
                option.WithBearerToken("My Bearer Token"),
              )
              refund, err := client.Refunds.New(context.TODO(), dodopayments.RefundNewParams{
                PaymentID: dodopayments.F("payment_id"),
              })
              if err != nil {
                panic(err.Error())
              }
              fmt.Printf("%+v\n", refund.BusinessID)
            }
        - lang: Java
          source: |-
            package com.dodopayments.api.example;

            import com.dodopayments.api.client.DodoPaymentsClient;
            import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient;
            import com.dodopayments.api.models.refunds.Refund;
            import com.dodopayments.api.models.refunds.RefundCreateParams;

            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    DodoPaymentsClient client = DodoPaymentsOkHttpClient.fromEnv();

                    RefundCreateParams params = RefundCreateParams.builder()
                        .paymentId("payment_id")
                        .build();
                    Refund refund = client.refunds().create(params);
                }
            }
        - lang: Kotlin
          source: |-
            package com.dodopayments.api.example

            import com.dodopayments.api.client.DodoPaymentsClient
            import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient
            import com.dodopayments.api.models.refunds.Refund
            import com.dodopayments.api.models.refunds.RefundCreateParams

            fun main() {
                val client: DodoPaymentsClient = DodoPaymentsOkHttpClient.fromEnv()

                val params: RefundCreateParams = RefundCreateParams.builder()
                    .paymentId("payment_id")
                    .build()
                val refund: Refund = client.refunds().create(params)
            }
        - lang: Ruby
          source: |-
            require "dodopayments"

            dodo_payments = Dodopayments::Client.new(
              bearer_token: "My Bearer Token",
              environment: "test_mode" # defaults to "live_mode"
            )

            refund = dodo_payments.refunds.create(payment_id: "payment_id")

            puts(refund)
components:
  schemas:
    CreateRefundRequest:
      type: object
      required:
        - payment_id
      properties:
        items:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/PartialRefundItem'
          description: Partially Refund an Individual Item
        metadata:
          $ref: '#/components/schemas/Metadata'
          description: Additional metadata associated with the refund.
        payment_id:
          type: string
          description: The unique identifier of the payment to be refunded.
        reason:
          type:
            - string
            - 'null'
          description: >-
            The reason for the refund, if any. Maximum length is 3000
            characters. Optional.
    RefundResponse:
      type: object
      required:
        - refund_id
        - payment_id
        - business_id
        - status
        - created_at
        - is_partial
        - metadata
        - customer
      properties:
        amount:
          type:
            - integer
            - 'null'
          format: int32
          description: The refunded amount.
        business_id:
          type: string
          description: The unique identifier of the business issuing the refund.
        created_at:
          type: string
          format: date-time
          description: The timestamp of when the refund was created in UTC.
        currency:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Currency'
              description: >-
                The currency of the refund, represented as an ISO 4217 currency
                code.
        customer:
          $ref: '#/components/schemas/CustomerLimitedDetailsResponse'
          description: >-
            Details about the customer for this refund (from the associated
            payment)
        is_partial:
          type: boolean
          description: If true the refund is a partial refund
        metadata:
          $ref: '#/components/schemas/Metadata'
          description: Additional metadata stored with the refund.
        payment_id:
          type: string
          description: The unique identifier of the payment associated with the refund.
        reason:
          type:
            - string
            - 'null'
          description: The reason provided for the refund, if any. Optional.
        refund_id:
          type: string
          description: The unique identifier of the refund.
        status:
          $ref: '#/components/schemas/RefundStatus'
          description: The current status of the refund.
    PartialRefundItem:
      type: object
      required:
        - item_id
      properties:
        amount:
          type:
            - integer
            - 'null'
          format: int32
          description: The amount to refund. if None the whole item is refunded
        item_id:
          type: string
          description: The id of the item (i.e. `product_id` or `addon_id`)
        tax_inclusive:
          type: boolean
          description: Specify if tax is inclusive of the refund. Default true.
    Metadata:
      type: object
      additionalProperties:
        type: string
      propertyNames:
        type: string
    Currency:
      type: string
      enum:
        - AED
        - ALL
        - AMD
        - ANG
        - AOA
        - ARS
        - AUD
        - AWG
        - AZN
        - BAM
        - BBD
        - BDT
        - BGN
        - BHD
        - BIF
        - BMD
        - BND
        - BOB
        - BRL
        - BSD
        - BWP
        - BYN
        - BZD
        - CAD
        - CHF
        - CLP
        - CNY
        - COP
        - CRC
        - CUP
        - CVE
        - CZK
        - DJF
        - DKK
        - DOP
        - DZD
        - EGP
        - ETB
        - EUR
        - FJD
        - FKP
        - GBP
        - GEL
        - GHS
        - GIP
        - GMD
        - GNF
        - GTQ
        - GYD
        - HKD
        - HNL
        - HRK
        - HTG
        - HUF
        - IDR
        - ILS
        - INR
        - IQD
        - JMD
        - JOD
        - JPY
        - KES
        - KGS
        - KHR
        - KMF
        - KRW
        - KWD
        - KYD
        - KZT
        - LAK
        - LBP
        - LKR
        - LRD
        - LSL
        - LYD
        - MAD
        - MDL
        - MGA
        - MKD
        - MMK
        - MNT
        - MOP
        - MRU
        - MUR
        - MVR
        - MWK
        - MXN
        - MYR
        - MZN
        - NAD
        - NGN
        - NIO
        - NOK
        - NPR
        - NZD
        - OMR
        - PAB
        - PEN
        - PGK
        - PHP
        - PKR
        - PLN
        - PYG
        - QAR
        - RON
        - RSD
        - RUB
        - RWF
        - SAR
        - SBD
        - SCR
        - SEK
        - SGD
        - SHP
        - SLE
        - SLL
        - SOS
        - SRD
        - SSP
        - STN
        - SVC
        - SZL
        - THB
        - TND
        - TOP
        - TRY
        - TTD
        - TWD
        - TZS
        - UAH
        - UGX
        - USD
        - UYU
        - UZS
        - VES
        - VND
        - VUV
        - WST
        - XAF
        - XCD
        - XOF
        - XPF
        - YER
        - ZAR
        - ZMW
    CustomerLimitedDetailsResponse:
      type: object
      required:
        - customer_id
        - name
        - email
      properties:
        customer_id:
          type: string
          description: Unique identifier for the customer
        email:
          type: string
          description: Email address of the customer
        metadata:
          $ref: '#/components/schemas/Metadata'
          description: Additional metadata associated with the customer
        name:
          type: string
          description: Full name of the customer
        phone_number:
          type:
            - string
            - 'null'
          description: Phone number of the customer
    RefundStatus:
      type: string
      enum:
        - succeeded
        - failed
        - pending
        - review
  securitySchemes:
    API_KEY:
      type: http
      scheme: bearer

````