> ## Documentation Index
> Fetch the complete documentation index at: https://developers.telnyx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create voicemail

> Create voicemail settings for a phone number



## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/numbers-identity/voicemail.yml post /phone_numbers/{phone_number_id}/voicemail
openapi: 3.1.0
info:
  title: Telnyx Voicemail API
  version: 2.0.0
  description: API for Voicemail.
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
security:
  - bearerAuth: []
paths:
  /phone_numbers/{phone_number_id}/voicemail:
    parameters:
      - name: phone_number_id
        in: path
        description: The ID of the phone number.
        example: '123455678900'
        required: true
        schema:
          type: string
    post:
      tags:
        - Voicemail
      summary: Create voicemail
      description: Create voicemail settings for a phone number
      operationId: CreateVoicemail
      requestBody:
        description: Details to create
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VoicemailRequest'
      responses:
        '200':
          $ref: '#/components/responses/VoicemailResponse'
        '401':
          description: Unauthorized
        '404':
          description: Resource not found
        '422':
          description: Bad request
      x-codeSamples:
        - lang: JavaScript
          source: >-
            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);
        - lang: Python
          source: |-
            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)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/team-telnyx/telnyx-go\"\n\t\"github.com/team-telnyx/telnyx-go/option\"\n)\n\nfunc main() {\n\tclient := telnyx.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tvoicemail, err := client.PhoneNumbers.Voicemail.New(\n\t\tcontext.TODO(),\n\t\t\"123455678900\",\n\t\ttelnyx.PhoneNumberVoicemailNewParams{\n\t\t\tVoicemailRequest: telnyx.VoicemailRequestParam{},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", voicemail.Data)\n}\n"
        - lang: Java
          source: >-
            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);
                }
            }
        - lang: Ruby
          source: |-
            require "telnyx"

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

            voicemail = telnyx.phone_numbers.voicemail.create("123455678900")

            puts(voicemail)
        - lang: CLI
          source: |-
            telnyx phone-numbers:voicemail create \
              --api-key 'My API Key' \
              --phone-number-id 123455678900
components:
  schemas:
    VoicemailRequest:
      type: object
      properties:
        pin:
          type: string
          example: '1234'
          description: The pin used for voicemail
        enabled:
          type: boolean
          example: true
          description: Whether voicemail is enabled.
    VoicemailPrefResponse:
      type: object
      example:
        enabled: true
        pin: '1234'
      properties:
        enabled:
          type: boolean
          example: true
          description: Whether voicemail is enabled.
        pin:
          type: string
          example: '1234'
          description: The pin used for the voicemail.
  responses:
    VoicemailResponse:
      description: Successful response
      content:
        application/json:
          schema:
            type: object
            properties:
              data:
                $ref: '#/components/schemas/VoicemailPrefResponse'
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````