> ## 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.

# Parse CDSL CAS PDF

> This endpoint specifically parses CDSL CAS (Consolidated Account Statement) PDF files and returns data in a unified format.
Use this endpoint when you know the PDF is from CDSL.




## OpenAPI

````yaml /api-reference/openapi.yaml post /v4/cdsl/parse
openapi: 3.1.0
info:
  title: CAS Parser - Track Portfolios from CDSL, NSDL, CAMS, KFintech
  description: >-
    API for parsing and analyzing CAS (Consolidated Account Statement) PDF files
    from NSDL, CDSL, and CAMS/KFintech, with a unified response format
  version: 4.0.0
  contact:
    name: Sameer Kumar
    email: sameer@casparser.in
servers:
  - url: https://api.casparser.in
    description: Production server
  - url: https://portfolio-parser.api.casparser.in
    description: Legacy production server (still supported)
  - url: http://localhost:5000
    description: Local development server
security: []
tags:
  - name: CAS Parser
    description: Endpoints for parsing CAS PDF files from different sources.
  - name: CAS Generator
    description: Endpoints for generating new CAS documents via email mailback (KFintech).
  - name: CAS Fetch
    description: |
      Endpoints for fetching CAS documents with instant download.
      Currently supports CDSL via OTP authentication.
  - name: Email Import
    description: >
      Endpoints for importing CAS files directly from user email inboxes.


      **Supported Providers:** Gmail (more coming soon)


      **How it works:**

      1. Call `POST /v4/inbox/connect` to get an OAuth URL

      2. Redirect user to the OAuth URL for consent

      3. User is redirected back to your `redirect_uri` with an encrypted
      `inbox_token`

      4. Use the token to list/fetch CAS files from their inbox
      (`/v4/inbox/cas`)

      5. Files are uploaded to temporary cloud storage (URLs expire in 24 hours)


      **Security:**

      - Read-only access (we cannot send emails)

      - Tokens are encrypted with server-side secret

      - User can revoke access anytime via `/v4/inbox/disconnect`
  - name: Inbound Email
    description: >
      Create dedicated inbound email addresses for investors to forward their
      CAS statements.


      **Use Case:** Your app wants to collect CAS statements from users without
      requiring OAuth or file upload.


      **How it works:**

      1. Call `POST /v4/inbound-email` to create a unique inbound email address

      2. Display this email to your user: "Forward your CAS statement to
      ie_xxx@import.casparser.in"

      3. When user forwards a CAS email, we verify sender authenticity
      (SPF/DKIM) and call your webhook

      4. Your webhook receives email metadata + attachment download URLs


      **Sender Validation:**

      - Only emails from verified CAS authorities are processed:
        - CDSL: `eCAS@cdslstatement.com`
        - NSDL: `NSDL-CAS@nsdl.co.in`
        - CAMS: `donotreply@camsonline.com`
        - KFintech: `samfS@kfintech.com`
      - Emails failing SPF/DKIM/DMARC are rejected

      - Forwarded emails must contain the original sender in headers


      **Billing:** 0.2 credits per successfully processed valid email
  - name: Contract Note Parser
    description: >-
      Endpoints for parsing Contract Note PDF files from various SEBI brokers
      like Zerodha, Groww, Upstox, ICICI etc.
  - name: Authorization
    description: |
      Endpoints for checking API quota and credits usage.
      These endpoints help you monitor your API usage and remaining quota.
  - name: Portfolio Connect
    description: >
      Endpoints for managing access tokens for the Portfolio Connect SDK.

      Use these to generate short-lived `at_` prefixed tokens that can be safely
      passed to frontend applications.

      Access tokens can be used in place of API keys on all v4 endpoints.
  - name: Agent Auth
    description: >
      Endpoints for coding agents to obtain API keys via a browser-based
      approval flow.


      **How it works:**

      1. Agent generates a random token locally (e.g. `openssl rand -hex 32`).
      No API call needed.

      2. Agent asks the user to open
      `https://app.casparser.in/agent-auth?token=<token>&client_name=<name>`

      3. User signs in via the browser and clicks Approve.

      4. Agent polls `GET /v1/agent-auth/token/{token}` every 5 seconds until
      the key is delivered.


      **Security:**

      - Token must be 16-128 characters (recommended: 64 hex chars / 256 bits)

      - Approved keys are delivered once (one-shot) and then deleted

      - Tokens expire after 10 minutes if not approved
  - name: KYC
    description: >
      Endpoints for verifying KYC (Know Your Customer) status of Indian
      investors.


      **Data source:** CVL KRA public inquiry portal (cvlkra.com), which
      aggregates

      records from all five SEBI-registered KRAs: CVL, NDML, CAMS, Karvy, and
      KFin.


      **Status normalization:** Raw CVL portal strings are normalized into clean
      enums.

      See the `kyc_status` property on `KycPanStatusResponse` for the full list.


      **Credits:** 0.5 per successful lookup. Failed lookups are not billed.
