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

# DigiLocker aggregate (one-call convenience)

> Return everything available for a DigiLocker session in a single call.
Each section is independent: if one is unavailable (e.g. the investor
didn't consent to it), it's reported under `errors` and the rest of the
response still succeeds.

- `identity` — verified identity, when requested via `documents` (free).
- `documents` — list of the investor's documents (free). Set
  `include_documents: false` to skip.
- `fetched` — for each document in `fetch_documents`, the parsed document data.

**Credits:** 0.25 per call, regardless of how many documents are
fetched or whether identity is returned.




## OpenAPI

````yaml /api-reference/openapi.yaml post /v1/kyc/digilocker/result/{session_id}
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:
  /v1/kyc/digilocker/result/{session_id}:
    post:
      tags:
        - KYC
      summary: DigiLocker aggregate (one-call convenience)
      description: >
        Return everything available for a DigiLocker session in a single call.

        Each section is independent: if one is unavailable (e.g. the investor

        didn't consent to it), it's reported under `errors` and the rest of the

        response still succeeds.


        - `identity` — verified identity, when requested via `documents` (free).

        - `documents` — list of the investor's documents (free). Set
          `include_documents: false` to skip.
        - `fetched` — for each document in `fetch_documents`, the parsed
        document data.


        **Credits:** 0.25 per call, regardless of how many documents are

        fetched or whether identity is returned.
      operationId: digilockerResult
      parameters:
        - name: session_id
          in: path
          required: true
          schema:
            type: string
          description: The `session_id` returned by `/v1/kyc/digilocker/session`.
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                fetch_documents:
                  type: array
                  items:
                    type: string
                    enum:
                      - pan
                      - aadhaar
                      - driving_licence
                  description: |
                    Documents to additionally fetch + parse from the locker.
                    Default: [] (no document fetch, no fetch billing).
                  example:
                    - pan
                    - driving_licence
                include_documents:
                  type: boolean
                  default: true
                  description: Include the issued-documents list.
      responses:
        '200':
          description: Aggregate result (sections present per availability)
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: success
                  identity:
                    oneOf:
                      - $ref: '#/components/schemas/DigilockerVerifiedIdentity'
                      - type: 'null'
                  consent:
                    $ref: '#/components/schemas/DigilockerConsent'
                  consented_documents:
                    type: array
                    description: Friendly names of documents the user consented to share.
                    items:
                      type: string
                    example:
                      - pan
                      - driving_licence
                  documents:
                    type: array
                    items:
                      $ref: '#/components/schemas/DigilockerDocument'
                  fetched:
                    type: object
                    description: >
                      Parsed documents keyed by the `fetch_documents` value

                      (pan/aadhaar/driving_licence). Value is null if the
                      document

                      was requested but unavailable. Each parsed object also

                      includes a `signature` block.
                    properties:
                      pan:
                        oneOf:
                          - $ref: '#/components/schemas/DigilockerPan'
                          - type: 'null'
                      aadhaar:
                        oneOf:
                          - $ref: '#/components/schemas/DigilockerAadhaar'
                          - type: 'null'
                      driving_licence:
                        oneOf:
                          - $ref: '#/components/schemas/DigilockerDrivingLicence'
                          - type: 'null'
                  errors:
                    type: object
                    description: Per-section error codes (omitted when there are none).
                    additionalProperties:
                      type: string
        '401':
          $ref: '#/components/responses/Unauthorized'
      security:
        - ApiKeyAuth: []
        - AccessTokenAuth: []
components:
  schemas:
    DigilockerVerifiedIdentity:
      type: object
      description: |
        The investor's verified identity. Only fields the investor shared are
        populated. `verified` contains the authenticated document identifiers
        (e.g. PAN, Aadhaar number).
      properties:
        name:
          type:
            - string
            - 'null'
          example: Anjali Sharma
        dob:
          type:
            - string
            - 'null'
          example: '1990-05-16'
        gender:
          type:
            - string
            - 'null'
          example: F
        email:
          type:
            - string
            - 'null'
          example: anjali@example.com
        mobile:
          type:
            - string
            - 'null'
          example: 98XXXXXX10
        digilocker_id:
          type:
            - string
            - 'null'
          example: rahul22031995
        username:
          type:
            - string
            - 'null'
          description: DigiLocker preferred username
          example: rahul22031995
        care_of:
          type:
            - string
            - 'null'
          example: S/O Rajesh Sharma
        address:
          type:
            - string
            - 'null'
        verified:
          type: object
          description: >-
            Authenticated document identifiers (keys present only when
            verified).
          properties:
            pan:
              type: string
              example: ABCDE1234F
            aadhaar:
              type: string
              description: Usually masked
              example: XXXXXXXX1234
            driving_licence:
              type: string
              example: KA01-20110012345
          additionalProperties: true
    DigilockerConsent:
      type: object
      description: |
        Consent receipt captured at session start. Carried through the flow for
        audit (DPDP / RBI compliance).
      properties:
        purpose:
          type:
            - string
            - 'null'
          description: The consent_purpose provided at /session.
          example: KYC for loan account opening
        consented_at:
          type:
            - string
            - 'null'
          format: date-time
          description: ISO 8601 timestamp (UTC) when consent was captured.
          example: '2026-05-30T22:37:17+00:00'
    DigilockerDocument:
      type: object
      description: Metadata for a single issued document in the user's DigiLocker.
      properties:
        name:
          type: string
          description: Document name
          example: PAN Verification Record
        type:
          type: string
          example: file
        doctype:
          type: string
          description: 5-character DigiLocker document type code
          example: PANCR
        issuer:
          type: string
          example: Income Tax Department
        issuerid:
          type: string
          example: in.gov.pan
        uri:
          type: string
          description: Unique DigiLocker identifier for the document
          example: in.gov.pan-PANCR-xxxxxxxxxxxx
        mime:
          type: array
          items:
            type: string
          example:
            - application/pdf
            - application/xml
        date:
          type:
            - string
            - 'null'
          format: date
          description: Last modified date in DigiLocker, normalized to ISO 8601.
          example: '2024-09-19'
    DigilockerPan:
      type: object
      description: |
        PAN certificate data parsed from DigiLocker XML (returned as `parsed`
        when `parse=pan`). Any field may be null if absent in the source XML.
      properties:
        pan:
          type:
            - string
            - 'null'
          description: PAN number
          example: ABCPD1234E
        name:
          type:
            - string
            - 'null'
          description: PAN holder name
          example: RAHUL SHARMA
        father_name:
          type:
            - string
            - 'null'
          description: Father/spouse name (the `swd` field; often empty)
          example: null
        dob:
          type:
            - string
            - 'null'
          description: Date of birth (DD-MM-YYYY as returned)
          example: 22-03-1995
        gender:
          type:
            - string
            - 'null'
          example: MALE
        status:
          type:
            - string
            - 'null'
          description: Certificate status (e.g. "A" = Active)
          example: A
        verified_on:
          type:
            - string
            - 'null'
          description: Timestamp DigiLocker verified the record
          example: 31-05-2026 03:55:02
        signature:
          $ref: '#/components/schemas/DigilockerSignature'
    DigilockerAadhaar:
      type: object
      description: >
        e-Aadhaar (Aadhaar Paperless Offline eKYC) data parsed from DigiLocker
        XML.

        Any field may be null if not present in the source XML.
      properties:
        name:
          type:
            - string
            - 'null'
          description: Full name as on Aadhaar
          example: Anjali Sharma
        dob:
          type:
            - string
            - 'null'
          description: Date of birth (as returned by DigiLocker, typically DD-MM-YYYY)
          example: 16-05-1990
        gender:
          type:
            - string
            - 'null'
          description: Gender (M, F, or T)
          example: F
        care_of:
          type:
            - string
            - 'null'
          description: Care-of / guardian field
          example: S/O Rajesh Sharma
        address:
          type:
            - string
            - 'null'
          description: Full address assembled from the Aadhaar address fields
          example: 12, MG Road, Indiranagar, Bengaluru, Karnataka, 560038, India
        photo_base64:
          type:
            - string
            - 'null'
          description: Base64-encoded photograph from the Aadhaar XML
        masked_aadhaar:
          type:
            - string
            - 'null'
          description: Masked Aadhaar number (only last 4 digits visible)
          example: XXXXXXXX1234
        session_id:
          type:
            - string
            - 'null'
          description: DigiLocker/UIDAI reference id for this eKYC document
    DigilockerDrivingLicence:
      type: object
      description: |
        Driving licence data parsed from DigiLocker XML (returned under
        `fetched.driving_licence`). Any field may be null if absent in the
        source XML.
      properties:
        dl_number:
          type:
            - string
            - 'null'
          example: KA0120190008989
        name:
          type:
            - string
            - 'null'
          example: Rahul Sharma
        father_name:
          type:
            - string
            - 'null'
          example: Suresh Sharma
        dob:
          type:
            - string
            - 'null'
          description: Date of birth, normalized to ISO 8601.
          example: '1995-03-22'
        gender:
          type:
            - string
            - 'null'
          example: M
        status:
          type:
            - string
            - 'null'
          example: A
        issued_at:
          type:
            - string
            - 'null'
          example: RTO, Bengaluru
        issue_date:
          type:
            - string
            - 'null'
          format: date
        valid_from:
          type:
            - string
            - 'null'
          format: date
        expiry_date:
          type:
            - string
            - 'null'
          format: date
        present_address:
          type:
            - string
            - 'null'
        permanent_address:
          type:
            - string
            - 'null'
        categories:
          type: array
          description: Vehicle classes the holder is licensed for.
          items:
            type: object
            properties:
              code:
                type: string
              abbreviation:
                type: string
              description:
                type: string
              issue_date:
                type: string
                format: date
        signature:
          $ref: '#/components/schemas/DigilockerSignature'
    DigilockerSignature:
      type: object
      description: >
        Signature provenance for a fetched document. Reports whether a signed

        XML block with an X.509 certificate is present, plus the signing

        certificate's details. Note: this is provenance reporting, not full

        XML-DSIG cryptographic verification (the trust model is
        direct-from-source

        retrieval, consistent with the industry).
      properties:
        signature_present:
          type: boolean
          example: true
        certificate:
          type:
            - object
            - 'null'
          properties:
            subject:
              type: string
              example: C=IN,O=DIGITAL INDIA CORPORATION,CN=DS DIGITAL INDIA CORPORATION
            issuer:
              type: string
            valid_from:
              type: string
              format: date-time
            valid_until:
              type: string
              format: date-time
            serial_number:
              type: string
    AuthErrorResponse:
      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: 'Authentication failed: API key is missing.'
  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: failed
            msg: >-
              Authentication failed: API key is missing. Please provide a valid
              API key in the x-api-key header.
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: |
        Your API key for authentication.
        Use `sandbox-with-json-responses` as Sandbox key.

````