API Resource: /menus

Want to get straight to work? Jump to available methods: POST /menus | GET /menus | DELETE /menus | GET /menus/UUID | PUT /menus/UUID | DELETE /menus/UUID


Menus present your callers with a list of options for routing their calls.

A menu greeting is often the first message a caller hears when reaching your phone number. Menus present callers with a list of call options—for example, “Press [1] for Sales, press [2] to leave a message, press [3] to troubleshoot ...”

Menus map phone digits to specific routes, which define how and where a call is routed. The digits available for menus are 0-9 and the hash (#) key. You can also set up an invalid-entry menu option and message, to be played if a caller presses a key not implemented in your menu.

Note that menu options work in conjunction with a greeting, on the one hand, and a set of call handling rules, on the other, as shown below.


Diagram showing how menus work with greetings and routes

In this case, selecting [1] will route a caller to your sales queue, [2] to voicemail and [3] to a troubleshooting application.

What Can I Do with Menus?

You can use menus to tell callers which key to press to reach a certain department or extension in your organization, or be routed to your application. You can also configure your menus to route calls made by a caller or another application to your API application—that is, the entire call can be processed programmatically using menus and call handling rules.

Imagine presenting customers calling your toll-free number after hours with three options: To talk to a support technician, to leave a message for a representative to call them in the morning, or to connect to an application that walks them through troubleshooting the issue they are experiencing. You can offer these support options easily using the Greetings, Menus and Call Handling Rules features in our Telephony Toolkit, or the /media, /menus and /routes services in our API.

Working with the /menus API Resource

In other cases, you may need to create menus more dynamically. Using the /menus API service, you can give your application’s users the ability to update their Phone.com menu options on the fly. You can also allow them to add or delete menus as needed.

This topic outlines the methods available for /menus, and shows you how to build effective requests for this service. Your app can create a menu using a POST to /menus. After that, you can update, list or delete menus using the PUT, GET and DELETE methods respectively.

Note: The maximum size for media files or JSON objects included with a POST or PUT request to the Phone.com API is 20 MB.

POST /menus

Use POST /menus to create a new menu. Be sure to use valid, existing media files and call handling rules when creating your GET /menus request.

Example

POST https://v1.api.phone.com/menus

Authentication

This method requires authentication.

Request Body Fields and Example

Field Type Values Description
name String Letters, numbers, spaces, dash, underscore. Up to 60 char. in length. Name for the menu. This is a friendly name that you can use to identify the menu.
allow_extension_dial Boolean Y/N, y/n, t/f, true/false, 1/0 Setting allows callers to enter an extension number at any time to bypass the menu and dial that extension
outgoing_recording String UUID resource_id of a valid recording object. UUID must be a valid resource_id of an existing object.
invalid_entry_recording String calling_number, called_number resource_id of a valid recording object
digits Array   An array of digits
digit String 0-9, and pound Key (digit) to map to a call handling rule
routes String UUID Valid, existing call handling rule

Request Body Format Example


{
   "name": "test",
   "allow_extension_dial": "false",
   "outgoing_recording": "40dc31d0-76ef-11e2-bcfd-0800200c9a66",
   "invalid_entry_recording": "f7c0ec0c-9016-11e2-97f5-525400838e08",
   "digits": [
        {
            "digit":"pound",
            "route":"6df07874-a797-11e2-bb5a-dc180921aee7"
       },
        {
            "digit":"0",
            "route":"ae761ef5-a6bd-11e2-b484-9048ce5be0cc"
       },
        {
            "digit":"1",
            "route":"8f0f5201-ac3b-11e2-8b76-de60857c4383"
       },
        {
            "digit":"2",
            "route":"d6e560bb-a6be-11e2-9080-f93165e3d18b"
       },
        {
            "digit":"3",
            "route":"d6e560bb-a6be-11e2-9080-f93165e3d18b"
       }
   ]
}

 

Success Response

HTTP Code: 200 OK


{
    "response": {
        "data": {
            "resource_id": "1b323609-14ba-11e3-8a95-c8d05d0d06fa"
        }
    }
}

Error Response

  • HTTP Code: 409 Conflict (Name in Use)
  • HTTP Code: 404 Not Found (Dependent resource not found)
  • HTTP Code: 500 Internal Server Error

For HTTP Code 404:

{
    "response": {
        "error": {
            "code": 30000,
            "info": "The system could not locate the resource you requested.",
            "url": "https://docs.phone.com/refguides/errorref/serviceerrors.html#error-code-30000"
        }
    }
}

Sample POST /menus Request (PHP)


  <?php
  $url = "https://v1.api.phone.com/menus";

  $post_body = <<<MENUDATA
  {
     "name": "test_14",
     "allow_extension_dial": "false",
     "outgoing_recording": "40dc31d0-76ef-11e2-bcfd-0800200c9a66",
     "invalid_entry_recording": "f7c0ec0c-9016-11e2-97f5-525400838e08",
     "digits": [
           {
                  "digit":"pound",
                  "route":"6df07874-a797-11e2-bb5a-dc180921aee7"
         },
           {
                  "digit":"0",
                  "route":"ae761ef5-a6bd-11e2-b484-9048ce5be0cc"
         },
           {
                  "digit":"1",
                  "route":"8f0f5201-ac3b-11e2-8b76-de60857c4383"
         },
           {
                  "digit":"2",
                  "route":"d6e560bb-a6be-11e2-9080-f93165e3d18b"
         },
           {
                  "digit":"3",
                  "route":"d6e560bb-a6be-11e2-9080-f93165e3d18b"
         }
           ]
    }
    MENUDATA;

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    // authentication
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($ch, CURLOPT_USERPWD, "username:password");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_body);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER,
             array('Content-Type:application/json',
                 'Content-Length: ' . strlen($post_body))
             );
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    $result = curl_exec($ch);

    $info = curl_getinfo($ch);
    curl_close($ch);

    if($info['http_code'] == 200 || $info['http_code'] == 201) {
             echo $result;
    } else {
             $error = array('http_code' => $info['http_code'], 'response' => $result);
             echo json_encode($error);
    }

    ?>