paths:
  /v4/cdsl/parse:
    post:
      tags:
        - CAS Parser
      summary: Parse CDSL CAS PDF
      description: >
        This endpoint specifically parses CDSL CAS (Consolidated Account
        Statement) PDF files and returns data in a unified format.

        Use this endpoint when you know the PDF is from CDSL.
      operationId: cdslParse
      requestBody:
        $ref: '#/components/requestBodies/CASParseRequest'
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnifiedResponse'
        '400':
          description: >-
            Bad request (Invalid PDF file, missing parameters, invalid password,
            or incorrect CAS type)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '500':
          $ref: '#/components/responses/InternalError'
      security:
        - ApiKeyAuth: []
components:
  requestBodies:
    CASParseRequest:
      required: true
      content:
        multipart/form-data:
          schema:
            type: object
            description: Provide either `pdf_file` OR `pdf_url` (one is required)
            properties:
              pdf_file:
                type: string
                format: binary
                description: CAS PDF file to parse (required if pdf_url not provided)
              pdf_url:
                type: string
                format: uri
                description: URL to the CAS PDF file (required if pdf_file not provided)
              password:
                type: string
                description: Password for the PDF file (if required)
        application/json:
          schema:
            type: object
            description: Provide either `pdf_file` OR `pdf_url` (one is required)
            properties:
              pdf_file:
                type: string
                format: base64
                description: Base64 encoded CAS PDF file (required if pdf_url not provided)
              pdf_url:
                type: string
                format: uri
                description: URL to the CAS PDF file (required if pdf_file not provided)
              password:
                type: string
                description: Password for the PDF file (if required)
  schemas:
    UnifiedResponse:
      type: object
      properties:
        meta:
          type: object
          properties:
            cas_type:
              type: string
              enum:
                - NSDL
                - CDSL
                - CAMS_KFINTECH
              description: Type of CAS detected and processed
            statement_period:
              type: object
              properties:
                from:
                  type: string
                  format: date
                  description: Start date of the statement period
                to:
                  type: string
                  format: date
                  description: End date of the statement period
            generated_at:
              type: string
              format: date-time
              description: Timestamp when the response was generated
        investor:
          type: object
          properties:
            name:
              type: string
              description: Name of the investor
            pan:
              type: string
              description: PAN (Permanent Account Number) of the investor
            email:
              type: string
              format: email
              description: Email address of the investor
            address:
              type: string
              description: Address of the investor
            pincode:
              type: string
              description: Postal code of the investor's address
            mobile:
              type: string
              description: Mobile number of the investor
            cas_id:
              type: string
              description: CAS ID of the investor (only for NSDL and CDSL)
        summary:
          type: object
          properties:
            total_value:
              type: number
              format: float
              description: Total portfolio value across all accounts
            accounts:
              type: object
              properties:
                demat:
                  type: object
                  properties:
                    count:
                      type: integer
                      description: Number of demat accounts
                    total_value:
                      type: number
                      format: float
                      description: Total value of demat accounts
                mutual_funds:
                  type: object
                  properties:
                    count:
                      type: integer
                      description: Number of mutual fund folios
                    total_value:
                      type: number
                      format: float
                      description: Total value of mutual funds
                insurance:
                  type: object
                  properties:
                    count:
                      type: integer
                      description: Number of insurance policies
                    total_value:
                      type: number
                      format: float
                      description: Total value of insurance policies
                nps:
                  type: object
                  properties:
                    count:
                      type: integer
                      description: Number of NPS accounts
                    total_value:
                      type: number
                      format: float
                      description: Total value of NPS accounts
        demat_accounts:
          type: array
          items:
            $ref: '#/components/schemas/DematAccount'
        mutual_funds:
          type: array
          items:
            $ref: '#/components/schemas/MutualFundFolio'
        insurance:
          type: object
          properties:
            life_insurance_policies:
              type: array
              items:
                $ref: '#/components/schemas/LifeInsurancePolicy'
        nps:
          type: array
          items:
            $ref: '#/components/schemas/NPSAccount'
          description: List of NPS accounts
    ErrorResponse:
      type: object
      required:
        - status
        - msg
      properties:
        status:
          type: string
          description: The status of the error.
          enum:
            - failed
          example: failed
        msg:
          type: string
          description: A descriptive message explaining the error.
          example: Invalid PDF file or password.
    DematAccount:
      type: object
      properties:
        demat_type:
          type: string
          enum:
            - NSDL
            - CDSL
          description: Type of demat account
        dp_id:
          type: string
          description: Depository Participant ID
        dp_name:
          type: string
          description: Depository Participant name
        client_id:
          type: string
          description: Client ID
        bo_id:
          type: string
          description: Beneficiary Owner ID (primarily for CDSL)
        value:
          type: number
          format: float
          description: Total value of the demat account
        linked_holders:
          type: array
          items:
            $ref: '#/components/schemas/LinkedHolder'
          description: List of account holders linked to this demat account
        holdings:
          type: object
          properties:
            equities:
              type: array
              items:
                $ref: '#/components/schemas/Equity'
            corporate_bonds:
              type: array
              items:
                $ref: '#/components/schemas/CorporateBond'
            government_securities:
              type: array
              items:
                $ref: '#/components/schemas/GovernmentSecurity'
            aifs:
              type: array
              items:
                $ref: '#/components/schemas/AIF'
            demat_mutual_funds:
              type: array
              items:
                $ref: '#/components/schemas/DematMutualFund'
        additional_info:
          type: object
          description: Additional information specific to the demat account type
          properties:
            bo_status:
              type: string
              description: Beneficiary Owner status (CDSL)
            bo_sub_status:
              type: string
              description: Beneficiary Owner sub-status (CDSL)
            bo_type:
              type: string
              description: Beneficiary Owner type (CDSL)
            bsda:
              type: string
              description: Basic Services Demat Account status (CDSL)
            email:
              type: string
              format: email
              description: Email associated with the demat account (CDSL)
            status:
              type: string
              description: Account status (CDSL)
            nominee:
              type: string
              description: Nominee details (CDSL)
            linked_pans:
              type: array
              items:
                type: string
              description: List of linked PAN numbers (NSDL)
    MutualFundFolio:
      type: object
      properties:
        folio_number:
          type: string
          description: Folio number
        amc:
          type: string
          description: Asset Management Company name
        registrar:
          type: string
          description: Registrar and Transfer Agent name
        value:
          type: number
          format: float
          description: Total value of the folio
        linked_holders:
          type: array
          items:
            $ref: '#/components/schemas/LinkedHolder'
          description: List of account holders linked to this mutual fund folio
        schemes:
          type: array
          items:
            $ref: '#/components/schemas/MutualFundScheme'
        additional_info:
          type: object
          description: Additional folio information
          properties:
            pan:
              type: string
              description: PAN associated with the folio
            pankyc:
              type: string
              description: PAN KYC status
            kyc:
              type: string
              description: KYC status of the folio
    LifeInsurancePolicy:
      type: object
      properties:
        policy_number:
          type: string
          description: Insurance policy number
        provider:
          type: string
          description: Insurance company name
        policy_name:
          type: string
          description: Name of the insurance policy
        life_assured:
          type: string
          description: Name of the life assured
        status:
          type: string
          description: Status of the policy (e.g., Active, Lapsed)
        sum_assured:
          type: number
          format: float
          description: Sum assured amount
        premium_amount:
          type: number
          format: float
          description: Premium amount
        premium_frequency:
          type: string
          description: Frequency of premium payment (e.g., Annual, Monthly)
        additional_info:
          type: object
          description: Additional information specific to the policy
    NPSAccount:
      type: object
      properties:
        pran:
          type: string
          description: Permanent Retirement Account Number (PRAN)
        cra:
          type: string
          description: Central Record Keeping Agency name
        value:
          type: number
          format: float
          description: Total value of the NPS account
        funds:
          type: array
          items:
            $ref: '#/components/schemas/NPSFund'
        linked_holders:
          type: array
          items:
            $ref: '#/components/schemas/LinkedHolder'
          description: List of account holders linked to this NPS account
        additional_info:
          type: object
          description: Additional information specific to the NPS account
    AuthErrorResponse:
      type: object
      required:
        - status
        - msg
      properties:
        status:
          type: string
          description: The status of the error.
          example: error
        msg:
          type: string
          description: A descriptive message explaining the error.
          example: 'Authentication failed: API key is missing.'
    LinkedHolder:
      type: object
      properties:
        name:
          type: string
          description: Name of the account holder
        pan:
          type: string
          description: PAN of the account holder
    Equity:
      type: object
      properties:
        isin:
          type: string
          description: ISIN code of the equity
        name:
          type: string
          description: Name of the equity
        units:
          type: number
          format: float
          description: Number of units held
        value:
          type: number
          format: float
          description: Current market value of the holding
        transactions:
          type: array
          items:
            $ref: '#/components/schemas/Transaction'
          description: List of transactions for this holding (beta)
        additional_info:
          type: object
          description: Additional information specific to the equity
          properties:
            open_units:
              type:
                - number
                - 'null'
              format: float
              description: Opening balance units for the statement period (beta)
            close_units:
              type:
                - number
                - 'null'
              format: float
              description: Closing balance units for the statement period (beta)
    CorporateBond:
      type: object
      properties:
        isin:
          type: string
          description: ISIN code of the corporate bond
        name:
          type: string
          description: Name of the corporate bond
        units:
          type: number
          format: float
          description: Number of units held
        value:
          type: number
          format: float
          description: Current market value of the holding
        transactions:
          type: array
          items:
            $ref: '#/components/schemas/Transaction'
          description: List of transactions for this holding (beta)
        additional_info:
          type: object
          description: Additional information specific to the corporate bond
          properties:
            open_units:
              type:
                - number
                - 'null'
              format: float
              description: Opening balance units for the statement period (beta)
            close_units:
              type:
                - number
                - 'null'
              format: float
              description: Closing balance units for the statement period (beta)
    GovernmentSecurity:
      type: object
      properties:
        isin:
          type: string
          description: ISIN code of the government security
        name:
          type: string
          description: Name of the government security
        units:
          type: number
          format: float
          description: Number of units held
        value:
          type: number
          format: float
          description: Current market value of the holding
        transactions:
          type: array
          items:
            $ref: '#/components/schemas/Transaction'
          description: List of transactions for this holding (beta)
        additional_info:
          type: object
          description: Additional information specific to the government security
          properties:
            open_units:
              type:
                - number
                - 'null'
              format: float
              description: Opening balance units for the statement period (beta)
            close_units:
              type:
                - number
                - 'null'
              format: float
              description: Closing balance units for the statement period (beta)
    AIF:
      type: object
      properties:
        isin:
          type: string
          description: ISIN code of the AIF
        name:
          type: string
          description: Name of the AIF
        units:
          type: number
          format: float
          description: Number of units held
        value:
          type: number
          format: float
          description: Current market value of the holding
        transactions:
          type: array
          items:
            $ref: '#/components/schemas/Transaction'
          description: List of transactions for this holding (beta)
        additional_info:
          type: object
          description: Additional information specific to the AIF
          properties:
            open_units:
              type:
                - number
                - 'null'
              format: float
              description: Opening balance units for the statement period (beta)
            close_units:
              type:
                - number
                - 'null'
              format: float
              description: Closing balance units for the statement period (beta)
    DematMutualFund:
      type: object
      properties:
        isin:
          type: string
          description: ISIN code of the mutual fund
        name:
          type: string
          description: Name of the mutual fund
        units:
          type: number
          format: float
          description: Number of units held
        value:
          type: number
          format: float
          description: Current market value of the holding
        transactions:
          type: array
          items:
            $ref: '#/components/schemas/Transaction'
          description: List of transactions for this holding (beta)
        additional_info:
          type: object
          description: Additional information specific to the mutual fund
          properties:
            open_units:
              type:
                - number
                - 'null'
              format: float
              description: Opening balance units for the statement period (beta)
            close_units:
              type:
                - number
                - 'null'
              format: float
              description: Closing balance units for the statement period (beta)
    MutualFundScheme:
      type: object
      properties:
        isin:
          type: string
          description: ISIN code of the scheme
        name:
          type: string
          description: Scheme name
        type:
          type: string
          enum:
            - Equity
            - Debt
            - Hybrid
            - Other
          description: Type of mutual fund scheme
        units:
          type: number
          format: float
          description: Number of units held
        nav:
          type: number
          format: float
          description: Net Asset Value per unit
        value:
          type: number
          format: float
          description: Current market value of the holding
        cost:
          type: number
          format: float
          description: Cost of investment
        gain:
          type: object
          properties:
            absolute:
              type: number
              format: float
              description: Absolute gain or loss
            percentage:
              type: number
              format: float
              description: Percentage gain or loss
        transactions:
          type: array
          items:
            $ref: '#/components/schemas/Transaction'
        nominees:
          type: array
          items:
            type: string
          description: List of nominees
        additional_info:
          type: object
          description: Additional information specific to the scheme
          properties:
            advisor:
              type: string
              description: Financial advisor name (CAMS/KFintech)
            rta_code:
              type: string
              description: RTA code for the scheme (CAMS/KFintech)
            amfi:
              type: string
              description: AMFI code for the scheme (CAMS/KFintech)
            open_units:
              type:
                - number
                - 'null'
              format: float
              description: Opening balance units for the statement period
            close_units:
              type:
                - number
                - 'null'
              format: float
              description: Closing balance units for the statement period
    NPSFund:
      type: object
      properties:
        name:
          type: string
          description: Name of the NPS fund
        units:
          type: number
          format: float
          description: Number of units held
        nav:
          type: number
          format: float
          description: Net Asset Value per unit
        value:
          type: number
          format: float
          description: Current market value of the holding
        cost:
          type: number
          format: float
          description: Cost of investment
        additional_info:
          type: object
          description: Additional information specific to the NPS fund
          properties:
            tier:
              type: number
              enum:
                - 1
                - 2
                - null
              description: NPS tier (Tier I or Tier II)
            manager:
              type: string
              description: Fund manager name
    Transaction:
      type: object
      description: >-
        Unified transaction schema for all holding types (MF folios, equities,
        bonds, etc.)
      properties:
        date:
          type: string
          format: date
          description: Transaction date (YYYY-MM-DD)
        description:
          type: string
          description: Transaction description/particulars
        type:
          type: string
          description: >-
            Transaction type. Possible values are PURCHASE, PURCHASE_SIP,
            REDEMPTION, SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT,
            SWITCH_OUT_MERGER, DIVIDEND_PAYOUT, DIVIDEND_REINVEST, SEGREGATION,
            STAMP_DUTY_TAX, TDS_TAX, STT_TAX, MISC, REVERSAL, UNKNOWN.
          enum:
            - PURCHASE
            - PURCHASE_SIP
            - REDEMPTION
            - SWITCH_IN
            - SWITCH_IN_MERGER
            - SWITCH_OUT
            - SWITCH_OUT_MERGER
            - DIVIDEND_PAYOUT
            - DIVIDEND_REINVEST
            - SEGREGATION
            - STAMP_DUTY_TAX
            - TDS_TAX
            - STT_TAX
            - MISC
            - REVERSAL
            - UNKNOWN
        amount:
          type:
            - number
            - 'null'
          format: float
          description: Transaction amount in currency (computed from units × price/NAV)
        units:
          type: number
          format: float
          description: Number of units involved in transaction
        nav:
          type:
            - number
            - 'null'
          format: float
          description: NAV/price per unit on transaction date
        balance:
          type: number
          format: float
          description: Balance units after transaction
        dividend_rate:
          type:
            - number
            - 'null'
          format: float
          description: Dividend rate (for DIVIDEND_PAYOUT transactions)
        additional_info:
          type: object
          description: Additional transaction-specific fields that vary by source
          properties:
            credit:
              type: number
              format: float
              description: Units credited (demat transactions)
            debit:
              type: number
              format: float
              description: Units debited (demat transactions)
            stamp_duty:
              type: number
              format: float
              description: Stamp duty charged
            order_no:
              type: string
              description: Order/transaction reference number (demat transactions)
            price:
              type: number
              format: float
              description: Price per unit (NSDL/CDSL MF transactions)
            income_distribution:
              type: number
              format: float
              description: Income distribution amount (CDSL MF transactions)
            capital_withdrawal:
              type: number
              format: float
              description: Capital withdrawal amount (CDSL MF transactions)
  responses:
    Unauthorized:
      description: Unauthorized. This can happen if the `x-api-key` header is missing.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/AuthErrorResponse'
          example:
            status: error
            msg: >-
              Authentication failed: API key is missing. Please provide a valid
              API key in the x-api-key header.
    Forbidden:
      description: >-
        Forbidden. This can happen if the API key is invalid or the quota has
        been exceeded.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/AuthErrorResponse'
          example:
            status: error
            msg: >-
              Authentication failed: API quota exceeded or invalid API key.
              Please check your API key or quota limits.
    InternalError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: |
        Your API key for authentication.
        Use `sandbox-with-json-responses` as Sandbox key.

````