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

# Add Response

Add a merchant response to a chargeback dispute.

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

## 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" },
  ]}
/>

### Path Parameters

<ParamTable
  rows={[
    { name: "chargebackId", type: "string", required: true, desc: "Unique chargeback identifier" },
  ]}
/>

### Body Parameters

<ParamTable
  rows={[
    { name: "response", type: "string", required: true, desc: "Merchant response text (must be non-empty)" },
  ]}
/>

## Response

### Success (200 OK)

```json
{
  "success": true,
  "data": {
    "chargebackId": "cb_a1b2c3d4e5f6g7h8",
    "status": "pending_review",
    "merchantResponse": "The customer received the product on January 12th. Delivery was confirmed with a signature. The tracking number is 1Z999AA10123456784. We have attached the signed delivery receipt and shipping confirmation as evidence.",
    "updatedAt": "2024-01-19T09:15:00.000Z"
  },
  "message": "Response added successfully",
  "error": null,
  "meta": {
    "request_id": "req_xxxxx",
    "timestamp": "2024-01-19T09:15:00.000Z",
    "processing_time_ms": 40,
    "api_version": "v1",
    "endpoint": "POST /chargebacks/:chargebackId/response",
    "user_type": "merchant"
  }
}
```

### Error Responses

<ErrorTable
  rows={[
    { code: "VALIDATION_ERROR", status: "400", message: "Invalid request parameters or empty response" },
    { code: "UNAUTHORIZED", status: "401", message: "Invalid API key" },
    { code: "CHARGEBACK_NOT_FOUND", status: "404", message: "Chargeback with the specified ID does not exist" },
    { code: "INVALID_STATE", status: "409", message: "Chargeback is not in a state that accepts responses" },
  ]}
/>

<CodeRail>

## Examples

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

```bash
curl -X POST https://api.zenpayz.com/merchant/api/v1/chargebacks/cb_a1b2c3d4e5f6g7h8/response \
  -H "Authorization: Bearer zp_test_xxxxx" \
  -H "X-Timestamp: 2024-01-19T09:15: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 '{
    "response": "The customer received the product on January 12th. Delivery was confirmed with a signature. The tracking number is 1Z999AA10123456784."
  }'
```

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

```javascript
const response = await fetch('https://api.zenpayz.com/merchant/api/v1/chargebacks/cb_a1b2c3d4e5f6g7h8/response', {
  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({
    response: 'The customer received the product on January 12th. Delivery was confirmed with a signature. The tracking number is 1Z999AA10123456784.',
  }),
});

const result = await response.json();
console.log(result.data.chargebackId); // cb_a1b2c3d4e5f6g7h8
console.log(result.data.merchantResponse); // "The customer received the product..."
```

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

```javascript
const result = await zenpays.chargebacks.addResponse('cb_a1b2c3d4e5f6g7h8', {
  response: 'The customer received the product on January 12th. Delivery was confirmed with a signature. The tracking number is 1Z999AA10123456784.',
});

console.log(result.chargebackId); // cb_a1b2c3d4e5f6g7h8
console.log(result.merchantResponse); // "The customer received the product..."
```

  </TabItem>
</Tabs>

</CodeRail>

## Related Endpoints

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