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

# Validate OTP - Code

> Verify One-Time Passwords (OTPs) with comprehensive validation checks for secure authentication workflows and two-factor authentication systems.

## Overview

This endpoint verifies OTPs generated by the "Request and Send OTP Code" endpoint. It allows you to validate whether the OTP code provided by a user matches the one that was sent.

## Request Parameters

<ParamField body="contact_id" type="string" required>
  The contact ID that received the OTP code. Format: `xxx@c.us`
</ParamField>

<ParamField body="code" type="string" required>
  The OTP code to validate. Example: "123456"
</ParamField>

## Response

<ResponseField name="success" type="boolean">
  Indicates whether the request was successful.
</ResponseField>

<ResponseField name="message" type="string">
  A message describing the result of the operation.
</ResponseField>

<ResponseField name="data" type="object">
  <Expandable title="Data Object">
    <ResponseField name="id" type="string">
      The ID of the message.
    </ResponseField>

    <ResponseField name="code" type="string">
      The OTP code that was validated.
    </ResponseField>

    <ResponseField name="contact_id" type="string">
      The contact ID.
    </ResponseField>

    <ResponseField name="is_validated" type="boolean">
      Indicates whether the OTP code was successfully validated.
    </ResponseField>

    <ResponseField name="timestamp" type="string">
      The timestamp when the validation was triggered.
    </ResponseField>
  </Expandable>
</ResponseField>

## Error Codes

<ResponseField name="403" type="object">
  Authorization Exception - Occurs when the request is not properly authorized.
</ResponseField>

<ResponseField name="422" type="object">
  Validation Exception - Occurs when the request parameters fail validation.
</ResponseField>


## OpenAPI

````yaml POST /otp/code/validate
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/validate:
    post:
      tags:
        - OTP Code
        - OtpCode
      summary: OTP Code - Validate Code
      description: >-
        Verify One-Time Passwords (OTPs) with comprehensive validation checks
        for secure authentication workflows and two-factor authentication
        systems.
      operationId: otpCode.validateCode
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ValidateOtpCodeRequest'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                anyOf:
                  - type: object
                  - $ref: '#/components/schemas/ValidateOtpCodeResource'
        '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:
    ValidateOtpCodeRequest:
      type: object
      properties:
        contact_id:
          type: string
          description: Contact ID.
          pattern: ^[0-9]+@[cs]\.us$
          minLength: 10
          maxLength: 50
          example: xxx@c.us
        code:
          type: string
          description: OTP Code.
          pattern: ^[0-9]{4,8}$
          minLength: 4
          maxLength: 8
          example: '123456'
      required:
        - contact_id
        - code
      title: ValidateOtpCodeRequest
    ValidateOtpCodeResource:
      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.
            contact_id:
              type: string
              description: The contact id.
            is_validated:
              type: boolean
              description: The validation status.
            timestamp:
              type: string
              description: The timestamp when it triggered.
          required:
            - id
            - code
            - contact_id
            - is_validated
            - timestamp
      required:
        - success
        - message
        - data
      title: ValidateOtpCodeResource
  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

````