Create voicemail
Create voicemail settings for a phone number
POST
/
phone_numbers
/
{phone_number_id}
/
voicemail
JavaScript
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const voicemail = await client.phoneNumbers.voicemail.create('123455678900');
console.log(voicemail.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
)
voicemail = client.phone_numbers.voicemail.create(
phone_number_id="123455678900",
)
print(voicemail.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"),
)
voicemail, err := client.PhoneNumbers.Voicemail.New(
context.TODO(),
"123455678900",
telnyx.PhoneNumberVoicemailNewParams{
VoicemailRequest: telnyx.VoicemailRequestParam{},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", voicemail.Data)
}package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.phonenumbers.voicemail.VoicemailCreateParams;
import com.telnyx.sdk.models.phonenumbers.voicemail.VoicemailCreateResponse;
import com.telnyx.sdk.models.phonenumbers.voicemail.VoicemailRequest;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
VoicemailCreateParams params = VoicemailCreateParams.builder()
.phoneNumberId("123455678900")
.voicemailRequest(VoicemailRequest.builder().build())
.build();
VoicemailCreateResponse voicemail = client.phoneNumbers().voicemail().create(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
voicemail = telnyx.phone_numbers.voicemail.create("123455678900")
puts(voicemail)<?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 {
$voicemail = $client->phoneNumbers->voicemail->create(
'123455678900', enabled: true, pin: '1234'
);
var_dump($voicemail);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx phone-numbers:voicemail create \
--api-key 'My API Key' \
--phone-number-id 123455678900curl --request POST \
--url https://api.telnyx.com/v2/phone_numbers/{phone_number_id}/voicemail \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"pin": "1234",
"enabled": true
}
'{
"data": {
"enabled": true,
"pin": "1234"
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
The ID of the phone number.
Body
application/json
Details to create
Response
Successful response
Show child attributes
Show child attributes
Example:
{ "enabled": true, "pin": "1234" }
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 voicemail = await client.phoneNumbers.voicemail.create('123455678900');
console.log(voicemail.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
)
voicemail = client.phone_numbers.voicemail.create(
phone_number_id="123455678900",
)
print(voicemail.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"),
)
voicemail, err := client.PhoneNumbers.Voicemail.New(
context.TODO(),
"123455678900",
telnyx.PhoneNumberVoicemailNewParams{
VoicemailRequest: telnyx.VoicemailRequestParam{},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", voicemail.Data)
}package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.phonenumbers.voicemail.VoicemailCreateParams;
import com.telnyx.sdk.models.phonenumbers.voicemail.VoicemailCreateResponse;
import com.telnyx.sdk.models.phonenumbers.voicemail.VoicemailRequest;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
VoicemailCreateParams params = VoicemailCreateParams.builder()
.phoneNumberId("123455678900")
.voicemailRequest(VoicemailRequest.builder().build())
.build();
VoicemailCreateResponse voicemail = client.phoneNumbers().voicemail().create(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
voicemail = telnyx.phone_numbers.voicemail.create("123455678900")
puts(voicemail)<?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 {
$voicemail = $client->phoneNumbers->voicemail->create(
'123455678900', enabled: true, pin: '1234'
);
var_dump($voicemail);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx phone-numbers:voicemail create \
--api-key 'My API Key' \
--phone-number-id 123455678900curl --request POST \
--url https://api.telnyx.com/v2/phone_numbers/{phone_number_id}/voicemail \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"pin": "1234",
"enabled": true
}
'{
"data": {
"enabled": true,
"pin": "1234"
}
}