Back to Methods Available for /menus.


GET /menus

Use GET /menus to retrieve a list of existing menus in your account. Note that, by default, you can retrieve a maximum of 20 menu objects per request. You can increase the number of returned objects to a maximum of up to 50 by setting the limit parameter, and you can set offset to page through all available objects.

Example

GET https://v1.api.phone.com/menus

Authentication

This method requires authentication.

Parameters

Parameter Type Values Description
limit (Optional) Integer   Limits the result set to the value provided, to a maximum of 50 menu objects. If you do not specify a limit, GET requests have a default maximum of 20 objects returned.
offset (Optional) Integer   Determines the number of rows to skip before returning rows for the request
order_by (Optional) String   The field by which you want to order results
name (Optional) String   Allows you to retrieve objects by name.

Success Response

HTTP Code: 200 OK

Response Body Fields and Example

Parameter Type Description
resource_id String The resource id of the object.
name String A name for the menu. This is a friendly name that you can use to identify the menu
allow_extension_dial Boolean Setting allows callers to enter an extension number at any time to bypass the menu and dial that extension
outgoing_recording String resource_id of a valid recording object
invalid_entry_recording String resource_id of a valid recording object
digits Array Array of digits
digit String Key (digit) to map to a call handling rule
route String Valid and existing call handling rule

Response Body Format Example


