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",
"status": "verified"
}
],
"order_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
}
}{
"errors": [
{
"code": "string",
"title": "string",
"detail": "string",
"source": {
"pointer": "/data/attributes/phone_number",
"parameter": "string"
}
}
]
}Authorizations
Was this page helpful?
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",
"status": "verified"
}
],
"order_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
}
}{
"errors": [
{
"code": "string",
"title": "string",
"detail": "string",
"source": {
"pointer": "/data/attributes/phone_number",
"parameter": "string"
}
}
]
}