<!-- ZenPays documentation · https://docs.zenpayz.com/docs/rest-api/endpoints/payments/list-transactions -->

# List Transactions

Retrieve a paginated list of transactions with optional filters.

<EndpointHeader verb="GET" path="/api/v1/transactions" />

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

### Query Parameters

<ParamTable
  rows={[
    { name: "page", type: "integer", default: "1", desc: "Page number" },
    { name: "limit", type: "integer", default: "20", desc: "Items per page (max 100)" },
    { name: "status", type: "string", default: "-", desc: "Filter by status" },
    { name: "paymentMethod", type: "string", default: "-", desc: "Filter by payment method" },
    { name: "currency", type: "string", default: "-", desc: "Filter by currency code" },
    { name: "customerId", type: "string", default: "-", desc: "Filter by customer ID" },
    { name: "transactionId", type: "string", default: "-", desc: "Filter by transaction ID" },
    { name: "minAmount", type: "integer", default: "-", desc: "Minimum amount" },
    { name: "maxAmount", type: "integer", default: "-", desc: "Maximum amount" },
    { name: "startDate", type: "string", default: "-", desc: "Start date (ISO 8601)" },
    { name: "endDate", type: "string", default: "-", desc: "End date (ISO 8601)" },
    { name: "search", type: "string", default: "-", desc: "Search in ID, email, name" },
  ]}
/>

### Transaction Status Values

| Status | Description |
|--------|-------------|
| `initiated` | Transaction created |
| `processing` | Being processed |
| `success` | Completed successfully |
| `failed` | Transaction failed |
| `cancelled` | Cancelled by user/merchant |
| `refunded` | Full refund processed |
| `partially_refunded` | Partial refund processed |

## Response

### Success (200 OK)

```json
{
  "success": true,
  "data": [
    {
      "id": "txn_xxxxx",
      "intentId": "pi_xxxxx",
      "merchantId": "mer_xxxxx",
      "customerId": "cus_xxxxx",
      "customerName": "John Doe",
      "customerEmail": "john@example.com",
      "amount": 1000,
      "currency": "USD",
      "status": "success",
      "paymentMethod": "upi",
      "processingFee": 29,
      "netAmount": 971,
      "metadata": {
        "orderId": "order_123"
      },
      "createdAt": "2024-01-15T10:30:00.000Z",
      "updatedAt": "2024-01-15T10:35:00.000Z"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 150,
    "totalPages": 8
  }
}
```

### Error Responses

<ErrorTable
  rows={[
    { code: "INVALID_REQUEST", status: "400", message: "Invalid query parameters" },
    { code: "UNAUTHORIZED", status: "401", message: "Invalid API key" },
  ]}
/>

<CodeRail>

## Examples

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

```bash
curl -X GET "https://api.zenpayz.com/api/v1/transactions?status=success&limit=50&startDate=2024-01-01" \
  -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"
```

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

```javascript
const crypto = require('crypto');

const apiKey = process.env.ZENPAYS_API_KEY;
const secretSalt = process.env.ZENPAYS_SECRET_SALT;
const timestamp = new Date().toISOString();

// For GET requests, use empty object
const signature = crypto
  .createHmac('sha256', secretSalt)
  .update(timestamp + '{}')
  .digest('hex');

const params = new URLSearchParams({
  status: 'success',
  limit: '50',
  startDate: '2024-01-01',
});

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

const result = await response.json();
console.log(`Found ${result.pagination.total} transactions`);
result.data.forEach(txn => {
  console.log(`${txn.id}: ${txn.amount} ${txn.currency} - ${txn.status}`);
});
```

  </TabItem>
  <TabItem value="python" label="Python">

```python
import hmac
import hashlib
import os
from datetime import datetime
import requests

api_key = os.environ["ZENPAYS_API_KEY"]
secret_salt = os.environ["ZENPAYS_SECRET_SALT"]
timestamp = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.000Z")

# For GET requests, use empty object
data = timestamp + "{}"
signature = hmac.new(
    secret_salt.encode(),
    data.encode(),
    hashlib.sha256
).hexdigest()

response = requests.get(
    "https://api.zenpayz.com/api/v1/transactions",
    headers={
        "Authorization": f"Bearer {api_key}",
        "X-Timestamp": timestamp,
        "X-Signature": signature,
        "X-Secret-Salt": secret_salt,
    },
    params={
        "status": "success",
        "limit": 50,
        "startDate": "2024-01-01",
    },
)

result = response.json()
print(f"Found {result['pagination']['total']} transactions")
for txn in result["data"]:
    print(f"{txn['id']}: {txn['amount']} {txn['currency']} - {txn['status']}")
```

  </TabItem>
  <TabItem value="sdk" label="SDK (Recommended)">

```javascript
// JavaScript SDK - handles authentication automatically
const { data, total } = await zenpays.payments.listTransactions({
  status: 'success',
  limit: 50,
  from: '2024-01-01',
});

console.log(`Found ${total} transactions`);
data.forEach(txn => {
  console.log(`${txn.id}: ${txn.amount} ${txn.currency} - ${txn.status}`);
});
```

  </TabItem>
</Tabs>

</CodeRail>

## Filtering Examples

### By Date Range

```bash
GET /api/v1/transactions?startDate=2024-01-01&endDate=2024-01-31
```

### By Amount Range

```bash
GET /api/v1/transactions?minAmount=1000&maxAmount=10000
```

### By Customer

```bash
GET /api/v1/transactions?customerId=cus_xxxxx
```

### Combined Filters

```bash
GET /api/v1/transactions?status=success&currency=USD&paymentMethod=upi&limit=100
```

## Related Endpoints

- [Get Transaction](/docs/rest-api/endpoints/transactions/get-transaction)
- [Export Transactions](/docs/rest-api/endpoints/transactions/export-transactions)
