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

# Vendor Commissions

Retrieve a paginated list of commission records for a specific vendor, with filtering and sorting support.

<EndpointHeader verb="GET" path="/merchant/api/v1/vendors/:id/commissions" />

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

### Query Parameters

<ParamTable
  rows={[
    { name: "status", type: "string", desc: "Filter by commission status (`pending`, `calculated`, `paid`, `cancelled`, `disputed`)" },
    { name: "commissionType", type: "string", desc: "Filter by commission type (`percentage`, `fixed`, `tiered`)" },
    { name: "calculatedAfter", type: "string", desc: "Commissions calculated after this date (ISO 8601)" },
    { name: "calculatedBefore", type: "string", desc: "Commissions calculated before this date (ISO 8601)" },
    { name: "paidAfter", type: "string", desc: "Commissions paid after this date (ISO 8601)" },
    { name: "paidBefore", type: "string", desc: "Commissions paid before this date (ISO 8601)" },
    { name: "minCommissionAmount", type: "number", desc: "Minimum commission amount" },
    { name: "currency", type: "string", desc: "Filter by currency code (e.g., `USD`, `EUR`)" },
    { name: "environment", type: "string", desc: "Filter by environment" },
    { name: "page", type: "number", desc: "Page number (default: `1`)" },
    { name: "limit", type: "number", desc: "Results per page (default: `20`)" },
    { name: "sortBy", type: "string", desc: "Field to sort by" },
    { name: "sortOrder", type: "string", desc: "Sort direction (`asc`, `desc`)" },
  ]}
/>

## Response

### Success (200 OK)

```json
{
  "success": true,
  "data": [
    {
      "commissionId": "comm_d4e5f6g7h8i9j0k1",
      "vendorId": "vnd_a1b2c3d4e5f6g7h8",
      "referralId": "ref_e5f6g7h8i9j0k1l2",
      "transactionId": "txn_f6g7h8i9j0k1l2m3",
      "amount": 125.00,
      "currency": "USD",
      "commissionRate": 12.5,
      "commissionType": "percentage",
      "baseAmount": 1000.00,
      "status": "paid",
      "calculatedAt": "2024-03-15T10:00:00.000Z",
      "paidAt": "2024-03-20T14:00:00.000Z",
      "environment": "production"
    },
    {
      "commissionId": "comm_g7h8i9j0k1l2m3n4",
      "vendorId": "vnd_a1b2c3d4e5f6g7h8",
      "referralId": "ref_h8i9j0k1l2m3n4o5",
      "transactionId": "txn_i9j0k1l2m3n4o5p6",
      "amount": 75.50,
      "currency": "USD",
      "commissionRate": 12.5,
      "commissionType": "percentage",
      "baseAmount": 604.00,
      "status": "pending",
      "calculatedAt": "2024-03-21T08:00:00.000Z",
      "paidAt": null,
      "environment": "production"
    }
  ],
  "message": "Vendor commissions retrieved successfully",
  "error": null,
  "meta": {
    "request_id": "req_xxxxx",
    "timestamp": "2024-03-21T10:30:00.000Z",
    "processing_time_ms": 95,
    "api_version": "v1",
    "endpoint": "GET /vendors/:id/commissions",
    "user_type": "merchant",
    "pagination": {
      "page": 1,
      "limit": 20,
      "totalItems": 2,
      "totalPages": 1
    }
  }
}
```

### Error Responses

<ErrorTable
  rows={[
    { code: "VALIDATION_ERROR", status: "400", message: "Invalid query parameters" },
    { code: "UNAUTHORIZED", status: "401", message: "Invalid API key" },
    { code: "VENDOR_NOT_FOUND", status: "404", message: "Vendor with specified ID does not exist" },
  ]}
/>

<CodeRail>

## Examples

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

```bash
curl -X GET "https://api.zenpayz.com/merchant/api/v1/vendors/vnd_a1b2c3d4e5f6g7h8/commissions?status=pending&currency=USD&page=1&limit=20" \
  -H "Authorization: Bearer zp_test_xxxxx" \
  -H "X-Timestamp: 2024-03-21T10:30:00.000Z" \
  -H "X-Signature: a1b2c3d4e5f6..." \
  -H "X-Secret-Salt: your_secret_salt" \
  -H "Content-Type: application/json"
```

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

```javascript
const params = new URLSearchParams({
  status: 'pending',
  currency: 'USD',
  page: '1',
  limit: '20',
});

const response = await fetch(`https://api.zenpayz.com/merchant/api/v1/vendors/vnd_a1b2c3d4e5f6g7h8/commissions?${params}`, {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${apiKey}`,
    'X-Timestamp': timestamp,
    'X-Signature': signature,
    'X-Secret-Salt': secretSalt,
    'Content-Type': 'application/json',
  },
});

const result = await response.json();
console.log(result.data); // Array of commission records
console.log(result.meta.pagination.totalItems); // Total count
```

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

```javascript
const commissions = await zenpays.vendors.listCommissions('vnd_a1b2c3d4e5f6g7h8', {
  status: 'pending',
  currency: 'USD',
  page: 1,
  limit: 20,
});

console.log(commissions.data); // Array of commission records
console.log(commissions.meta.pagination.totalItems); // Total count
```

  </TabItem>
</Tabs>

</CodeRail>

## Related Endpoints

- [Get Vendor](/docs/rest-api/endpoints/vendors/get-vendor)
- [Vendor Referrals](/docs/rest-api/endpoints/vendors/vendor-referrals)
- [Vendor Payout](/docs/rest-api/endpoints/vendors/vendor-payout)
- [Vendor Analytics](/docs/rest-api/endpoints/vendors/vendor-analytics)
