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.
POST
/
messaging_hosted_number_orders
/
{id}
/
validation_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.validateCodes('id', {
verification_codes: [{ code: 'code', phone_number: 'phone_number' }],
});
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.validate_codes(
id="id",
verification_codes=[{
"code": "code",
"phone_number": "phone_number",
}],
)
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.ValidateCodes(
context.TODO(),
"id",
telnyx.MessagingHostedNumberOrderValidateCodesParams{
VerificationCodes: []telnyx.MessagingHostedNumberOrderValidateCodesParamsVerificationCode{{
Code: "code",
PhoneNumber: "phone_number",
}},
},
)
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.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);
}
}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)<?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->validateCodes(
'id',
verificationCodes: [['code' => 'code', 'phoneNumber' => 'phone_number']],
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx messaging-hosted-number-orders validate-codes \
--api-key 'My API Key' \
--id id \
--verification-code '{code: code, phone_number: phone_number}'curl --request POST \
--url https://api.telnyx.com/v2/messaging_hosted_number_orders/{id}/validation_codes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"verification_codes": [
{
"phone_number": "<string>",
"code": "<string>"
}
]
}
'{
"data": {
"phone_numbers": [
{
"phone_number": "<string>"
}
],
"order_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}{
"errors": [
{
"code": "<string>",
"title": "<string>",
"detail": "<string>",
"source": {
"pointer": "<string>",
"parameter": "<string>"
},
"meta": {}
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Order ID related to the validation codes.
Body
application/json
Message payload
Show child attributes
Show child attributes
Response
Successful response with the phone numbers and their respective status of the validation codes.
Show child attributes
Show child attributes
Was this page helpful?
⌘I
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.validateCodes('id', {
verification_codes: [{ code: 'code', phone_number: 'phone_number' }],
});
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.validate_codes(
id="id",
verification_codes=[{
"code": "code",
"phone_number": "phone_number",
}],
)
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.ValidateCodes(
context.TODO(),
"id",
telnyx.MessagingHostedNumberOrderValidateCodesParams{
VerificationCodes: []telnyx.MessagingHostedNumberOrderValidateCodesParamsVerificationCode{{
Code: "code",
PhoneNumber: "phone_number",
}},
},
)
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.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);
}
}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)<?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->validateCodes(
'id',
verificationCodes: [['code' => 'code', 'phoneNumber' => 'phone_number']],
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx messaging-hosted-number-orders validate-codes \
--api-key 'My API Key' \
--id id \
--verification-code '{code: code, phone_number: phone_number}'curl --request POST \
--url https://api.telnyx.com/v2/messaging_hosted_number_orders/{id}/validation_codes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"verification_codes": [
{
"phone_number": "<string>",
"code": "<string>"
}
]
}
'{
"data": {
"phone_numbers": [
{
"phone_number": "<string>"
}
],
"order_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}{
"errors": [
{
"code": "<string>",
"title": "<string>",
"detail": "<string>",
"source": {
"pointer": "<string>",
"parameter": "<string>"
},
"meta": {}
}
]
}