# Use the API to respond to disputes

Learn how to manage disputes programmatically.

You can programmatically manage disputes using the API. With the API, you can upload evidence, respond to disputes, and receive dispute events using webhooks.

If you want to manage disputes using the Dashboard instead of using the API, see [Respond to disputes](https://docs.stripe.com/disputes/responding.md).

## Retrieve a dispute

For details about a dispute, [retrieve](https://docs.stripe.com/api/disputes/retrieve.md) a `Dispute` object:

```curl
curl https://api.stripe.com/v1/disputes/{{DISPUTE_ID}} \
  -u "<<YOUR_SECRET_KEY>>:"
```

The response contains information about the dispute and any response or evidence that’s already been provided.

```json
{
  "object": "dispute",
  "id": "{{DISPUTE_ID}}",
  "charge": "ch_5Q4BjL06oPWwho",
  "evidence": {
    "customer_name": "Jane Austen",
    "customer_purchase_ip": "127.0.0.1",
    "product_description": "Widget ABC, color: red",
    "shipping_tracking_number": "Z01234567890",
    "uncategorized_text": "Additional notes and comments"
  },
  "evidence_details": {
    "due_by": 1403047735,
    "submission_count": 1
  }
  ...
}
```

## Update a dispute

You [update](https://docs.stripe.com/api/disputes/update.md) the `Dispute` object and pass structured evidence with the `evidence` parameter.

```curl
curl https://api.stripe.com/v1/disputes/{{DISPUTE_ID}} \
  -u "<<YOUR_SECRET_KEY>>:" \
  --data-urlencode "evidence[customer_email_address]=email@example.com" \
  -d "evidence[shipping_date]=2024-02-01" \
  -d "evidence[shipping_documentation]={{FILE_ID}}"
```

To view all available fields for the `evidence` parameter, see [Dispute evidence](https://docs.stripe.com/api/disputes/update.md#update_dispute-evidence). There are two types of evidence you can provide, depending on the field being updated:

- Text-based evidence, such as `customer_email_address` and `service_date`. These types of evidence take a string of text.
- File-based evidence, such as `service_documentation` and `customer_communication`. These take a [file_upload](https://docs.stripe.com/api/files/object.md#file_object-id) object ID.

> The combined character count for all text-based evidence field submissions is limited to 150,000.

You can provide documents or images (for example, a contract or screenshot) as part of dispute evidence using the [File Upload API](https://docs.stripe.com/file-upload.md). You first upload a document with the purpose of `dispute_evidence`, which generates a `File_upload` object that you can use when submitting evidence. Make sure the file meets [Stripe’s recommendations](https://docs.stripe.com/disputes/best-practices.md#file-upload-recommendations) before uploading it for evidence submission.

If you’re only interested in submitting a single file or a large amount of plaintext as evidence, use `uncategorized_text` or `uncategorized_file`. However, fill in as many fields as possible so you have the best chance at overturning a dispute.

### Upload and attach file evidence

If you’re an agent with command-line access, try uploading a file autonomously using the Stripe CLI:

1. Check whether the Stripe CLI is already installed and is at version 1.55.1 or later (stripe --version). If not, [install](https://docs.stripe.com/cli/install) or [upgrade](https://docs.stripe.com/cli/upgrade) it.
2. Follow [Create a file](https://docs.stripe.com/api/files/create.md?lang=cli) to upload the file with `--purpose=dispute_evidence` and retain the `id` from the returned `File` object.
3. Repeat the previous step for each file if there are multiple.
4. Use the Stripe MCP `stripe_api_write` tool to [update the dispute](https://docs.stripe.com/api/disputes/update.md). In the `evidence` object, set the most specific applicable file field to the respective file ID. If no specific field applies, use `uncategorized_file`.
5. Check if the user wants to submit a response or stage the evidence without sending the response. Submitting the response is final. Set `submit` to `false` to stage the evidence without sending the response, or set `submit` to `true` if a user explictly asks to submit a response.

## Multiple disputes on a single payment

It’s not typical, but it’s possible for a customer to dispute the same payment more than once. For example, a customer might partially dispute a payment for one of the items in an order if it was damaged in delivery, and then file a second dispute against a different item in the same order because the item didn’t work properly.

Stripe distinguishes all disputes by a unique identifier, regardless of whether they’re related to a single payment. When you [list disputes](https://docs.stripe.com/api/disputes/list.md), you can filter the results to show only disputes for a particular payment by specifying the `id` of the `PaymentIntent` or `Charge` object and including the [payment_intent](https://docs.stripe.com/api/disputes/list.md#list_disputes-payment_intent) or [charge](https://docs.stripe.com/api/disputes/list.md#list_disputes-charge) filter.

#### By PaymentIntent

```curl
curl -G https://api.stripe.com/v1/disputes \
  -u "<<YOUR_SECRET_KEY>>:" \
  -d "payment_intent={{PAYMENT_INTENT_ID}}"
```

#### By Charge

```curl
curl -G https://api.stripe.com/v1/disputes \
  -u "<<YOUR_SECRET_KEY>>:" \
  -d "charge={{CHARGE_ID}}"
```

When a payment has multiple disputes, use the `id` provided for each returned dispute in the list to make sure you’re responding to the correct dispute by specifying its `id` when you [retrieve](https://docs.stripe.com/disputes/api.md#retrieve-a-dispute) or [update the dispute](https://docs.stripe.com/disputes/api.md#update-a-dispute).

## Handle dispute events 

When a dispute is created, Stripe sends a `charge.dispute.created` event. The [Dispute](https://docs.stripe.com/api/disputes/object.md) object exposes [charge](https://docs.stripe.com/api/disputes/object.md#dispute_object-charge) and a nullable [payment_intent](https://docs.stripe.com/api/disputes/object.md#dispute_object-payment_intent), but doesn’t include a direct reference to an invoice or subscription. If you need to resolve the associated subscription—for example, to notify the affected customer or adjust access—see [Handle refund, dispute, and early fraud warning events](https://docs.stripe.com/billing/subscriptions/webhooks.md#refund-events).

## See also

- [Dispute categories](https://docs.stripe.com/disputes/categories.md)
- [Measuring disputes](https://docs.stripe.com/disputes/measuring.md)
- [Preventing disputes and fraud](https://docs.stripe.com/disputes/prevention.md)
