API Resource: /media

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


Note: This topic discusses the /media service offered through the Phone.com API. Throughout the discussion, though, we will reference /greetings and /hold_music. These are aliases for our Telephony Toolkit settings for Greetings and Hold Music, and are part of the API /media service.

The Phone.com API /media service lets you personalize and manage the greetings (/greetings) and hold music (/hold_music) configured for your phone numbers.

Typically, someone calling your phone number might hear a greeting that offers call-routing options for the caller to select—for example, to press [1] to speak to someone in your Tech Support department. If the caller chooses to speak to Tech Support, they would be placed in the call queue for that department, and will hear hold music while waiting for your representative to answer the line. Should your support representative place the caller on hold during the conversation, the caller might hear hold music again.


Caller hears greeting and hold music while waiting in queue

What Can I Do with Greetings and Hold Music?

Greetings and hold music are simply recordings that you can add to your account, and later update or delete. However, they are quite different in purpose.

A greeting is an audio file that plays when a caller first connects to your phone number. You can use greetings to provide information, or to explain menu options and prompt callers to make a selection.

Hold Music is the music or recorded information that plays while callers are waiting in a call queue, or waiting while placed on hold during a call. You can use hold music to entertain callers while they are waiting, or provide information about new features or promotions.

Media Settings in the Telephony Toolkit

Before beginning, consider exactly how you will use media in your application. For example, if you want to offer callers the option to talk to your Sales department or leave a message, you will need to set up a greeting to play when your callers connect, a menu and call handling rules to route callers to the options in your greeting, a queue for your Sales separtment, and hold music to play while callers are on hold.

In most cases, you will find it easiest to set up your greetings and hold music using the Telephony Toolkit’s settings for Greetings. Using Greetings, you can upload a recorded message (AIFF, AU, MP3 or WAV) to your account or use our Text-to-Speech service, which lets you convert a text greeting to a recording. When you add a new greeting, you can select to allow the greeting to be used as hold music.

To add a new greeting, log into your Phone.com API Developer account, click Configure > Add a Greeting, and select options for the following settings:


Add Greeting Page

  • Nickname: Enter a name for the greeting that you will easily associate with your application.
  • Restricted to: Select All to use the greeting on all numbers in your account, or select the specific extension for the phone number to which you want to apply the greeting.
  • Allow for use as hold music: Select Yes to enable the greeting to be used as hold music or no to use it only as a greeting.
  • To add your greeting, select and complete one of the following options:
    • Text to Greeting: Enter a text-based message, select a voice to use, and click Add.
    • Record from Phone: Click Click to Record a Greeting and follow the prompts to record a greeting.
    • Upload New File: Select the file on your system to use as a greeting, and click Upload.
  • Notes: Add any details that you would like to remember about the greeting—for example, the information in the greeting, what the recording is used for, or the date uploaded.
  • Click Save Greeting.

You have configured a greeting for your application. For more information, see Managing Greetings and Hold Music.

Working with the /media API Resource

While setting up greetings and hold music is easier using Greetings in the Telephony Toolkit, in many cases you will need to access, add, update and delete media resources more dynamically using the /media API service.

A GET /media request lets you to list all of the media objects in your account, retrieve (GET) information about your greetings or hold music, and retrieve the actual raw data files. The service also allows you to update (PUT) media, letting you replace recordings and overwrite metadata related to media objects.

When a media object is created (POST), it is assigned an ID (UUID), which can then be used to specify that object in menus, queues and call handling rules. The /media service also lets you specify temporary media IDs that will expire and be removed from your account after a set time. Use the /media service when you want to manage media objects on the fly. For example, you could update the seasonal greetings used in all of your franchise locations’ after-hours phone directories, based on the time of year. That is, your application could automatically make a PUT call to the /greeting alias for each locations’ phone number, adding the updated greeting file.

For more information, see Managing Greetings and Hold Music.

POST /media

Use POST /media to add a media object to your account that can be used as a greeting or hold music. Note that the maximum size for media files or JSON objects included with a POST or PUT request to the Phone.com API is 20 MB.

Example

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

Authentication

This method requires authentication.

Request Body Fields and Example