{
    "response": {
        "data": [
            {
                "resource_id": "b4154ba7-eda9-11e2-93ee-e5b815bfe86c",
                "allow_extension_dial": "false",
                "digits": [
                    {
                        "digit": "0",
                        "route": {
                            "resource_id": "4a94e8bd-eda9-11e2-93ee-ff2277829dfa",
                            "url": "https://v1.api.phone.com/routes/4a94e8bd-eda9-11e2-93ee-ff2277829dfa"
                        }
                    },
                    {
                        "digit": "1",
                        "route": {
                            "resource_id": "4a94e8bd-eda9-11e2-93ee-ff2277829dfa",
                            "url": "https://v1.api.phone.com/routes/4a94e8bd-eda9-11e2-93ee-ff2277829dfa"
                        }
                    },
                    {
                        "digit": "2",
                        "route": {
                            "resource_id": "4a94e8bd-eda9-11e2-93ee-ff2277829dfa",
                            "url": "https://v1.api.phone.com/routes/4a94e8bd-eda9-11e2-93ee-ff2277829dfa"
                        }
                    },
                    {
                        "digit": "3",
                        "route": {
                            "resource_id": "4a94e8bd-eda9-11e2-93ee-ff2277829dfa",
                            "url": "https://v1.api.phone.com/routes/4a94e8bd-eda9-11e2-93ee-ff2277829dfa"
                        }
                    },
                    {
                        "digit": "#",
                        "route": {
                            "resource_id": "4a94e8bd-eda9-11e2-93ee-ff2277829dfa",
                            "url": "https://v1.api.phone.com/routes/4a94e8bd-eda9-11e2-93ee-ff2277829dfa"
                        }
                    }
                ],
                "invalid_entry_recording": "",
                "name": "Test_1",
                "outgoing_recording": ""
            },
            {
                "resource_id": "73c4252b-eda9-11e2-93ee-93fc516eecf6",
                "allow_extension_dial": "false",
                "digits": [
                    {
                        "digit": "0",
                        "route": {
                            "resource_id": "4a94e8bd-eda9-11e2-93ee-ff2277829dfa",
                            "url": "https://v1.api.phone.com/routes/4a94e8bd-eda9-11e2-93ee-ff2277829dfa"
                        }
                    },
                    {
                        "digit": "1",
                        "route": {
                            "resource_id": "4a94e8bd-eda9-11e2-93ee-ff2277829dfa",
                            "url": "https://v1.api.phone.com/routes/4a94e8bd-eda9-11e2-93ee-ff2277829dfa"
                        }
                    },
                    {
                        "digit": "2",
                        "route": {
                            "resource_id": "4a94e8bd-eda9-11e2-93ee-ff2277829dfa",
                            "url": "https://v1.api.phone.com/routes/4a94e8bd-eda9-11e2-93ee-ff2277829dfa"
                        }
                    },
                    {
                        "digit": "3",
                        "route": {
                            "resource_id": "4a94e8bd-eda9-11e2-93ee-ff2277829dfa",
                            "url": "https://v1.api.phone.com/routes/4a94e8bd-eda9-11e2-93ee-ff2277829dfa"
                        }
                    },
                    {
                        "digit": "#",
                        "route": {
                            "resource_id": "4a94e8bd-eda9-11e2-93ee-ff2277829dfa",
                            "url": "https://v1.api.phone.com/routes/4a94e8bd-eda9-11e2-93ee-ff2277829dfa"
                        }
                    }
                ],
                "invalid_entry_recording": "",
                "name": "Test_10",
                "outgoing_recording": ""
            },
            {
                "resource_id": "6fa47c76-eda9-11e2-93ee-92d4ad85c38d",
                "allow_extension_dial": "false",
                "digits": [
                    {
                        "digit": "0",
                        "route": {
                            "resource_id": "4a94e8bd-eda9-11e2-93ee-ff2277829dfa",
                            "url": "https://v1.api.phone.com/routes/4a94e8bd-eda9-11e2-93ee-ff2277829dfa"
                        }
                    },
                    {
                        "digit": "1",
                        "route": {
                            "resource_id": "4a94e8bd-eda9-11e2-93ee-ff2277829dfa",
                            "url": "https://v1.api.phone.com/routes/4a94e8bd-eda9-11e2-93ee-ff2277829dfa"
                        }
                    },
                    {
                        "digit": "2",
                        "route": {
                            "resource_id": "4a94e8bd-eda9-11e2-93ee-ff2277829dfa",
                            "url": "https://v1.api.phone.com/routes/4a94e8bd-eda9-11e2-93ee-ff2277829dfa"
                        }
                    },
                    {
                        "digit": "3",
                        "route": {
                            "resource_id": "4a94e8bd-eda9-11e2-93ee-ff2277829dfa",
                            "url": "https://v1.api.phone.com/routes/4a94e8bd-eda9-11e2-93ee-ff2277829dfa"
                        }
                    },
                    {
                        "digit": "#",
                        "route": {
                            "resource_id": "4a94e8bd-eda9-11e2-93ee-ff2277829dfa",
                            "url": "https://v1.api.phone.com/routes/4a94e8bd-eda9-11e2-93ee-ff2277829dfa"
                        }
                    }
                ],
                "invalid_entry_recording": "",
                "name": "Test_11",
                "outgoing_recording": ""
            },
            {
                "resource_id": "6afba988-eda9-11e2-93ee-dcfcd7f004eb",
                "allow_extension_dial": "false",
                "digits": [
                    {
                        "digit": "0",
                        "route": {
                            "resource_id": "4a94e8bd-eda9-11e2-93ee-ff2277829dfa",
                            "url": "https://v1.api.phone.com/routes/4a94e8bd-eda9-11e2-93ee-ff2277829dfa"
                        }
                    },
                    {
                        "digit": "1",
                        "route": {
                            "resource_id": "4a94e8bd-eda9-11e2-93ee-ff2277829dfa",
                            "url": "https://v1.api.phone.com/routes/4a94e8bd-eda9-11e2-93ee-ff2277829dfa"
                        }
                    },
                    {
                        "digit": "2",
                        "route": {
                            "resource_id": "4a94e8bd-eda9-11e2-93ee-ff2277829dfa",
                            "url": "https://v1.api.phone.com/routes/4a94e8bd-eda9-11e2-93ee-ff2277829dfa"
                        }
                    },
                    {
                        "digit": "3",
                        "route": {
                            "resource_id": "4a94e8bd-eda9-11e2-93ee-ff2277829dfa",
                            "url": "https://v1.api.phone.com/routes/4a94e8bd-eda9-11e2-93ee-ff2277829dfa"
                        }
                    },
                    {
                        "digit": "#",
                        "route": {
                            "resource_id": "4a94e8bd-eda9-11e2-93ee-ff2277829dfa",
                            "url": "https://v1.api.phone.com/routes/4a94e8bd-eda9-11e2-93ee-ff2277829dfa"
                        }
                    }
                ],
                "invalid_entry_recording": "",
                "name": "Test_12",
                "outgoing_recording": ""
            },
            {
                "resource_id": "aff69d90-eda9-11e2-93ee-ede3ad44c021",
                "allow_extension_dial": "false",
                "digits": [
                    {
                        "digit": "0",
                        "route": {
                            "resource_id": "4a94e8bd-eda9-11e2-93ee-ff2277829dfa",
                            "url": "https://v1.api.phone.com/routes/4a94e8bd-eda9-11e2-93ee-ff2277829dfa"
                        }
                    },
                    {
                        "digit": "1",
                        "route": {
                            "resource_id": "4a94e8bd-eda9-11e2-93ee-ff2277829dfa",
                            "url": "https://v1.api.phone.com/routes/4a94e8bd-eda9-11e2-93ee-ff2277829dfa"
                        }
                    },
                    {
                        "digit": "2",
                        "route": {
                            "resource_id": "4a94e8bd-eda9-11e2-93ee-ff2277829dfa",
                            "url": "https://v1.api.phone.com/routes/4a94e8bd-eda9-11e2-93ee-ff2277829dfa"
                        }
                    },
                    {
                        "digit": "3",
                        "route": {
                            "resource_id": "4a94e8bd-eda9-11e2-93ee-ff2277829dfa",
                            "url": "https://v1.api.phone.com/routes/4a94e8bd-eda9-11e2-93ee-ff2277829dfa"
                        }
                    },
                    {
                        "digit": "#",
                        "route": {
                            "resource_id": "4a94e8bd-eda9-11e2-93ee-ff2277829dfa",
                            "url": "https://v1.api.phone.com/routes/4a94e8bd-eda9-11e2-93ee-ff2277829dfa"
                        }
                    }
                ],
                "invalid_entry_recording": "",
                "name": "Test_2",
                "outgoing_recording": ""
            }
        ],
        "links": [
            {
                "next": "https://v1.api.phone.com/menus?limit=5&offset=5&order_by=name"
            }
        ]
    }
}

  

Error Response

  • HTTP Code: 404 Not Found (Dependent resource not found)

Sample GET /menus Request (PHP)


<?php
$url = "https://v1.api.phone.com/menus/?limit=5&offset=0";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
// authentication
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "username:password");

curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$result = curl_exec($ch);

$info = curl_getinfo($ch);
curl_close($ch);

if($info['http_code'] == 200) {
        echo $result;
} else {
        $error = array('http_code' => $info['http_code'], 'response' => $result);
        echo json_encode($error);
}
?>

Back to Methods Available for /menus.


DELETE /menus

Use DELETE /menus to remove all menus in your account. Note that you must include the delete_all argument to prevent you from deleting all your menus by accident. Also, menus being used by another object cannot be deleted.

Example

DELETE https://v1.api.phone.com/menus?delete_all=1

Authentication

This method requires authentication.

Parameters

Parameter Type Values Description
delete_all Boolean 0, 1 Set to 1 to complete the operation

Success Response

HTTP Code: 200 OK


{
 "response" : {
     "data" : "1"
   }
}

Error Response

  • HTTP Code: 400 Invalid Request
  • HTTP Code: 404 Not Found (Dependent resource not found)
  • HTTP Code: 409 Conflict (Name in Use)

For HTTP Code 400

{
    "response": {
        "error": {
            "code": 30007,
            "info": "You cannot delete all without the delete_all argument.",
            "url": "https://docs.phone.com/refguides/errorref/serviceerrors.html#error-code-30007"
        }
    }
}


