<!-- ZenPays documentation · https://docs.zenpayz.com/docs/rest-api/endpoints/vendors/update-vendor-status -->

# Update Vendor Status

Update the status of a specific vendor. Use this endpoint to activate, deactivate, or suspend a vendor.

<EndpointHeader verb="PATCH" path="/merchant/api/v1/vendors/:id/status" />

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

### Path Parameters

<ParamTable
  rows={[
    { name: "id", type: "string", required: true, desc: "Vendor ID (e.g., `vnd_a1b2c3d4e5f6g7h8`)" },
  ]}
/>

### Body Parameters

<ParamTable
  rows={[
    { name: "status", type: "string", required: true, desc: "New status (`active`, `inactive`, `suspended`, `pending`)" },
    { name: "reason", type: "string", desc: "Reason for the status change" },
    { name: "adminComment", type: "string", desc: "Internal admin comment" },
  ]}
/>

## Response

### Success (200 OK)

```json
{
  "success": true,
  "data": {
    "vendorId": "vnd_a1b2c3d4e5f6g7h8",
    "previousStatus": "active",
    "status": "suspended",
    "reason": "Compliance review required",
    "adminComment": "Flagged during quarterly audit",
    "updatedAt": "2024-03-21T14:00:00.000Z"
  },
  "message": "Vendor status updated successfully",
  "error": null,
  "meta": {
    "request_id": "req_xxxxx",
    "timestamp": "2024-03-21T14:00:00.000Z",
    "processing_time_ms": 90,
    "api_version": "v1",
    "endpoint": "PATCH /vendors/:id/status",
    "user_type": "merchant"
  }
}
```

### Error Responses

<ErrorTable
  rows={[
    { code: "VALIDATION_ERROR", status: "400", message: "Invalid status value" },
    { code: "UNAUTHORIZED", status: "401", message: "Invalid API key" },
    { code: "VENDOR_NOT_FOUND", status: "404", message: "Vendor with specified ID does not exist" },
    { code: "INVALID_STATUS_TRANSITION", status: "409", message: "Status transition is not allowed" },
  ]}
/>

<CodeRail>

## Examples

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

```bash
curl -X PATCH https://api.zenpayz.com/merchant/api/v1/vendors/vnd_a1b2c3d4e5f6g7h8/status \
  -H "Authorization: Bearer zp_test_xxxxx" \
  -H "X-Timestamp: 2024-03-21T14:00:00.000Z" \
  -H "X-Signature: a1b2c3d4e5f6..." \
  -H "X-Secret-Salt: your_secret_salt" \
  -H "Content-Type: application/json" \
  -d '{
    "status": "suspended",
    "reason": "Compliance review required",
    "adminComment": "Flagged during quarterly audit"
  }'
```

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

```javascript
const response = await fetch('https://api.zenpayz.com/merchant/api/v1/vendors/vnd_a1b2c3d4e5f6g7h8/status', {
  method: 'PATCH',
  headers: {
    'Authorization': `Bearer ${apiKey}`,
    'X-Timestamp': timestamp,
    'X-Signature': signature,
    'X-Secret-Salt': secretSalt,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    status: 'suspended',
    reason: 'Compliance review required',
    adminComment: 'Flagged during quarterly audit',
  }),
});

const result = await response.json();
console.log(result.data.previousStatus); // active
console.log(result.data.status); // suspended
```

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

```javascript
const result = await zenpays.vendors.updateStatus('vnd_a1b2c3d4e5f6g7h8', {
  status: 'suspended',
  reason: 'Compliance review required',
  adminComment: 'Flagged during quarterly audit',
});

console.log(result.previousStatus); // active
console.log(result.status); // suspended
```

  </TabItem>
</Tabs>

</CodeRail>

## Related Endpoints

- [Get Vendor](/docs/rest-api/endpoints/vendors/get-vendor)
- [Update Vendor](/docs/rest-api/endpoints/vendors/update-vendor)
- [Update Vendor KYC](/docs/rest-api/endpoints/vendors/update-vendor-kyc)
