<!-- ZenPays documentation · https://docs.zenpayz.com/docs/rest-api/endpoints/chargebacks/create-chargeback -->

# Create Chargeback

Create a new chargeback record against a specific transaction.

<EndpointHeader verb="POST" path="/merchant/api/v1/chargebacks" />

## Request

### Headers

<ParamTable
  label="Header"
  rows={[
    { name: "Authorization", required: true, desc: "`Bearer {api_key}`" },
    { name: "X-Signature", required: true, desc: "HMAC-SHA256 signature" },
    { name: "X-Timestamp", required: true, desc: "ISO 8601 timestamp" },
    { name: "X-Secret-Salt", required: true, desc: "Secret salt for HMAC validation" },
    { name: "Content-Type", required: true, desc: "`application/json`" },
    { name: "X-Merchant-Id", required: true, desc: "Merchant identifier" },
    { name: "X-Request-Id", required: true, desc: "Unique request identifier" },
  ]}
/>

### Body Parameters

<ParamTable
  rows={[
    { name: "transactionId", type: "string", required: true, desc: "ID of the original transaction being disputed" },
    { name: "amount", type: "number", required: true, desc: "Chargeback amount" },
    { name: "currency", type: "string", required: true, desc: "ISO 4217 currency code" },
    { name: "reason", type: "string", required: true, desc: "Reason for the chargeback" },
    { name: "source", type: "string", required: true, desc: "Source of the chargeback (e.g. card_network, customer, bank)" },
    { name: "reasonCode", type: "string", desc: "Standard reason code from the card network" },
    { name: "reasonDescription", type: "string", desc: "Detailed description of the reason" },
    { name: "externalChargebackId", type: "string", desc: "External chargeback identifier from the payment network" },
    { name: "disputeDeadline", type: "string", desc: "Deadline to respond to the dispute (ISO 8601)" },
    { name: "evidenceDeadline", type: "string", desc: "Deadline to submit evidence (ISO 8601)" },
    { name: "priority", type: "string", desc: "Priority level: `low`, `medium`, `high`, `urgent`" },
  ]}
/>

## Response

### Success (201 Created)

```json
{
  "success": true,
  "data": {
    "chargebackId": "cb_a1b2c3d4e5f6g7h8",
    "transactionId": "txn_f8e7d6c5b4a39281",
    "amount": 150.00,
    "currency": "USD",
    "reason": "fraudulent",
    "source": "card_network",
    "reasonCode": "10.4",
    "reasonDescription": "Other Fraud - Card-Absent Environment",
    "externalChargebackId": "ext_cb_12345",
    "status": "initiated",
    "outcome": "pending",
    "priority": "high",
    "disputeDeadline": "2024-02-15T23:59:59.000Z",
    "evidenceDeadline": "2024-02-10T23:59:59.000Z",
    "evidence": [],
    "merchantResponse": null,
    "createdAt": "2024-01-15T10:30:00.000Z",
    "updatedAt": "2024-01-15T10:30:00.000Z"
  },
  "message": "Chargeback created successfully",
  "error": null,
  "meta": {
    "request_id": "req_xxxxx",
    "timestamp": "2024-01-15T10:30:00.000Z",
    "processing_time_ms": 45,
    "api_version": "v1",
    "endpoint": "POST /chargebacks",
    "user_type": "merchant"
  }
}
```

### Error Responses

<ErrorTable
  rows={[
    { code: "VALIDATION_ERROR", status: "400", message: "Invalid request parameters" },
    { code: "UNAUTHORIZED", status: "401", message: "Invalid API key" },
    { code: "TRANSACTION_NOT_FOUND", status: "404", message: "Referenced transaction does not exist" },
    { code: "DUPLICATE_CHARGEBACK", status: "409", message: "A chargeback already exists for this transaction" },
  ]}
/>

<CodeRail>

## Examples

<Tabs groupId="language">
  <TabItem value="curl" label="cURL" default>

```bash
curl -X POST https://api.zenpayz.com/merchant/api/v1/chargebacks \
  -H "Authorization: Bearer zp_test_xxxxx" \
  -H "X-Timestamp: 2024-01-15T10:30:00.000Z" \
  -H "X-Signature: a1b2c3d4e5f6..." \
  -H "X-Secret-Salt: your_secret_salt" \
  -H "Content-Type: application/json" \
  -H "X-Merchant-Id: merch_xxxxx" \
  -H "X-Request-Id: req_xxxxx" \
  -d '{
    "transactionId": "txn_f8e7d6c5b4a39281",
    "amount": 150.00,
    "currency": "USD",
    "reason": "fraudulent",
    "source": "card_network",
    "reasonCode": "10.4",
    "priority": "high",
    "disputeDeadline": "2024-02-15T23:59:59.000Z",
    "evidenceDeadline": "2024-02-10T23:59:59.000Z"
  }'
```

  </TabItem>
  <TabItem value="javascript" label="JavaScript">

```javascript
const response = await fetch('https://api.zenpayz.com/merchant/api/v1/chargebacks', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${apiKey}`,
    'X-Timestamp': timestamp,
    'X-Signature': signature,
    'X-Secret-Salt': secretSalt,
    'Content-Type': 'application/json',
    'X-Merchant-Id': merchantId,
    'X-Request-Id': requestId,
  },
  body: JSON.stringify({
    transactionId: 'txn_f8e7d6c5b4a39281',
    amount: 150.00,
    currency: 'USD',
    reason: 'fraudulent',
    source: 'card_network',
    reasonCode: '10.4',
    priority: 'high',
    disputeDeadline: '2024-02-15T23:59:59.000Z',
    evidenceDeadline: '2024-02-10T23:59:59.000Z',
  }),
});

const result = await response.json();
console.log(result.data.chargebackId); // cb_a1b2c3d4e5f6g7h8
```

  </TabItem>
  <TabItem value="sdk" label="SDK">

```javascript
const chargeback = await zenpays.chargebacks.create({
  transactionId: 'txn_f8e7d6c5b4a39281',
  amount: 150.00,
  currency: 'USD',
  reason: 'fraudulent',
  source: 'card_network',
  reasonCode: '10.4',
  priority: 'high',
  disputeDeadline: '2024-02-15T23:59:59.000Z',
  evidenceDeadline: '2024-02-10T23:59:59.000Z',
});

console.log(chargeback.chargebackId); // cb_a1b2c3d4e5f6g7h8
```

  </TabItem>
</Tabs>

</CodeRail>

## Related Endpoints

- [List Chargebacks](/docs/rest-api/endpoints/chargebacks/list-chargebacks)
- [Get Chargeback](/docs/rest-api/endpoints/chargebacks/get-chargeback)
- [Submit Evidence](/docs/rest-api/endpoints/chargebacks/submit-evidence)
- [Add Response](/docs/rest-api/endpoints/chargebacks/add-response)
