# Upsert a dispute

`PUT /disputes/{id}`

> This is a subset of the full specification, limited to the `PUT /disputes/{id}` operation.
>
> You can find the full specification here: /_bundle/docs/dev-docs/api/index.yaml

```yaml
openapi: 3.1.1
info:
  version: latest
  title: Core APIs
  contact:
    name: Rebilly API Support
    url: https://www.rebilly.com/contact/
    email: integrations@rebilly.com
  license:
    name: Rebilly
    url: https://www.rebilly.com/api-license/
  termsOfService: https://www.rebilly.com/terms-of-use/
  x-logo:
    url: https://rebilly-core.redoc.ly/rb_apiLogo.svg
    backgroundColor: '#0044d4'
  description: This is a subset of the full specification, limited to the `PUT /disputes/{id}` operation.
  x-metadata:
    description: The most common APIs used to automate common workflows.
    redocly_category: API Reference
servers:
  - url: https://api-sandbox.rebilly.com/organizations/{organizationId}
    description: Sandbox server
    variables:
      organizationId:
        default: '{organizationId}'
        description: |-
          Unique organization identifier.
          An organization is an entity that represents a company.
          For more information, see [Obtain an organization ID](https://www.rebilly.com/docs/settings/organizations-and-websites/#obtain-your-organization-id-and-website-id).
  - url: https://api.rebilly.com/organizations/{organizationId}
    description: Live server
    variables:
      organizationId:
        default: '{organizationId}'
        description: |-
          Unique organization identifier.
          An organization is an entity that represents a company.
          For more information, see [Obtain an organization ID](https://www.rebilly.com/docs/settings/organizations-and-websites/#obtain-your-organization-id-and-website-id).
security:
  - SecretApiKey: []
  - JWT: []
tags:
  - name: Disputes
    description: |-
      Use these operations to manage disputes.
      A dispute occurs when a customer contests a charge to their account.
      The dispute and related information is made available to the merchant by the bank or credit card company.
      The merchant then has the option to represent the charge and win the case.
      This process is called dispute resolution.
      If the merchant is unable to represent the charge, the card issuer typically reverses the sale and adds fees on top of the charge.
      This process is called a chargeback.
x-tagGroups:
  - name: Payments
    tags:
      - Disputes
paths:
  /disputes/{id}:
    parameters:
      - $ref: '#/components/parameters/resourceId'
    put:
      x-products:
        - Core
      tags:
        - Disputes
      summary: Upsert a dispute
      operationId: PutDispute
      x-sdk-operation-name: update
      description: Creates or updates (upserts) a dispute with a specified ID.
      requestBody:
        $ref: '#/components/requestBodies/Dispute'
      responses:
        '200':
          description: Dispute updated.
          headers:
            Rate-Limit-Limit:
              $ref: '#/components/headers/Rate-Limit-Limit'
            Rate-Limit-Remaining:
              $ref: '#/components/headers/Rate-Limit-Remaining'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Dispute'
        '201':
          description: Dispute created.
          headers:
            Location:
              $ref: '#/components/headers/Location'
            Rate-Limit-Limit:
              $ref: '#/components/headers/Rate-Limit-Limit'
            Rate-Limit-Remaining:
              $ref: '#/components/headers/Rate-Limit-Remaining'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Dispute'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/ValidationError'
        '429':
          $ref: '#/components/responses/TooManyRequests'
      x-codeSamples:
        - lang: PHP
          label: PHP-SDK-2.0
          source: |
            $disputeForm = new Rebilly\Entities\Dispute();
            $disputeForm->setTransactionId('transactionId');
            $disputeForm->setCurrency('USD');
            $disputeForm->setAmount(10);
            $disputeForm->setReasonCode(1000);
            $disputeForm->setType($disputeForm::TYPE_1CB);
            $disputeForm->setStatus($disputeForm::STATUS_RESPONSE_NEEDED);
            $disputeForm->setPostedTime('2025-01-01 05:00:00');

            try {
                $dispute = $client->disputes()->update('disputeId', $dispute);
            } catch (Rebilly\Http\Exception\DataValidationException $e) {
                print_r($e->getValidationErrors());
            }
        - lang: JavaScript
          source: |
            // creating a dispute
            const data = {
                transactionId: 'my-transaction-id',
                currency: 'USD',
                amount: 5,
                reasonCode: '1000',
                type: 'first-chargeback',
                status: 'response-needed',
                acquirerReferenceNumber: '143543',
                postedTime: '2017-09-19T20:46:48Z',
                deadlineTime: '2017-09-19T20:46:48Z'
            };

            // the ID is optional
            const firstdispute = await api.disputes.create({data});

            // or you can provide one
            const secondDispute = await api.disputes.create({id: 'my-second-id', data});



            // updating a dispute
            const updateData = {
                transactionId: 'my-other-transaction-id',
                currency: 'USD',
                amount: 5,
                reasonCode: '1000',
                type: 'first-chargeback',
                status: 'response-needed',
                acquirerReferenceNumber: '143543',
                postedTime: '2017-09-19T20:46:48Z',
                deadlineTime: '2017-09-19T20:46:48Z'
            };

            const dispute = await api.disputes.update({id: 'my-second-id', data: updateData});
        - lang: PHP
          source: |-
            $service = new \Rebilly\Sdk\Service($client);

            $disputeForm = new \Rebilly\Sdk\Model\PostDisputeRequest();
            $disputeForm->setTransactionId('transactionId');
            $disputeForm->setCurrency('USD');
            $disputeForm->setAmount(10);
            $disputeForm->setReasonCode('1000');
            $disputeForm->setType($disputeForm::TYPE_INFORMATION_REQUEST);
            $disputeForm->setStatus($disputeForm::STATUS_RESPONSE_NEEDED);
            $disputeForm->setPostedTime('2025-01-01 05:00:00');

            try {
                $dispute = $service->disputes()->update('disputeId', $disputeForm);
            } catch (\Rebilly\Sdk\Exception\DataValidationException $e) {
                print_r($e->getValidationErrors());
            }
components:
  securitySchemes:
    JWT:
      description: |-
        JWT is a short lifetime token that can be assigned a specific expiration time.

        Usage format: `Bearer <JWT>`.
      type: http
      scheme: bearer
      bearerFormat: JWT
    SecretApiKey:
      description: |-
        Never share your secret keys.
        Keep them guarded and secure.

        Use your secret API key only to make requests from the server side.
        To authenticate, provide your secret key in the request header.
      name: REB-APIKEY
      type: apiKey
      in: header
  parameters:
    resourceId:
      name: id
      in: path
      description: ID of the resource.
      required: true
      schema:
        type: string
        maxLength: 50
        pattern: ^[@~\-\.\w]+$
  headers:
    Location:
      description: Location of the related resource.
      schema:
        type: string
        format: uri
      example: https://api.rebilly.com/example
    Rate-Limit-Limit:
      description: |-
        Maximum number of requests available at one time for this rate limit.
        For more information, see [Rate limits](#section/Rate-limits).
      schema:
        type: integer
      example: 500
    Rate-Limit-Remaining:
      description: |-
        Number of requests still available for this rate limit.
        For more information, see [Rate limits](#section/Rate-limits).
      schema:
        type: integer
      example: 499
    Rate-Limit-Retry-After:
      description: Number of seconds to wait before retrying the request.
      schema:
        type: integer
      example: 1
  schemas:
    CreatedTime:
      type: string
      description: |-
        Date and time when the resource is created.
        This value is set automatically when the resource is created.
      format: date-time
      readOnly: true
      x-sortable: true
      x-label: Creation Time
    UpdatedTime:
      type: string
      description: |-
        Date and time when the resource is updated.
        This value is set automatically when the resource is updated.
      format: date-time
      readOnly: true
      x-sortable: true
      x-label: Last Update Time
    BaseProblem:
      type: object
      additionalProperties: true
      minProperties: 1
      description: RFC-7807 [problem details](https://tools.ietf.org/html/rfc7807) JSON object.
      properties:
        type:
          type: string
          description: |-
            Problem type in the form of a [URI](https://tools.ietf.org/html/rfc3986) reference.
            It should provide human-readable documentation for the problem type.
            When this member is not present, its value is assumed to be "about:blank".
          format: uri
        title:
          type: string
          description: |-
            Short, human-readable summary of the problem type.
            Other than for the purposes of localization, this should not change from occurrence to occurrence of the problem.
        detail:
          type: string
          description: Human-readable explanation that is specific to this occurrence of the problem.
        instance:
          type: string
          description: |-
            URI reference that identifies the specific occurrence of the problem.
            It may or may not yield further information if dereferenced.
    Unauthorized:
      allOf:
        - title: Unauthorized
        - type: object
          properties:
            status:
              type: integer
              description: HTTP status code.
              minimum: 401
              maximum: 401
        - $ref: '#/components/schemas/BaseProblem'
    OrganizationId:
      type: string
      description: |-
        Unique organization identifier.
        An organization is an entity that represents a company.
        For more information, see [Obtain an organization ID](https://www.rebilly.com/docs/settings/organizations-and-websites/#obtain-your-organization-id-and-website-id).
      maxLength: 50
      example: org_0YVDM8RC7GDADADSBSMW124JA8
    Forbidden:
      allOf:
        - title: Forbidden
        - type: object
          properties:
            status:
              type: integer
              description: HTTP status code.
              minimum: 403
              maximum: 403
            error:
              type: string
              description: |-
                Message that describes why the request is forbidden.
                Most responses use a descriptive message, such as `Not allowed to change security settings`.
                If the organization requires multi-factor authentication (MFA) and MFA verification has not been completed for the session, this value is `mfa_required`.
                If MFA verification has not been completed for the session and the operation requires a confirmed session, this value is `mfa_required_for_caller`.
                This includes turning on `requireMfa` and resetting MFA for a user.
                If the organization restricts access to a list of IP addresses and the request comes from an IP address that is not in the list, this value is `ip_not_allowed`.
            organizationId:
              description: |-
                ID of the organization that requires MFA or does not allow the IP address of the request.
                This property is present only if `error` is `mfa_required` or `ip_not_allowed`.
                The organization is the organization of the request or another organization that the request acts on.
              $ref: '#/components/schemas/OrganizationId'
        - $ref: '#/components/schemas/BaseProblem'
    InvalidFields:
      type: array
      description: Invalid field details.
      items:
        type: object
        properties:
          field:
            type: string
            description: |-
              Name of the field.
              Dot notation is used for nested object field names.
          message:
            description: Message field.
            type: string
      example:
        - field: field1
          message: field1 is invalid
        - field: subObject.field2
          message: field2 is invalid
        - field: subObject.field2
          message: another error in the field2
    ValidationError:
      allOf:
        - title: Validation error
        - type: object
          properties:
            status:
              type: integer
              description: HTTP status code.
              minimum: 422
              maximum: 422
        - $ref: '#/components/schemas/BaseProblem'
        - type: object
          properties:
            invalidFields:
              $ref: '#/components/schemas/InvalidFields'
    TooManyRequests:
      type: object
      additionalProperties: true
      minProperties: 1
      description: RFC-7807 [problem details](https://tools.ietf.org/html/rfc7807) JSON object.
      properties:
        type:
          type: string
          description: |-
            Problem type in the form of a [URI](https://tools.ietf.org/html/rfc3986) reference.
            It should provide human-readable documentation for the problem type.
            When this member is not present, its value is assumed to be "about:blank".
          format: uri
          example: about:blank
        title:
          type: string
          description: |-
            Short, human-readable summary of the problem type.
            Other than for the purposes of localization, this should not change from occurrence to occurrence of the problem.
          example: Rate Limit Exceeded
        status:
          type: integer
          description: HTTP status code.
          minimum: 429
          maximum: 429
        detail:
          type: string
          description: Human-readable explanation that is specific to this occurrence of the problem.
          example: A request cannot be executed because the user has sent too many requests within a certain period of time
        instance:
          type: string
          description: |-
            URI reference that identifies the specific occurrence of the problem.
            It may or may not yield further information if dereferenced.
    CurrencyCode:
      type: string
      description: Currency code in ISO 4217 format.
      minLength: 3
      maxLength: 3
      example: USD
      x-label: Currency
    Dispute:
      type: object
      properties:
        id:
          type: string
          description: ID of the dispute.
          readOnly: true
          maxLength: 50
          example: dp_0YVCE8J5F2DE58FV0S8YASW4HK
        customerId:
          description: ID of the customer who is disputing a transaction.
          type:
            - string
            - 'null'
          readOnly: true
          maxLength: 50
          example: cus_0YV7DDSDD1C8DA64KHH2W33CPF
        transactionId:
          description: ID of the disputed transaction.
          type:
            - string
            - 'null'
          maxLength: 50
          example: txn_0YVDTQJ8YWDGQACV2N2N5SPWQ0
        currency:
          $ref: '#/components/schemas/CurrencyCode'
        amount:
          description: Dispute amount.
          type: number
          format: double
        acquirerReferenceNumber:
          description: Acquirer reference number for the dispute.
          type:
            - string
            - 'null'
        caseId:
          description: Case ID of the dispute.
          type:
            - string
            - 'null'
        reasonCode:
          description: Code used in the chargeback that describes the reason for the dispute.
          type:
            - string
            - 'null'
          maxLength: 255
        reasonDescription:
          description: Description of the reason for the dispute.
          type:
            - string
            - 'null'
          maxLength: 512
          readOnly: true
        category:
          description: Category of dispute.
          type: string
          readOnly: true
          enum:
            - fraud
            - authorization
            - processing-errors
            - consumer-disputes
            - uncategorized
            - bank-return
        type:
          description: Type of dispute.
          type: string
          enum:
            - information-request
            - first-chargeback
            - second-chargeback
            - arbitration
            - fraud
            - ethoca-alert
            - verifi-alert
            - bank-return
            - paypal-claim
            - representment
            - inquiry
            - forced-refund
            - collaboration
        status:
          description: Status of the dispute.
          type: string
          enum:
            - response-needed
            - under-review
            - forfeited
            - won
            - lost
            - unknown
        postedTime:
          description: Date and time when the dispute is posted.
          type: string
          format: date-time
        deadlineTime:
          description: |-
            Latest date and time by when a merchant must submit a representment for a dispute.
            If the deadline is missed, the merchant loses the dispute.
          type:
            - string
            - 'null'
          format: date-time
        rawResponse:
          description: Raw response from the payment gateway that processed the disputed transaction.
          type:
            - string
            - 'null'
          readOnly: true
        resolvedTime:
          type:
            - string
            - 'null'
          format: date-time
          description: Date and time when the dispute is resolved.
          readOnly: true
        source:
          description: Source of the dispute.
          type:
            - string
            - 'null'
          readOnly: true
          enum:
            - null
            - api
            - manual
            - sftp
            - webhook
        revision:
          description: |-
            Number of times the dispute data has been modified.

            Use the revision number when analyzing webhook data to
            determine if a change should take precedence over the current
            representation.
          type: integer
          readOnly: true
        createdTime:
          $ref: '#/components/schemas/CreatedTime'
        updatedTime:
          $ref: '#/components/schemas/UpdatedTime'
        _links:
          type: array
          description: Related links.
          readOnly: true
          items:
            type: object
            properties:
              href:
                description: Link URL.
                type: string
              rel:
                description: Type of link.
                type: string
                enum:
                  - self
                  - transaction
                  - customer
                  - attachments
        _embedded:
          type: object
          description: Embedded objects that are requested by the `expand` query parameter.
          readOnly: true
          properties:
            transaction:
              type: object
            customer:
              type: object
    TransactionId:
      type: string
      description: ID of the transaction.
      maxLength: 50
      example: txn_0YVDTQJ8YWDGQACV2N2N5SPWQ0
  responses:
    Unauthorized:
      description: |-
        Unauthorized access.
        Invalid credentials used.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Unauthorized'
    Forbidden:
      description: |-
        Access forbidden.
        If the organization requires multi-factor authentication (MFA) and the session has not passed MFA, `error` is `mfa_required`.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Forbidden'
    ValidationError:
      description: Invalid data sent.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ValidationError'
    TooManyRequests:
      description: Request rate limit exceeded.
      headers:
        Rate-Limit-Limit:
          $ref: '#/components/headers/Rate-Limit-Limit'
        Rate-Limit-Remaining:
          description: |-
            Number of requests still available for this rate limit.
            For more information, see [Rate limits](#section/Rate-limits).
          schema:
            type: integer
          example: 0
        Rate-Limit-Retry-After:
          $ref: '#/components/headers/Rate-Limit-Retry-After'
        Retry-After:
          description: Number of seconds to wait before retrying the request.
          schema:
            type: integer
          example: 1
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/TooManyRequests'
  requestBodies:
    Dispute:
      content:
        application/json:
          schema:
            type: object
            required:
              - currency
              - amount
              - transactionId
              - postedTime
              - type
              - status
              - reasonCode
            properties:
              transactionId:
                description: ID of the disputed transaction.
                $ref: '#/components/schemas/TransactionId'
              currency:
                $ref: '#/components/schemas/CurrencyCode'
              amount:
                description: Dispute amount.
                type: number
                format: double
              acquirerReferenceNumber:
                description: Acquirer reference number for the dispute.
                type:
                  - string
                  - 'null'
                maxLength: 255
              caseId:
                description: Case ID of the dispute.
                type:
                  - string
                  - 'null'
                maxLength: 100
              reasonCode:
                description: Code used in the chargeback that describes the reason for the dispute.
                type: string
                maxLength: 255
                enum:
                  - '0'
                  - '00'
                  - '1'
                  - '2'
                  - '3'
                  - '4'
                  - '5'
                  - '6'
                  - '7'
                  - '8'
                  - '9'
                  - '10.1'
                  - '10.2'
                  - '10.3'
                  - '10.4'
                  - '10.5'
                  - '11.1'
                  - '11.2'
                  - '11.3'
                  - '12'
                  - '12.1'
                  - '12.2'
                  - '12.3'
                  - '12.4'
                  - '12.5'
                  - '12.6'
                  - 12.6.1
                  - 12.6.2
                  - '12.7'
                  - '13.1'
                  - '13.2'
                  - '13.3'
                  - '13.4'
                  - '13.5'
                  - '13.6'
                  - '13.7'
                  - '13.8'
                  - '13.9'
                  - '30'
                  - '31'
                  - '34'
                  - '35'
                  - '37'
                  - '40'
                  - '41'
                  - '42'
                  - '46'
                  - '47'
                  - '49'
                  - '50'
                  - '51'
                  - '53'
                  - '54'
                  - '55'
                  - '56'
                  - '57'
                  - '59'
                  - '60'
                  - '62'
                  - '63'
                  - '70'
                  - '71'
                  - '72'
                  - '73'
                  - '74'
                  - '75'
                  - '76'
                  - '77'
                  - '78'
                  - '79'
                  - '80'
                  - '81'
                  - '82'
                  - '83'
                  - '85'
                  - '86'
                  - '93'
                  - '98'
                  - '004'
                  - '021'
                  - '024'
                  - '059'
                  - '062'
                  - '063'
                  - '127'
                  - '154'
                  - '155'
                  - '158'
                  - '173'
                  - '175'
                  - '176'
                  - '193'
                  - '680'
                  - '684'
                  - '691'
                  - '693'
                  - '1000'
                  - '2001'
                  - '2002'
                  - '2003'
                  - '2004'
                  - '2005'
                  - '2008'
                  - '2011'
                  - '2700'
                  - '2701'
                  - '2702'
                  - '2703'
                  - '2704'
                  - '2705'
                  - '2706'
                  - '2707'
                  - '2708'
                  - '2709'
                  - '2710'
                  - '2713'
                  - '2870'
                  - '2871'
                  - '4807'
                  - '4808'
                  - '4812'
                  - '4831'
                  - '4834'
                  - '4837'
                  - '4840'
                  - '4841'
                  - '4842'
                  - '4846'
                  - '4849'
                  - '4850'
                  - '4853'
                  - '4854'
                  - '4855'
                  - '4859'
                  - '4860'
                  - '4863'
                  - '4870'
                  - '4871'
                  - '4901'
                  - '4902'
                  - '4903'
                  - '4904'
                  - '4905'
                  - '4908'
                  - '4999'
                  - '4534'
                  - '4541'
                  - '4542'
                  - '4550'
                  - '4553'
                  - '4586'
                  - '4752'
                  - '4753'
                  - '4755'
                  - '4865'
                  - '4866'
                  - '4867'
                  - '7010'
                  - '7030'
                  - '8002'
                  - A
                  - A01
                  - A02
                  - A08
                  - AL
                  - AP
                  - AW
                  - B
                  - C
                  - C02
                  - C04
                  - C05
                  - C08
                  - C14
                  - C18
                  - C28
                  - C31
                  - C32
                  - CA
                  - CD
                  - CR
                  - D
                  - DA
                  - DP
                  - DP1
                  - EX
                  - F10
                  - F14
                  - F22
                  - F24
                  - F29
                  - F30
                  - F31
                  - FR1
                  - FR2
                  - FR4
                  - FR6
                  - IC
                  - IN
                  - IS
                  - ITA
                  - LP
                  - M01
                  - M10
                  - M49
                  - 'N'
                  - NA
                  - NC
                  - P
                  - P01
                  - P03
                  - P04
                  - P05
                  - P07
                  - P08
                  - P22
                  - P23
                  - R03
                  - R13
                  - RG
                  - RM
                  - RN1
                  - RN2
                  - SV
                  - TF
                  - TNM
                  - UA01
                  - UA02
                  - UA03
                  - UA10
                  - UA11
                  - UA12
                  - UA18
                  - UA20
                  - UA21
                  - UA22
                  - UA23
                  - UA28
                  - UA30
                  - UA31
                  - UA32
                  - UA38
                  - UA99
                  - bank_cannot_process
                  - credit_not_processed
                  - customer_initiated
                  - debit_not_authorized
                  - duplicate
                  - fraudulent
                  - general
                  - incorrect_account_details
                  - insufficient_funds
                  - merchandise
                  - non_receipt
                  - not_as_described
                  - pre-chargeback-alert
                  - product_not_received
                  - product_unacceptable
                  - special
                  - subscription_canceled
                  - unauthorized
                  - unauthorized_claim
                  - unrecognized
                  - MERCHANDISE_OR_SERVICE_NOT_RECEIVED
                  - MERCHANDISE_OR_SERVICE_NOT_AS_DESCRIBED
                  - UNAUTHORISED
                  - CREDIT_NOT_PROCESSED
                  - DUPLICATE_TRANSACTION
                  - INCORRECT_AMOUNT
                  - PAYMENT_BY_OTHER_MEANS
                  - CANCELED_RECURRING_BILLING
                  - PROBLEM_WITH_REMITTANCE
                  - OTHER
              type:
                description: Type of dispute.
                type: string
                enum:
                  - information-request
                  - first-chargeback
                  - second-chargeback
                  - arbitration
                  - fraud
                  - ethoca-alert
                  - verifi-alert
                  - bank-return
                  - paypal-claim
                  - representment
                  - inquiry
                  - forced-refund
                  - collaboration
              status:
                description: Status of the dispute.
                type: string
                enum:
                  - response-needed
                  - under-review
                  - forfeited
                  - won
                  - lost
                  - unknown
              postedTime:
                description: Date and time when the dispute is posted.
                type: string
                format: date-time
              deadlineTime:
                description: |-
                  Latest date and time by when a merchant must submit a representment for a dispute.
                  If the deadline is missed, the merchant loses the dispute.
                type:
                  - string
                  - 'null'
                format: date-time
      description: Dispute resource.
      required: true
```
