Create voicemail
Create voicemail settings for a phone number. You can also configure a custom greeting by setting the greeting object: use mode custom_greeting together with a media_name that points to an audio file uploaded through the Media Storage API, or mode default to use the standard system greeting.
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 '
{
"enabled": true,
"pin": "1234",
"greeting": {
"mode": "custom_greeting",
"media_name": "my_voicemail_greeting"
}
}
'{
"data": {
"enabled": true,
"pin": "1234",
"greeting": {
"mode": "custom_greeting",
"media_name": "my_voicemail_greeting"
}
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
The ID of the phone number.
Body
Details to create
The pin used for voicemail
"1234"
Whether voicemail is enabled.
true
Controls the greeting a caller hears before leaving a voicemail. Set mode to default to play the standard system greeting, or to custom_greeting to play your own audio. When mode is custom_greeting, media_name is required and must reference an audio file already uploaded to your account through the Media Storage API.
Show child attributes
Show child attributes
Response
Successful response
Show child attributes
Show child attributes
{
"enabled": true,
"pin": "1234",
"greeting": {
"mode": "custom_greeting",
"media_name": "my_voicemail_greeting"
}
}
Was this page helpful?
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 '
{
"enabled": true,
"pin": "1234",
"greeting": {
"mode": "custom_greeting",
"media_name": "my_voicemail_greeting"
}
}
'{
"data": {
"enabled": true,
"pin": "1234",
"greeting": {
"mode": "custom_greeting",
"media_name": "my_voicemail_greeting"
}
}
}