Field Type Values Description
name String my_name Use a name (Nickname) for the greeting that you will easily associate with your media object.
extension (Optional) String ID Extension object resource_id
notes (Optional) String   Notes about the media object
type String ‘tts’, ‘file’ The type of the media object; either “file” or “tts” (text to speech).
tts_voice (Optional) String ‘allison’, ‘amy’, ‘belle’, ‘callie’, ‘callieq’, ‘dallas’, ‘damien’, ‘david’, ‘designerdave’, ‘diane’, ‘diesel’, ‘dog’, ‘duchess’, ‘duncan’, ‘emily’, ‘evilgenius’, ‘frank’, ‘french-fry’, ‘gregory’, ‘isabelle’, ‘jean-pierre’, ‘jerkface’, ‘katrin’, ‘kayla’, ‘kidaroo’, ‘lawrence’, ‘layo’, ‘linda’, ‘marta’, ‘matthias’, ‘miguel’, ‘millie’, ‘princess’, ‘ransomnote’, ‘robin’, ‘robot’, ‘shouty’, ‘shygirl’, ‘tamika’, ‘tophat’, ‘vittoria’, ‘vixen’, ‘vlad’, ‘walter’, ‘whispery’, ‘william’, ‘wiseguy’, ‘zach’ If ‘tts’ is specified for ‘type’ you can choose a voice for the audio output. The default voice is ‘allison.’ To preview the voices, log into your Phone.com API Developer account, and click Configure > Add Greeting, and select Text to Greeting. Type a message and use the Select a voice menu to test various voices.
tts_text (Optional) String   The text to be used for the text-to-speech greeting.
is_hold_music Boolean Y/N, y/n, t/f, true/false, 1/0 Determines whether the media object is a greeting or hold_music. Not required when using the aliases /greetings and /hold_music. The service will default to N or Y respectively.
is_temporary (Optional) Boolean Y/N, y/n, t/f, true/false, 1/0 Determines whether the media object is temporary or not. Temporary media objects are removed in 24 hours unless a different expiration date is supplied.
expiration_date (Optional) String Timestamp or ISO 8601 time string Determines the expiration date of a temporary media object.

Request Body Format Example

The example below shows how you can upload (POST) a text-to-speech media file to your account, setting it as the greeting for a specific extension. The greeting is created by our text-to-speech tool, using the text “This is a test message” and the Amy voice. It cannot be used as hold music because is_hold_music is set to false.


 {
    "name": "test",
    "extension": "e04c9e4a-762e-11e2-8054-aefb1020f2dc",
    "type": "tts",
    "tts_voice": "amy",
    "tts_text": "This is a test message.",
    "is_hold_music":"false"
 }

Success Response

HTTP Code: 200 OK


{
    "response": {
        "data": {
            "resource_id": "702e7f11-1580-11e3-94d9-8ca338592373"
        }
    }
}

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 409:

{
    "response": {
        "error": {
            "code": 30005,
            "detail": [
                "the name: test24, is in use for another recording."
            ],
            "info": "Invalid request. The resource is in use.",
            "url": "https://docs.phone.com/refguides/errorref/serviceerrors.html#error-code-30005"
        }
    }
}

Sample POST /media Request (PHP)

When uploading a media file, the Phone.com API requires that you send the file and metadata as a multipart/form-data request.

You can use a POST to /media to add a greeting or hold music to your account, but the is_hold_music field is required as follows:

  • POST to /hold_music does not require the is_hold_music field or it must be set to true.
  • POST to /greetings does not require the is_hold_music field or it must be set to false.

  <?php
  $sample_file = "sample.mp3";
  $url = "https://v1.api.phone.com/media/";

  $post_body['data'] = '{
    "name":"test",
    "extension":"e04c9e4a-762e-11e2-8054-aefb1020f2dc",
    "type": "file",
    "is_hold_music":"false"
  }';

  $post_body['file'] = "@$sample_file";

  $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_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 /media.


GET /media

Use GET /media to retrieve a list of media objects in your account. Note that, by default, you can retrieve a maximum of 20 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/media

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 media 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   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

Field Type Values Description
resource_id String UUID The resource id of the object.
create_date String   The creation date of the media object in ISO 8601 format.
create_date_epoch Integer   The creation date of the media object in unix time format.
duration Integer   The length of the media in seconds.
filename String   The original filename of the media file.
is_hold_music Boolean   Determines whether the media object is a greeting or hold_music. Not required when using the aliases /greetings and /hold_music. The service will default to N or Y respectively.
is_temporary Boolean   Determines whether the media object is temporary or not. Temporary media objects are removed in 24 hours unless a different expiration date is supplied.
name String   Name for the media object. This is a friendly name that you can use to identify the object.
notes String   Any details you want to note about the media object.
extension String   Extension resource_id
origin String   Media object type. Must be file or tts (text to speech).
tts_text String   The text to be used for the text-to-speech greeting.
tts_voice String   If tts is specified as the type, you can special a voice for audio output. The default voice is allison.
expiration_date String   The expiration date of a temporary media object.

Response Body Format Example

Example of the response body format for GET /greetings.


