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

# Encrypt data



## OpenAPI

````yaml /openapi/openapi.yaml post /v2/encrypt
openapi: 3.0.3
info:
  title: Qanapi
  version: 3.0.0
  description: Secure API with enforced API Key headers. Supports V2 and V3 endpoints.
servers:
  - url: https://{subdomain}.qanapi.cloud/api
    description: The Qanapi API server
    variables:
      subdomain:
        default: ''
        description: Customer-specific subdomain.
security:
  - ApiKeyAuth: []
paths:
  /v2/encrypt:
    post:
      tags:
        - Encryption
      summary: Encrypt data
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/V2EncryptRequest'
            example:
              data:
                password: secret
              sensitiveFields:
                - password
              attributes:
                classification: confidential
                owner: alice@example.com
                tags:
                  - legal
              access:
                acl:
                  - admin
      responses:
        '200':
          description: Encrypted data
          content:
            application/json:
              schema:
                $ref: ef85b08d-630f-46aa-836e-61c2080d03b4
              example:
                data:
                  password: enc$::abc123::...
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
      security:
        - BearerAuth: []
components:
  schemas:
    V2EncryptRequest:
      type: object
      required:
        - data
      properties:
        data:
          description: >
            The actual data to encrypt.

            - Can be a scalar (string/number), object, or array.

            - If the value is an object or array, only the specified
            `sensitiveFields` are encrypted.
          oneOf:
            - type: string
            - type: number
            - type: object
              additionalProperties: true
            - type: array
              items:
                x-stainless-any: true
        sensitiveFields:
          type: array
          items:
            type: string
          description: |
            Laravel-style dot-notated paths to fields that should be encrypted.

            Supports:
              - Dot notation for nested fields: `user.profile.ssn`
              - Wildcard `*` for arrays or dynamic keys: `users.*.token`

            Examples:
              - `password`
              - `user.credentials.secret`
              - `accounts.*.secret`
              - `teams.*.members.*.email`
        attributes:
          type: object
          description: Optional metadata describing the data's context.
          properties:
            classification:
              type: string
              enum:
                - public
                - internal
                - confidential
                - restricted
              example: confidential
            owner:
              type: string
              format: email
              example: jane@example.com
            tags:
              type: array
              items:
                type: string
              example:
                - pii
                - finance
        access:
          type: object
          properties:
            acl:
              type: array
              items:
                type: string
              description: >
                Access control list — list of user roles authorized to decrypt
                this data.
              example:
                - admin
                - auditor
    Error:
      type: object
      required:
        - message
      properties:
        message:
          type: string
          example: An error occurred.
  responses:
    UnauthorizedError:
      description: Unauthorized - Invalid API Key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            unauthorized:
              $ref: '#/components/examples/unauthorized'
    ForbiddenError:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            forbidden:
              $ref: '#/components/examples/forbidden'
  examples:
    unauthorized:
      value:
        message: Unauthenticated.
    forbidden:
      value:
        message: This action is unauthorized.
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-qanapi-authorization
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````