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

# Validate hosted number codes

> Validate the verification codes sent to the numbers of the hosted order. The verification codes must be created in the verification codes endpoint.



## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/messaging/hosted-numbers.yml post /messaging_hosted_number_orders/{id}/validation_codes
openapi: 3.1.0
info:
  title: Telnyx Messaging Hosted Numbers API
  version: 2.0.0
  description: API for messaging hosted number orders.
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
security:
  - bearerAuth: []
paths:
  /messaging_hosted_number_orders/{id}/validation_codes:
    post:
      tags:
        - Hosted Numbers
      summary: Validate hosted number codes
      description: >-
        Validate the verification codes sent to the numbers of the hosted order.
        The verification codes must be created in the verification codes
        endpoint.
      operationId: ValidateVerificationCodesForMessagingHostedNumberOrder
      parameters:
        - name: id
          in: path
          description: Order ID related to the validation codes.
          required: true
          schema:
            type: string
      requestBody:
        description: Message payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ValidationCodesRequest'
      responses:
        '200':
          $ref: '#/components/responses/ValidationCodesResponse'
        4XX:
          $ref: '#/components/responses/messaging_GenericErrorResponse'
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Telnyx from 'telnyx';


            const client = new Telnyx({
              apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
            });


            const response = await
            client.messagingHostedNumberOrders.validateCodes('id', {
              verification_codes: [{ code: 'code', phone_number: 'phone_number' }],
            });


            console.log(response.data);
        - lang: Python
          source: |-
            import os
            from telnyx import Telnyx

            client = Telnyx(
                api_key=os.environ.get("TELNYX_API_KEY"),  # This is the default and can be omitted
            )
            response = client.messaging_hosted_number_orders.validate_codes(
                id="id",
                verification_codes=[{
                    "code": "code",
                    "phone_number": "phone_number",
                }],
            )
            print(response.data)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/team-telnyx/telnyx-go\"\n\t\"github.com/team-telnyx/telnyx-go/option\"\n)\n\nfunc main() {\n\tclient := telnyx.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tresponse, err := client.MessagingHostedNumberOrders.ValidateCodes(\n\t\tcontext.TODO(),\n\t\t\"id\",\n\t\ttelnyx.MessagingHostedNumberOrderValidateCodesParams{\n\t\t\tVerificationCodes: []telnyx.MessagingHostedNumberOrderValidateCodesParamsVerificationCode{{\n\t\t\t\tCode:        \"code\",\n\t\t\t\tPhoneNumber: \"phone_number\",\n\t\t\t}},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.Data)\n}\n"
        - lang: Java
          source: >-
            package com.telnyx.sdk.example;


            import com.telnyx.sdk.client.TelnyxClient;

            import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;

            import
            com.telnyx.sdk.models.messaginghostednumberorders.MessagingHostedNumberOrderValidateCodesParams;

            import
            com.telnyx.sdk.models.messaginghostednumberorders.MessagingHostedNumberOrderValidateCodesResponse;


            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    TelnyxClient client = TelnyxOkHttpClient.fromEnv();

                    MessagingHostedNumberOrderValidateCodesParams params = MessagingHostedNumberOrderValidateCodesParams.builder()
                        .id("id")
                        .addVerificationCode(MessagingHostedNumberOrderValidateCodesParams.VerificationCode.builder()
                            .code("code")
                            .phoneNumber("phone_number")
                            .build())
                        .build();
                    MessagingHostedNumberOrderValidateCodesResponse response = client.messagingHostedNumberOrders().validateCodes(params);
                }
            }
        - lang: Ruby
          source: |-
            require "telnyx"

            telnyx = Telnyx::Client.new(api_key: "My API Key")

            response = telnyx.messaging_hosted_number_orders.validate_codes(
              "id",
              verification_codes: [{code: "code", phone_number: "phone_number"}]
            )

            puts(response)
        - lang: CLI
          source: |-
            telnyx messaging-hosted-number-orders validate-codes \
              --api-key 'My API Key' \
              --id id \
              --verification-code '{code: code, phone_number: phone_number}'
components:
  schemas:
    ValidationCodesRequest:
      type: object
      properties:
        verification_codes:
          type: array
          items:
            type: object
            properties:
              phone_number:
                type: string
                x-format: +E.164
              code:
                type: string
            required:
              - phone_number
              - code
      required:
        - verification_codes
    ValidationCodes:
      type: object
      properties:
        phone_numbers:
          type: array
          items:
            type: object
            properties:
              phone_number:
                type: string
                x-format: +E.164
              status:
                type: string
                enum:
                  - verified
                  - rejected
                  - already_verified
            required:
              - phone_number
              - status
        order_id:
          type: string
          format: uuid
      required:
        - phone_numbers
        - order_id
    messaging_Errors:
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/messaging_Error'
    messaging_Error:
      required:
        - code
        - title
      properties:
        code:
          type: string
          x-format: integer
        title:
          type: string
        detail:
          type: string
        source:
          type: object
          properties:
            pointer:
              description: JSON pointer (RFC6901) to the offending entity.
              type: string
              format: json-pointer
            parameter:
              description: Indicates which query parameter caused the error.
              type: string
        meta:
          type: object
  responses:
    ValidationCodesResponse:
      description: >-
        Successful response with the phone numbers and their respective status
        of the validation codes.
      content:
        application/json:
          schema:
            type: object
            title: Retrieve Messaging Hosted Number Response
            properties:
              data:
                $ref: '#/components/schemas/ValidationCodes'
    messaging_GenericErrorResponse:
      description: Unexpected error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/messaging_Errors'
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````