{
    "response": {
        "data": [
            {
                "resource_id": "9d1ee64b-f316-11e2-b57c-ac4ed37d8038",
                "create_date": "1374528920",
                "duration": "0",
                "filename": "",
                "is_hold_music":"false",
                "is_temporary": "true",
                "name": "voicemail_greeting1",
                "notes": "",
                "origin": "tts",
                "tts_text": "I'm not in, please leave a message.",
                "tts_voice": "amy"
            },
            {
                "resource_id": "b2efa380-f316-11e2-b57c-85218d89f6ad",
                "create_date": "1374528957",
                "duration": "0",
                "filename": "",
                "is_hold_music":"false",
                "is_temporary": "true",
                "name": "voicemail_greeting2",
                "notes": "",
                "origin": "tts",
                "tts_text": "I'm not in, please leave a message.",
                "tts_voice": "amy"
            },
            {
                "resource_id": "d301decd-f316-11e2-b57c-f201cc387158",
                "create_date": "1374529011",
                "duration": "0",
                "filename": "",
                "is_hold_music":"false",
                "is_temporary": "true",
                "name": "voicemail_greeting3",
                "notes": "",
                "origin": "tts",
                "tts_text": "I'm not in, please leave a message.",
                "tts_voice": "amy"
            },
            {
                "resource_id": "ff2c4a00-f316-11e2-b57c-bb4b36650bcd",
                "create_date": "1374529085",
                "duration": "0",
                "filename": "",
                "is_hold_music":"false",
                "is_temporary": "true",
                "name": "voicemail_greeting4",
                "notes": "",
                "origin": "tts",
                "tts_text": "I'm not in, please leave a message.",
                "tts_voice": "amy"
            },
            {
                "resource_id": "22f4a387-f317-11e2-b57c-c3989fe48e08",
                "create_date": "1374529145",
                "duration": "0",
                "filename": "",
                "is_hold_music":"false",
                "is_temporary": "true",
                "name": "voicemail_greeting5",
                "notes": "",
                "origin": "tts",
                "tts_text": "I'm not in, please leave a message.",
                "tts_voice": "amy"
            }
        ],
        "links": [
            {
                "next": "https://v1.api.phone.com/greetings?limit=5&offset=5&order_by=name&sort=desc"
            }
        ]
    }
}

Error Response

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

Sample GET /media Request (PHP)

Note that using GET on /media will return all media objects. A GET on /hold_music will return only hold-music media objects and a GET on /greetings will return only media objects that are not hold music.


<?php
$url = "https://v1.api.phone.com/GET/media/?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 /media.


DELETE /media

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

Example

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

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 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 /media Request (PHP)

Note that you must supply the delete_all argument to prevent you from deleting all your media objects by accident. Also, media objects being used by another object cannot be deleted.


<?php
$url = "https://v1.api.phone.com/media?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 /media.


GET /media/UUID

Use GET /media/UUID to retrieve a specific media object.

Example

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

Authentication

This method requires authentication.

Parameters

Parameter Type Description
media (Optional) String The media format you wish to download (ulaw, wav, mp3 supported)

Success Response

HTTP Code: 200 OK

Response Body Fields and Example

Field Type Values Description
resource_id String UUID The resource id of the object.
create_date String   The creation date of the media object.
duration Integer   The length of the media in seconds.
filename String   The original filename of the media file.
is_hold_music Boolean   Determines whether the media object is a greeting or hold_music. Not required when using the aliases /greetings and /hold_music. The service will default to N or Y respectively.
is_temporary Boolean   Determines whether the media object is temporary or not. Temporary media objects are removed in 24 hours unless a different expiration date is supplied.
name String   Name for the media object. This is a friendly name that you can use to identify the object.
notes String   Any details you want to note about the media object.
extension String   Extension resource_id
origin String   Media object type. Must be file or tts (text to speech).
tts_text String   The text to be used for the text-to-speech greeting.
tts_voice String   If tts is specified as the type, you can special a voice for audio output. The default voice is allison.
expiration_date String   The expiration date of a temporary media object.

Response Body Format Example


{
    "response": {
        "data": {
            "resource_id": "5aa19024-c3c8-11e2-8404-525400838e08",
            "create_date": "1223937223",
            "duration": "0",
            "filename": "",
            "is_hold_music": "true",
            "is_temporary": "true",
            "name": "Film Soundtrack",
            "notes": "",
            "origin": "file",
            "tts_text": "",
            "tts_voice": ""
        }
    }
}
            

Error Response

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

Sample GET /media/UUID Request (PHP)


<?php
$url = "https://v1.api.phone.com/GET/media/89fa9c15-ced1-11e2-8d4d-e9333b439310";

$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 /media.


PUT /media/UUID

Use PUT /media/UUID to update specific media objects.

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 media object using PUT to /media/UUID. However, you cannot change the name to a name used by another media object.

Be aware that the maximum size for media files or JSON objects included with a PUT or POST request to the Phone.com API is 20 MB.

Example

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

Authentication

This method requires authentication.

Request Body Fields and Example

