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

# Request Code

> Generate and send One-Time Password (OTP) codes with customizable validation settings for secure user authentication.



## OpenAPI

````yaml POST /otp/code/request
openapi: 3.1.0
info:
  title: CrunchzApp API Docs
  version: 1.0.0
  description: >-
    Comprehensive WhatsApp API for seamless messaging integration, automation,
    and customer communication in your applications.
servers:
  - url: https://api.crunchz.app/api
security:
  - http: []
paths:
  /otp/code/request:
    post:
      tags:
        - OTP Code
        - OtpCode
      summary: OTP Code - Request and Send Code
      description: >-
        Generate and send One-Time Password (OTP) codes with customizable
        validation settings for secure user authentication.
      operationId: otpCode.requestCode
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StoreOtpCodeRequest'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                anyOf:
                  - type: object
                  - $ref: '#/components/schemas/OtpCodeResource'
        '400':
          $ref: '#/components/responses/BadRequestException'
        '401':
          $ref: '#/components/responses/UnauthorizedException'
        '403':
          $ref: '#/components/responses/AuthorizationException'
        '422':
          $ref: '#/components/responses/ValidationException'
        '500':
          $ref: '#/components/responses/InternalServerErrorException'
components:
  schemas:
    StoreOtpCodeRequest:
      type: object
      properties:
        contact_id:
          type: string
          description: Contact ID .
          example: xxx@c.us
        length:
          type: number
          description: Length OTP Code.
          example: 4
          maximum: 6
        useLetter:
          type: boolean
          description: Using letter for Otp Code.
          example: false
        useNumber:
          type: boolean
          description: Using number for Otp Code.
          example: true
        allCapital:
          type: boolean
          description: Using uppercase for Otp Code.
          example: false
        name:
          type: string
          description: Application Name.
          example: Your Company Name
        expires:
          type: number
          description: Expire time in second ( e.g 30 Minute )
          example: 1800
      required:
        - contact_id
        - length
        - useLetter
        - useNumber
        - allCapital
        - name
        - expires
      title: StoreOtpCodeRequest
    OtpCodeResource:
      type: object
      properties:
        success:
          type: boolean
          description: The success status of response.
        message:
          type: string
          description: The message of response.
        data:
          type: object
          properties:
            id:
              type: string
              description: The ID of the message.
            code:
              type: string
              description: The otp code sent to phone.
            chat_id:
              type: string
              description: The chat id.
            message:
              type: string
              description: The message.
            expired_at:
              type: string
              description: The time when the code is expired.
            timestamp:
              type: string
              description: The timestamp when it triggered.
          required:
            - id
            - code
            - chat_id
            - message
            - expired_at
            - timestamp
      required:
        - success
        - message
        - data
      title: OtpCodeResource
  responses:
    BadRequestException:
      description: Bad request error
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Error overview.
            required:
              - message
    UnauthorizedException:
      description: Unauthorized error
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Error overview.
            required:
              - message
    AuthorizationException:
      description: Authorization error
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Error overview.
            required:
              - message
    ValidationException:
      description: Validation error
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Errors overview.
              errors:
                type: object
                description: A detailed description of each field that failed validation.
                additionalProperties:
                  type: array
                  items:
                    type: string
            required:
              - message
              - errors
    InternalServerErrorException:
      description: Internal server error
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Error overview.
            required:
              - message
  securitySchemes:
    http:
      type: http
      scheme: bearer
      bearerFormat: JWT

````