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

# Mask Aadhaar

> Mask sensitive information from Aadhaar card documents

## Overview

This API masks sensitive information from Aadhaar card images or PDFs to protect privacy while maintaining document usability. Perfect for KYC workflows where you need to collect and store documents securely.

## Supported Formats

* **Images**: JPG, JPEG, PNG
* **Documents**: PDF

## Required Information

* **Document URL**: Publicly accessible URL of the Aadhaar document
* **Consent**: Must be "yes" to proceed with masking

## Masking Options

Control exactly what gets masked:

| Option                     | Default | Description                                       |
| -------------------------- | ------- | ------------------------------------------------- |
| `mask_qr`                  | `false` | Mask the QR code on the Aadhaar card              |
| `mask_all_digits`          | `false` | Mask all digits of the Aadhaar number             |
| `extract_last_four_digits` | `false` | Extract only last 4 digits (e.g., returns "6032") |

## Common Use Cases

### 1. Standard KYC Masking

Mask all digits and extract the last 4 for verification:

```json theme={null}
{
  "document_url": "https://example.com/aadhaar.jpg",
  "consent": "yes",
  "mask_qr": true,
  "mask_all_digits": false,
  "extract_last_four_digits": true
}
```

### 2. Complete Privacy

Mask everything without extracting digits:

```json theme={null}
{
  "document_url": "https://example.com/aadhaar.jpg",
  "consent": "yes",
  "mask_qr": true,
  "mask_all_digits": true,
  "extract_last_four_digits": false
}
```

## Response Data

* **Masked Document URL**: Link to the masked version (valid for 30 days)
* **Original Document URL**: Link to the secure original (valid for 30 days)
* **Last 4 Digits**: Returned if `extract_last_four_digits` was enabled
* **Detection Status**: Indicates if an Aadhaar number was found in the document

## Important Notes

* The document URL must be publicly accessible during processing
* Consent must be explicitly set to "yes"
* Poor quality images may fail to process


## OpenAPI

````yaml POST /v2/mask/aadhaar
openapi: 3.0.0
info:
  title: KonnectNXT API Store
  description: >-
    A sample API that uses a plant store as an example to demonstrate features
    in the OpenAPI specification
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://bgv.konnectnxt.com/api
    description: Production
  - url: https://testbgv.konnectnxt.com/api
    description: QA
security:
  - bearerAuth: []
