Create a Dispute
Create a new dispute for a specific charge. This initiates the chargeback process for the associated transaction.
Request Parametersโ
Required - 1 fieldRequired Parameters
`id`STRING(required)
Charge ID to create a dispute for (path parameter). The charge must be in a disputable state. Format: chrg_test_ or chrg_live_ followed by alphanumeric string.
Responsesโ
200
Successful creationReturns the newly created dispute object with initial status set to "open".
Response includes:
id- Dispute ID (dspt_test_ or dspt_live_ prefix)object- "dispute"livemode- Whether this is a live mode disputestatus- Initial status (open)amount- Disputed amount in smallest currency unitcurrency- Three-letter ISO currency codereason_code- Reason for disputereason_message- Human-readable reason descriptioncharge- Associated charge IDmessage- Response message (null initially)documents- List of evidence documents (empty initially)created_at- When dispute was createdclosed_at- When dispute was closed (null for open disputes)
400
Bad requestRequest validation failed. Check the error message for details.
Common causes:
- Invalid charge ID format
- Missing required parameters
- Malformed request body
401
UnauthorizedAuthentication failed. Invalid or missing API key.
Common causes:
- Missing Authorization header
- Invalid secret key
- Using public key instead of secret key
- Incorrect HTTP Basic Auth format
404
Not foundCharge not found.
Common causes:
- Incorrect charge ID
- Charge belongs to different account
- ID typo or formatting error
422
Unprocessable entityDispute cannot be created for this charge.
Common causes:
- Charge already has an existing dispute
- Charge is not in a disputable state
- Charge has been refunded
- Charge is too old to dispute
5xx
Server errorServer-side error occurred. These are rare but should be handled gracefully.
How to handle:
- Retry the request with exponential backoff
- Check status.omise.co for service incidents
- See Error Handling for detailed guidance
Code samplesโ
- cURL
- Ruby
- Python
- Node.js
- PHP
- Java
- C#
- Go
curl https://api.omise.co/charges/chrg_test_5xuy4w91xqz7d1w9u0t/disputes \
-X POST \
-u skey_test_5xuy4w91xqz7d1w9u0t:
require 'omise'
Omise.api_key = 'skey_test_5xuy4w91xqz7d1w9u0t'
charge = Omise::Charge.retrieve('chrg_test_5xuy4w91xqz7d1w9u0t')
dispute = charge.disputes.create
import omise
omise.api_secret = 'skey_test_5xuy4w91xqz7d1w9u0t'
charge = omise.Charge.retrieve('chrg_test_5xuy4w91xqz7d1w9u0t')
dispute = charge.disputes.create()
const omise = require('omise')({
secretKey: 'skey_test_5xuy4w91xqz7d1w9u0t'
});
const dispute = await omise.charges.createDispute('chrg_test_5xuy4w91xqz7d1w9u0t');
<?php
define('OMISE_SECRET_KEY', 'skey_test_5xuy4w91xqz7d1w9u0t');
$charge = OmiseCharge::retrieve('chrg_test_5xuy4w91xqz7d1w9u0t');
$dispute = $charge->disputes()->create();
Client client = new Client.Builder()
.secretKey("skey_test_5xuy4w91xqz7d1w9u0t")
.build();
Dispute dispute = client.charges().createDispute("chrg_test_5xuy4w91xqz7d1w9u0t");
var client = new Client("skey_test_5xuy4w91xqz7d1w9u0t");
var dispute = await client.Charges.CreateDispute("chrg_test_5xuy4w91xqz7d1w9u0t");
client, _ := omise.NewClient(
"pkey_test_5xuy4w91xqz7d1w9u0t",
"skey_test_5xuy4w91xqz7d1w9u0t",
)
dispute, _ := client.CreateDispute("chrg_test_5xuy4w91xqz7d1w9u0t")
Error and result codesโ
Common Error Codesโ
| Code | Description | Resolution |
|---|---|---|
bad_request | Invalid parameters | Check charge ID format |
authentication_failure | Invalid API key | Verify your secret key is correct |
not_found | Charge not found | Check charge ID is correct |
invalid_charge_id | Charge ID format invalid | Use valid chrg_ format |
dispute_already_exists | Charge already has a dispute | Cannot create duplicate disputes |
charge_not_disputable | Charge cannot be disputed | Verify charge status and age |
Dispute Status Valuesโ
| Status | Description |
|---|---|
open | Newly initiated, awaiting your response |
pending | Under review with merchant response submitted |
won | Merchant won the dispute |
lost | Merchant lost the dispute |
Reason Codesโ
| Code | Description |
|---|---|
fraudulent | Customer claims unauthorized transaction |
unrecognized | Customer doesn't recognize the charge |
duplicate | Customer claims duplicate charge |
goods_or_services_not_provided | Product/service not received |
not_as_described | Product significantly different from description |
credit_not_processed | Refund promised but not received |
general | Other reasons |
API Credentials
Try it outโ
Required - 1 fields
Your IP:
...Loading...