Field Type Values Description
name String my_name The name (Nickname) for the media object.
extension (Optional) String ID Extension object resource_id
notes (Optional) String   Notes about the media object
type String ‘tts’, ‘file’ The type of the media object; either “file” or “tts” (text to speech).
tts_voice (Optional) String ‘allison’, ‘amy’, ‘belle’, ‘callie’, ‘callieq’, ‘dallas’, ‘damien’, ‘david’, ‘designerdave’, ‘diane’, ‘diesel’, ‘dog’, ‘duchess’, ‘duncan’, ‘emily’, ‘evilgenius’, ‘frank’, ‘french-fry’, ‘gregory’, ‘isabelle’, ‘jean-pierre’, ‘jerkface’, ‘katrin’, ‘kayla’, ‘kidaroo’, ‘lawrence’, ‘layo’, ‘linda’, ‘marta’, ‘matthias’, ‘miguel’, ‘millie’, ‘princess’, ‘ransomnote’, ‘robin’, ‘robot’, ‘shouty’, ‘shygirl’, ‘tamika’, ‘tophat’, ‘vittoria’, ‘vixen’, ‘vlad’, ‘walter’, ‘whispery’, ‘william’, ‘wiseguy’, ‘zach’ If ‘tts’ is specified for ‘type’ you can choose a voice for the audio output. The default voice is ‘allison.’ To preview the voices, log into your Phone.com API Developer account, and click Configure > Add Greeting, and select Text to Greeting. Type a message and use the Select a voice menu to test various voices.
tts_text (Optional) String   The text to be used for a text-to-speech greeting.
is_hold_music Boolean Y/N, y/n, t/f, true/false, 1/0 Determines whether the media object is a greeting or hold_music. Not required when using the aliases /greetings and /hold_music. The service will default to N or Y respectively.
**is_temporary* (Optional) Boolean Y/N, y/n, t/f, true/false, 1/0 Determines whether the media object is temporary or not. Temporary media objects are removed in 24 hours if a different expiration date is not supplied.
expiration_date (Optional) String Timestamp or ISO 8601 time string Determines the expiration date of a temporary media object.

Request Body Format Example


{
    "name": "test",
    "extension": "e04c9e4a-762e-11e2-8054-aefb1020f2dc",
    "type": "tts",
    "tts_voice": "amy",
    "tts_text": "This is a test message.",
    "is_hold_music":"false"
}

Success Response

HTTP Code: 200 OK


{
    "response": {
        "data": {
            "resource_id": "702e7f11-1580-11e3-94d9-8ca338592373"
        }
    }
}

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 /media Request (PHP)

When uploading a greeting, the Phone.com API requires that you send the file and metadata as a multipart/form-data request.

Constructing a PUT request can sometimes be more difficult than a POST, depending on the language you are using. Note the PHP example below.

You can use a PUT to /media/UUID to update a greeting or hold music, but the is_hold_music field is required as follows:

  • PUT to /hold_music does not require the is_hold_music field or it must be set to true.
  • PUT to /greetings does not require the is_hold_music field or it must be set to false.

<?php
$sample_file = "sample.mp3";
$url = "https://v1.api.phone.com/greetings/25ba781b-c949-11e2-ab14-fd6c8b81e89a";

$data = '{
  "name":"test",
  "extension":"e04c9e4a-762e-11e2-8054-aefb1020f2dc",
  "type": "file",
  "is_hold_music":"false"
}';

$filecont = file_get_contents($sample_file);

$separator = '-----------'.md5(microtime());

$requestBody = "--$separator\r\n"
       . "Content-Disposition: form-data; name=\"data\"\r\n"
       . "\r\n"
       . $data . "\r\n"
       . "--$separator\r\n"
             . "Content-Disposition: form-data; name=\"file\"; filename=\"$sample_file\"\r\n"
             . "Content-Type: application/octet-stream\r\n"
             . "\r\n"
             . "$filecont\r\n"
       . "--$separator--";

$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, $requestBody);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "Content-Type: multipart/form-data; boundary=$separator"
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$result = curl_exec($ch);

$info = curl_getinfo($ch);
var_dump($info);
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 /media.


DELETE /media/UUID

Use DELETE /media/UUID to delete a specific media object.

Example

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

Authentication

This method requires authentication.

Success Response

HTTP Code: 200 OK


{
    "response": {
        "results": "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": [
                "the recording is in use in a call route: 1a2f387e-1588-11e3-93c4-d6a916b242a9."
            ],
            "info": "Invalid request. The resource is in use.",
            "url": "https://docs.phone.com/refguides/errorref/serviceerrors.html#error-code-30005"
        }
    }
}

Sample DELETE /media/UUID Request (PHP)

A media object that is currently in use by another object cannot be deleted until that reference is removed.


<?php
$url = "https://v1.api.phone.com/media/25ba781b-c949-11e2-ab14-fd6c8b81e89a";

$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 /media.


Learn More: