> ## Documentation Index
> Fetch the complete documentation index at: https://casparser.in/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# CAS Generator for Mutual Funds

> Request mutual fund CAS statements programmatically. Get 50+ years of transaction history from both KFintech and CAMS RTAs.

## Overview

CAS Generator triggers a mutual fund CAS statement to be emailed to your user — no manual portal visits needed.

**Coverage:** Uses KFintech's email mailback service. KFintech and CAMS have a mutual partnership that provides data from both RTAs (Registrar and Transfer Agents), so this endpoint retrieves mutual fund data from both KFintech and CAMS, covering all mutual funds in India.

```mermaid theme={null}
flowchart LR
    A[Your App] --> B[CAS Parser<br/>Generator]
    B --> C[KFintech<br/>Portal]
    C --> D[User Email<br/>CAS PDF]
```

**Use cases:**

* Client onboarding (request 50+ years of transaction history)
* Automated monthly portfolio updates
* Filling gaps in transaction history

<Note>
  KFintech emails the CAS to the user's registered email within a few minutes. The CAS is not returned in the API response.
</Note>

## Request a CAS statement

```python theme={null}
import requests

response = requests.post(
    "https://api.casparser.in/v4/kfintech/generate",
    headers={"x-api-key": "YOUR_API_KEY"},
    json={
        "email": "investor@example.com",
        "from_date": "1990-01-01",
        "to_date": "2024-01-15",
        "password": "Abcdefghi12$"
    }
)

data = response.json()
# {"status": "success", "msg": "CAS request submitted. Check email shortly."}
```

## Parameters

| Parameter   | Required | Description                           |
| ----------- | -------- | ------------------------------------- |
| `email`     | Yes      | User's email registered with KFintech |
| `pan_no`    | No       | User's PAN number (optional)          |
| `from_date` | Yes      | Start date (YYYY-MM-DD)               |
| `to_date`   | Yes      | End date (YYYY-MM-DD)                 |
| `password`  | Yes      | Password for the PDF                  |

## Integration patterns

### Pattern 1: Generate + Gmail Import

Combine CAS Generator with Gmail Inbox Import for a seamless flow:

```python theme={null}
# 1. Request CAS generation
requests.post(
    "https://api.casparser.in/v4/kfintech/generate",
    headers={"x-api-key": API_KEY},
    json={
        "email": "user@gmail.com",
        "from_date": "2020-01-01",
        "to_date": "2024-12-31",
        "password": "Abcdefghi12$"
    }
)

# 2. Wait for email (1-2 minutes)
time.sleep(120)

# 3. Import from Gmail
response = requests.post(
    "https://api.casparser.in/v4/inbox/cas",
    headers={
        "x-api-key": API_KEY,
        "x-inbox-token": inbox_token
    }
)
```

### Pattern 2: User-initiated

Let users trigger generation and upload manually:

```jsx theme={null}
// Frontend
const requestCAS = async () => {
  await fetch('/api/generate-cas', {
    method: 'POST',
    body: JSON.stringify({ email: user.email, pan: user.pan })
  });
  
  alert('CAS will arrive in your email in 1-2 minutes. Upload it here when received.');
};
```

## Timing expectations

| Step                | Duration                  |
| ------------------- | ------------------------- |
| API request         | \< 1 second               |
| KFintech processing | 1-2 minutes               |
| Email delivery      | Depends on email provider |

## Date range options

```python theme={null}
from datetime import datetime, timedelta

# Last 1 year
requests.post(..., json={
    "email": "user@example.com",
    "from_date": (datetime.now() - timedelta(days=365)).strftime("%Y-%m-%d"),
    "to_date": datetime.now().strftime("%Y-%m-%d"),
    "password": "Abcdefghi12$"
})

# Complete transaction history (50+ years)
requests.post(..., json={
    "email": "user@example.com",
    "from_date": "1970-01-01",
    "to_date": datetime.now().strftime("%Y-%m-%d"),
    "password": "Abcdefghi12$"
})
```

## Credit usage

| Operation    | Credits |
| ------------ | ------- |
| Generate CAS | 0.5     |

## Comparison: CDSL Fetch vs CAS Generator

| Feature           | CDSL Fetch                                   | CAS Generator             |
| ----------------- | -------------------------------------------- | ------------------------- |
| **Speed**         | Real-time (\~20s)                            | 1-2 minutes               |
| **Data source**   | CDSL eCAS (all holdings)                     | KFintech + CAMS (all MFs) |
| **History**       | Current holdings                             | 50+ years transactions    |
| **User input**    | PAN + BO ID + DOB + OTP                      | Email + date range        |
| **Asset classes** | Demat + Non-Demat (stocks, bonds, MFs, etc.) | Mutual funds              |

<Note>
  **Important:** CDSL eCAS statements contain holdings from **both CDSL and NSDL** depositories. Similarly, NSDL eCAS contains both NSDL and CDSL holdings. This is a consolidated view across all depositories, not limited to the issuing depository.
</Note>

## Next steps

<CardGroup cols={2}>
  <Card title="Gmail Import" icon="envelope" href="/guides/gmail-inbox">
    Import the generated CAS
  </Card>

  <Card title="Parsing Guide" icon="file-pdf" href="/guides/parsing">
    Parse uploaded CAS files
  </Card>
</CardGroup>
