Skip to main content
POST
/
messaging_hosted_number_orders
/
{id}
/
verification_codes
JavaScript
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.createVerificationCodes('id', {
  phone_numbers: ['string'],
  verification_method: 'sms',
});

console.log(response.data);
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.create_verification_codes(
    id="id",
    phone_numbers=["string"],
    verification_method="sms",
)
print(response.data)
package main

import (
	"context"
	"fmt"

	"github.com/team-telnyx/telnyx-go"
	"github.com/team-telnyx/telnyx-go/option"
)

func main() {
	client := telnyx.NewClient(
		option.WithAPIKey("My API Key"),
	)
	response, err := client.MessagingHostedNumberOrders.NewVerificationCodes(
		context.TODO(),
		"id",
		telnyx.MessagingHostedNumberOrderNewVerificationCodesParams{
			PhoneNumbers:       []string{"string"},
			VerificationMethod: telnyx.MessagingHostedNumberOrderNewVerificationCodesParamsVerificationMethodSMS,
		},
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", response.Data)
}
package com.telnyx.sdk.example;

import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.messaginghostednumberorders.MessagingHostedNumberOrderCreateVerificationCodesParams;
import com.telnyx.sdk.models.messaginghostednumberorders.MessagingHostedNumberOrderCreateVerificationCodesResponse;

public final class Main {
    private Main() {}

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

        MessagingHostedNumberOrderCreateVerificationCodesParams params = MessagingHostedNumberOrderCreateVerificationCodesParams.builder()
            .id("id")
            .addPhoneNumber("string")
            .verificationMethod(MessagingHostedNumberOrderCreateVerificationCodesParams.VerificationMethod.SMS)
            .build();
        MessagingHostedNumberOrderCreateVerificationCodesResponse response = client.messagingHostedNumberOrders().createVerificationCodes(params);
    }
}
require "telnyx"

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

response = telnyx.messaging_hosted_number_orders.create_verification_codes(
  "id",
  phone_numbers: ["string"],
  verification_method: :sms
)

puts(response)
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;

$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');

try {
  $response = $client->messagingHostedNumberOrders->createVerificationCodes(
    'id', phoneNumbers: ['string'], verificationMethod: 'sms'
  );

  var_dump($response);
} catch (APIException $e) {
  echo $e->getMessage();
}
telnyx messaging-hosted-number-orders create-verification-codes \
  --api-key 'My API Key' \
  --id id \
  --phone-number string \
  --verification-method sms
curl --request POST \
  --url https://api.telnyx.com/v2/messaging_hosted_number_orders/{id}/verification_codes \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "phone_numbers": [
    "<string>"
  ]
}
'
{
  "data": [
    {
      "phone_number": "<string>",
      "verification_code_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
      "error": "<string>"
    }
  ]
}
{
  "errors": [
    {
      "code": "<string>",
      "title": "<string>",
      "detail": "<string>",
      "source": {
        "pointer": "<string>",
        "parameter": "<string>"
      },
      "meta": {}
    }
  ]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

id
string
required

Order ID to have a verification code created.

Body

application/json

Message payload

phone_numbers
string[]
required
verification_method
enum<string>
required
Available options:
sms,
call

Response

Verification codes created and sent to the phone numbers of the hosted order.

data
VerificationCodeResult · object[]
required