Sample DELETE /menus Request (PHP)


 <?php
 $url = "https://v1.api.phone.com/menus?delete_all=1";

 $ch = curl_init();
 curl_setopt($ch, CURLOPT_URL, $url);
 // authentication
 curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
 curl_setopt($ch, CURLOPT_USERPWD, "username:password");

 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
 curl_setopt($ch, CURLOPT_HEADER, true);
 curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

 $result = curl_exec($ch);

 $info = curl_getinfo($ch);
 curl_close($ch);

 if($info['http_code'] == 200) {
         echo $result;
 } else {
         $error = array('http_code' => $info['http_code'], 'response' => $result);
         echo json_encode($error);
 }
 ?>


Back to Methods Available for /menus.


GET /menus/UUID

Use GET /menus/UUID to retrieve a single menu object.

Example

GET https://v1.api.phone.com/menus/UUID

Authentication

This method requires authentication.

Success Response

HTTP Code: 200 OK

Response Body Fields and Example

Parameter Type Description
resource_id String The resource id of the object.
name String Name for the menu. This is a friendly name that you can use to identify the menu
allow_extension dial Boolean Setting allows callers to enter an extension at any time to bypass the menu and dial that extension
outgoing_recording String resource_id of a valid recording object
invalid_entry_recording String resource_id of a valid recording object
digits Array Array of digits
digit String Key (digit) to map to a call handling rule
route String Valid, existing call handling rule

Response Body Format Example


{
  "response" : {
    "data" : [
      {
        "resource_id" : "df44bf19-a629-11e2-af6b-e962ab480915",
        "outgoing_recording" : "40dc31d0-76ef-11e2-bcfd-0800200c9a66",
        "allow_extension_dial" : "false",
        "name" : "Test_11",
        "invalid_entry_recording" : "f7c0ec0c-9016-11e2-97f5-525400838e08",
        "digits" : [
          {
             "digit" : "0",
             "route" : "8c9235e8-a629-11e2-af6b-b95688288ca8"
          },
           {
             "digit" : "1",
             "route" : "8c9235e8-a629-11e2-af6b-b95688288ca8"
          },
           {
             "digit" : "2",
             "route" : "8c9235e8-a629-11e2-af6b-b95688288ca8"
          },
           {
             "digit" : "3",
             "route" : "8c9235e8-a629-11e2-af6b-b95688288ca8"
          },
           {
             "digit" : "*",
             "route" : "8c9235e8-a629-11e2-af6b-b95688288ca8"
          }
        ]
    }
}


Error Response

  • HTTP Code: 404 Not Found (Dependent resource not found)

Sample GET /menus/UUID Request (PHP)


<?php
$url = "https://v1.api.phone.com/menus/df44bf19-a629-11e2-af6b-e962ab480915";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
// authentication
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "username:password");

curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$result = curl_exec($ch);

$info = curl_getinfo($ch);
curl_close($ch);

if($info['http_code'] == 200) {
        echo $result;
} else {
        $error = array('http_code' => $info['http_code'], 'response' => $result);
        echo json_encode($error);
}
?>


Back to Methods Available for /menus.


PUT /menus/UUID

Use PUT /menus/UUID to update a specific menu object with new data.

Important:

Note that a PUT is not a PATCH. You need to send the complete object in the HTTP request body in order to update it. Also, you can change the name of a menu using PUT to /menus, but you cannot change the name to a name used by another menu.

Example

PUT https://v1.api.phone.com/menus/UUID

Authentication

This method requires authentication.

Request Body Fields and Example

Field Type Values Description
name String Letters, numbers, spaces, dash, underscore. Up to 60 char. in length. Name for the menu. This is a friendly name that you can use to identify the menu.
allow_extension_dial Boolean Y/N, y/n, t/f, true/false, 1/0 This setting allows callers to enter in an extension number at anytime to bypass the menu and dial that extension.
outgoing_recording String UUID resource_id of a valid recording object. UUID must be a valid resource_id of an existing object.
invalid_entry_recording String UUID resource_id of a valid recording object
digits Array   Array of digits
digit String 0-9, and pound Key (digit) to map to a call handling rule
route String UUID Valid, existing call handling rule

Request Body Format Example


{
   "name": "test",
   "allow_extension_dial": "false",
   "outgoing_recording": "40dc31d0-76ef-11e2-bcfd-0800200c9a66",
   "invalid_entry_recording": "f7c0ec0c-9016-11e2-97f5-525400838e08",
   "digits": [
        {
                "digit":"pound",
                "route":"6df07874-a797-11e2-bb5a-dc180921aee7"
       },
        {
                "digit":"0",
                "route":"ae761ef5-a6bd-11e2-b484-9048ce5be0cc"
       },
        {
                "digit":"1",
                "route":"8f0f5201-ac3b-11e2-8b76-de60857c4383"
       },
        {
                "digit":"2",
                "route":"d6e560bb-a6be-11e2-9080-f93165e3d18b"
       },
        {
                "digit":"3",
                "route":"d6e560bb-a6be-11e2-9080-f93165e3d18b"
       }
        ]
}

Success Response

HTTP Code: 200 OK


{
    "response": {
        "data": {
            "resource_id": "415fd46a-14c2-11e3-97a6-cba068469828"
        }
    }
}

Error Response

  • HTTP Code: 404 Not Found (Dependent resource not found)
  • HTTP Code: 409 Conflict (Name in Use)
  • HTTP Code: 500 Internal Server Error

For HTTP Code 404

{
    "response": {
        "error": {
            "code": 30000,
            "info": "The system could not locate the resource you requested.",
            "url": "https://docs.phone.com/refguides/errorref/serviceerrors.html#error-code-30000"
        }
    }
}

Sample PUT /menus Request (PHP)


<?php
$url = "https://v1.api.phone.com/menus/5c16ed38-ad21-11e2-b67b-a1bd4e9063de";

$put_body = <<<MENUDATA
{
  "name": "test",
  "allow_extension_dial": "false",
  "outgoing_recording": "40dc31d0-76ef-11e2-bcfd-0800200c9a66",
  "invalid_entry_recording": "f7c0ec0c-9016-11e2-97f5-525400838e08",
  "digits": [
        {
               "digit":"pound",
               "route":"6df07874-a797-11e2-bb5a-dc180921aee7"
      },
        {
               "digit":"0",
               "route":"ae761ef5-a6bd-11e2-b484-9048ce5be0cc"
      },
        {
               "digit":"1",
               "route":"8f0f5201-ac3b-11e2-8b76-de60857c4383"
      },
        {
               "digit":"2",
               "route":"d6e560bb-a6be-11e2-9080-f93165e3d18b"
      },
        {
               "digit":"3",
               "route":"d6e560bb-a6be-11e2-9080-f93165e3d18b"
      }
        ]
}
MENUDATA;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
// authentication
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "username:password");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, $put_body);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER,
       array('Content-Type:application/json',
          'Content-Length: ' . strlen($put_body))
       );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$result = curl_exec($ch);