paths:
  /v2/mask/aadhaar:
    post:
      tags:
        - Masking
        - Document Masking
      summary: Mask Aadhaar Card
      description: >-
        Masks sensitive information from Aadhaar card images or PDFs. Returns a
        URL to the masked document. Processing typically takes 2-5 seconds.
      operationId: maskAadhaar
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AadhaarMaskRequest'
            examples:
              maskWithLastFourDigits:
                summary: Mask with last 4 digits extracted
                value:
                  document_url: https://example.com/documents/aadhaar_sample.jpg
                  consent: 'yes'
                  mask_qr: true
                  mask_all_digits: true
                  extract_last_four_digits: true
              maskComplete:
                summary: Complete masking
                value:
                  document_url: https://example.com/documents/aadhaar_complete.pdf
                  consent: 'yes'
                  mask_qr: true
                  mask_all_digits: true
      responses:
        '200':
          description: Aadhaar masked successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AadhaarMaskSuccessResponse'
              examples:
                successWithLastFour:
                  summary: Success with last 4 digits
                  value:
                    status: success
                    code: 200
                    message: Operation completed successfully
                    data:
                      document_url: https://storage.example.com/masked_document_abc123.jpg
                      original_document_url: https://storage.example.com/original_document_xyz456.jpg
                      id_number: '6032'
                      id_number_found: true
                    credits_used: 1
                    credits_remaining: 99
                successCompletelyMasked:
                  summary: Success with complete masking
                  value:
                    status: success
                    code: 200
                    message: Operation completed successfully
                    data:
                      document_url: https://storage.example.com/masked_document_def789.jpg
                      original_document_url: https://storage.example.com/original_document_ghi012.jpg
                      id_number: null
                      id_number_found: false
                    credits_used: 1
                    credits_remaining: 98
        '400':
          description: Bad Request - Invalid input parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error_WithCredits'
              examples:
                invalidURL:
                  summary: Invalid document URL
                  value:
                    status: error
                    code: 400
                    message: document_url must start with http:// or https://
                    data: null
                missingConsent:
                  summary: Missing consent
                  value:
                    status: error
                    code: 400
                    message: consent is not taken, cannot proceed with masking
                    data: null
                invalidConsentValue:
                  summary: Invalid consent value
                  value:
                    status: error
                    code: 400
                    message: consent must be 'yes' or 'no'
                    data: null
                missingDocumentUrl:
                  summary: Missing document URL
                  value:
                    status: error
                    code: 400
                    message: document_url is required
                    data: null
                invalidDataType:
                  summary: Invalid data type
                  value:
                    status: error
                    code: 400
                    message: mask_qr must be a boolean
                    data: null
        '401':
          $ref: '#/components/responses/401'
        '402':
          $ref: '#/components/responses/402'
        '403':
          $ref: '#/components/responses/403'
        '422':
          description: Unprocessable Entity - Document processing failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error_WithCredits'
              examples:
                documentNotAccessible:
                  summary: Document URL not accessible
                  value:
                    status: error
                    code: 422
                    message: Unable to access document at the provided URL
                    data: null
                invalidDocument:
                  summary: Invalid document format
                  value:
                    status: error
                    code: 422
                    message: >-
                      Document format not supported. Supported formats: JPG,
                      PNG, PDF
                    data: null
                noAadhaarFound:
                  summary: No Aadhaar found in document
                  value:
                    status: error
                    code: 422
                    message: No Aadhaar card detected in the provided document
                    data: null
                poorQuality:
                  summary: Poor document quality
                  value:
                    status: error
                    code: 422
                    message: Document quality is too poor for processing
                    data: null
        '429':
          description: Too Many Requests - Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error_WithCredits'
              examples:
                rateLimitExceeded:
                  summary: Rate limit exceeded
                  value:
                    status: error
                    code: 429
                    message: Too many requests. Please try again in 60 seconds
                    data: null
        '500':
          $ref: '#/components/responses/500_WithCredits'
components:
  schemas:
    AadhaarMaskRequest:
      type: object
      required:
        - document_url
        - consent
      properties:
        document_url:
          type: string
          format: uri
          description: >-
            Publicly accessible URL of the Aadhaar document to be masked.
            Supports both images (JPG, PNG) and PDF documents.
          example: https://example.com/documents/aadhaar_card.jpg
          minLength: 10
          maxLength: 2048
          pattern: ^https?://.+
        consent:
          type: string
          enum:
            - 'yes'
            - 'no'
          description: >-
            User consent for masking the document. Must be 'yes' to proceed with
            masking.
          example: 'yes'
        mask_qr:
          type: boolean
          default: false
          description: >-
            Whether to mask the QR code on the Aadhaar card. Set to true to
            mask, false to keep visible.
          example: true
        mask_all_digits:
          type: boolean
          default: false
          description: >-
            Whether to mask all digits of the Aadhaar number. Set to true to
            mask all digits, false to keep visible.
          example: true
        extract_last_four_digits:
          type: boolean
          default: false
          description: >-
            Whether to extract and show only the last four digits of Aadhaar
            number. Set to true to extract last 4 digits (e.g., returns '6032'
            in id_number field), false to return null.
          example: true
    AadhaarMaskSuccessResponse:
      allOf:
        - $ref: '#/components/schemas/APIBaseResponse'
        - type: object
          properties:
            data:
              $ref: '#/components/schemas/MaskedDocumentData'
        - $ref: '#/components/schemas/Credits'
    Error_WithCredits:
      allOf:
        - $ref: '#/components/schemas/Error'
        - $ref: '#/components/schemas/APIErrorData'
        - $ref: '#/components/schemas/Credits'
    APIBaseResponse:
      type: object
      required:
        - status
        - code
        - message
      properties:
        status:
          $ref: '#/components/schemas/APIStatus'
        code:
          $ref: '#/components/schemas/HTTPCode'
        message:
          $ref: '#/components/schemas/APIMessage'
    MaskedDocumentData:
      type: object
      properties:
        document_url:
          type: string
          format: uri
          description: >-
            URL of the masked Aadhaar document. This URL is valid for 30 days
            from generation.
          example: https://storage.example.com/masked_abc123def456.jpg
        original_document_url:
          type: string
          format: uri
          description: >-
            URL of the original unmasked document (stored securely). This URL is
            valid for 30 days from generation.
          example: https://storage.example.com/original_xyz789ghi012.jpg
        id_number:
          type: string
          nullable: true
          description: >-
            Last four digits of the Aadhaar number (if extract_last_four_digits
            was true). Returns null if not extracted.
          example: '6032'
          pattern: ^\d{4}$|^null$
        id_number_found:
          type: boolean
          description: Indicates whether an Aadhaar number was detected in the document.
          example: true
    Credits:
      type: object
      properties:
        credits_used:
          $ref: '#/components/schemas/CreditsUsed'
        credits_left:
          $ref: '#/components/schemas/CreditsLeft'
      required:
        - credits_used
        - credits_left
    Error:
      allOf:
        - $ref: '#/components/schemas/APIBaseResponse'
    APIErrorData:
      type: object
      properties:
        data:
          type: object
          nullable: true
          example: null
    APIStatus:
      type: string
      enum:
        - success
        - error
      description: Overall status of the API
    HTTPCode:
      type: integer
      description: HTTP status code
      example: 400
    APIMessage:
      type: string
      description: Description of the response or error
      example: Invalid request parameters
    CreditsUsed:
      type: integer
      description: Represents the total number of credits used in this request.
      example: 3
    CreditsLeft:
      type: integer
      description: 'Represents the remaining credits available for use. '
      example: 4040
  responses:
    '401':
      description: Unauthorized
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/Error'
              - $ref: '#/components/schemas/APIErrorData'
          examples:
            Missing Token:
              summary: Bearer token is missing or invalid.
              value:
                status: error
                code: 401
                message: Bearer token is missing or invalid.
                data: null
            Incorrect Token Format:
              summary: Token format is incorrect
              value:
                status: error
                code: 401
                message: Token format is incorrect
                data: null
            No Admin Found:
              summary: No admin found for this request
              value:
                status: error
                code: 401
                message: No admin user found for this organization
                data: null
            Invalid API Key:
              summary: Invalid API Key
              value:
                status: error
                code: 401
                message: Invalid API key (organization ID)
                data: null
            User not Found:
              summary: User not found
              value:
                status: error
                code: 401
                message: User not found.
                data: null
    '402':
      description: Payment Required
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/Error'
              - $ref: '#/components/schemas/APIErrorData'
          examples:
            Credit Limit Exceed:
              summary: Credit Limit Exceeded.
              value:
                status: error
                code: 402
                message: Credit Limit Exceeded.
                data: null
            Insufficient Credits:
              summary: Insufficient credits
              value:
                status: error
                code: 402
                message: 'Insufficient credits: 2 required, 1 remaining.'
                data: null
    '403':
      description: Forbidden
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/Error'
              - $ref: '#/components/schemas/APIErrorData'
          examples:
            Token Revoked:
              summary: Token access has been Revoked, Contact Support.
              value:
                status: error
                code: 403
                message: Token access has been Revoked, Contact Support.
                data: null
            Token Inactive:
              summary: Token is Inactive, Contact Support.
              value:
                status: error
                code: 403
                message: Token is Inactive, Contact Support.
                data: null
    500_WithCredits:
      description: Internal Server Error
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/Error'
              - $ref: '#/components/schemas/APIErrorData'
              - $ref: '#/components/schemas/Credits'
          examples:
            Internal Server Error:
              summary: Internal Server Error.
              value:
                status: error
                code: 500
                message: Internal Server Error.
                data: null
                credits_used: 3
                credits_remaining: 178
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key issued by KonnectNXT. Pass as `Authorization: Bearer
        <your_api_key>`.

````