$info = curl_getinfo($ch);
curl_close($ch);

if($info['http_code'] == 200 || $info['http_code'] == 201) {
        echo $result;
} else {
        $error = array('http_code' => $info['http_code'], 'response' => $result);
        echo json_encode($error);
}

?>

Back to Methods Available for /menus.


DELETE /menus/UUID

Use DELETE /menus/UUID to delete a specific menu object.

Example

DELETE https://v1.api.phone.com/menus/UUID

Authentication

This method requires authentication.

Success Response

HTTP Code: 200 OK


{
    "response": {
        "data": "1"
    }
}

Error Response

  • HTTP Code: 400 Invalid Request
  • HTTP Code: 404 Not Found (Dependent resource not found)
  • HTTP Code: 409 Conflict (Name in Use)

For HTTP Code 409

{
    "response": {
        "error": {
            "code": 30005,
            "detail_0": "resource: 7c90a683-14c6-11e3-ac5d-a21bb51951d7, is in use and cannot be deleted.",
            "info": "Invalid request. The resource is in use.",
            "url": "https://docs.phone.com/refguides/errorref/serviceerrors.html#error-code-30005"
        }
    }
}

Sample DELETE /menus/UUID Request (PHP)

Note that a menu currently in use in another object, such as a call handling rule, cannot be deleted.


<?php
$url = "https://v1.api.phone.com/menus/5c16ed38-ad21-11e2-b67b-a1bd4e9063de";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
// authentication
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "username:password");

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$result = curl_exec($ch);

$info = curl_getinfo($ch);
curl_close($ch);

if($info['http_code'] == 200) {
  echo $result;
} else {
  $error = array('http_code' => $info['http_code'], 'response' => $result);
  echo json_encode($error);
}
?>

Back to Methods Available for /menus.


Learn More: