{"metadata":{"image":[],"title":"","description":""},"api":{"url":"/accounts/:account_id/media","auth":"required","examples":{"codes":[{"code":"## Example 1:  Below is an exmaple of creating a media with TTS.  \n##      Note:  Use Content-Type = application/json in headers.\n\n<?php\n\nrequire 'vendor/autoload.php';\nuse GuzzleHttp\\Client;\n\n//----------------------------------\n//--- Create a media for account ---\n//----------------------------------\n$client = new \\GuzzleHttp\\Client([\n    'base_uri' => 'https://api.phone.com/v4/',\n    'headers' => ['Authorization' => 'Bearer 12345',\n                  'Content-Type' => 'application/json'\n                 ]\n]);\n\ntry {\n    $response = $client->post(\"accounts/349303/media\", ['json' => [\n        'name' => 'My Text To Speech Media',\n        'origin' => 'tts',\n        'tts_text' => 'Thanks for calling, press 1 for Diane, 2 for David',\n        'tts_voice' => 'diane'\n    ]]);\n\n    echo $response->getBody();\n\n} catch (\\GuzzleHttp\\Exception\\ClientException $e) {\n    echo $e->getResponse()->getBody()->getContents();\n}","language":"php","name":"Text-to-Speech (TTS)"},{"code":"## Example 2:  Below is an exmaple of uploading a local media file.  \n##      Note:  Use Content-Type = multipart/form-data in headers.\n\n<?php\n\nrequire 'vendor/autoload.php';\nuse GuzzleHttp\\Client;\n\n//-----------------------------------\n//--- Create a device for account ---\n//-----------------------------------\n$client = new \\GuzzleHttp\\Client;\n\ntry {\n\n$response = $client->request('POST', 'https://api.phone.com/v4/accounts/349003/media', [\n    'headers' => [\n        'authorization' => 'Bearer zPzOJy6K1z67gsdfdfeOszMfCxBcTLl5zTV5AUm'\n    ],\n    'multipart' => [\n        [\n            'name' => 'json',\n            'contents' => '{ \"name\" : \"Main Menu Hold Music\", \"origin\" : \"file\", \"type\" : \"hold_music\" }'\n        ],\n        [\n            'name' => 'file',\n            'contents' => fopen(__DIR__ . '/test.mp3', 'r')\n        ]\n    ]\n]);\n    echo $response->getBody();\n} catch (\\Exception $e){\n    echo $e->getMessage();\n}","language":"php","name":"Upload a Local File (Guzzle)"},{"name":"Upload a local file (cURL)","language":"php","code":"<?php\n\n$curl = curl_init();\n$cfile = curl_file_create('myMusic.mp3');\n\n$data = array();\n$data['json'] = '{\"origin\" : \"file\", \"name\": \"Uploaded media name\", \"type\": \"hold_music\"}';\n$data['file'] = $cfile;\n\ncurl_setopt_array($curl, array(\n    CURLOPT_URL => \"https://api.phone.com/v4/accounts/337171/media\",\n    CURLOPT_RETURNTRANSFER => true,\n    CURLOPT_ENCODING => \"\",\n    CURLOPT_MAXREDIRS => 10,\n    CURLOPT_TIMEOUT => 30,\n    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n    CURLOPT_CUSTOMREQUEST => \"POST\",\n    CURLOPT_POSTFIELDS => $data,\n    CURLOPT_HTTPHEADER => array(\n        \"authorization: Bearer ThisIsYourAPItoken\",\n        \"cache-control: no-cache\",\n        \"content-type: multipart/form-data\"\n    ),\n));\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n    echo \"cURL Error #:\" . $err;\n} else {\n    echo $response;\n}\n"}]},"method":"post","params":[{"name":"account_id","type":"int","default":"","desc":"Account ID","required":false,"in":"path","ref":"","_id":"56f9c415338fbb2000ec3711"},{"name":"name","type":"string","default":"","desc":"Name of media","required":true,"in":"body","ref":"","_id":"579be149f4ad7b190094b6cd"},{"name":"origin","type":"string","default":"","desc":"'tts', 'file'","required":true,"in":"body","ref":"","_id":"579be1c7f4ad7b190094b6cf"},{"name":"type","type":"string","default":"","desc":"'hold_music', 'greeting'","required":false,"in":"body","ref":"","_id":"579be1c7f4ad7b190094b6d0"},{"name":"tts_voice","type":"string","default":"","desc":"\"Mads / Danish\", \"Naja / Danish\", \"Lotte / Dutch\", \"Ruben / Dutch\", \"Nicole / English (Australia)\", \"Russell / English (Australia)\", \"Amy / English (Great Britain)\", \"Brian / English (Great Britain)\", \"Emma / English (Great Britain)\", \"Raveena / English (India)\", \"Ivy / English (US)\", \"Joanna / English (US)\", \"Joey / English (US)\", \"Justin / English (US)\", \"Kendra / English (US)\", \"Kimberly / English (US)\", \"Salli / English (US)\", \"Geraint / English (Wales)\", \"Celine / French\", \"Mathieu / French\", \"Chantal / French (Canada)\", \"Hans / German\", \"Marlene / German\", \"Vicki / German\", \"Dora / Icelandic\", \"Karl / Icelandic\", \"Carla / Italian\", \"Giorgio / Italian\", \"Mizuki / Liv\", \"Liv / Norwegian\", \"Jacek / Polish\", \"Jan / Polish\", \"Ewa / Polish\", \"Maja / Polish\", \"Ricardo / Portuguese\", \"Vitoria / Portuguese\", \"Cristiano / Portuguese (Brazil)\", \"Ines / Portuguese (Brazil)\", \"Carmen / Romanian\", \"Maxim / Russian\", \"Tatyana / Russian\", \"Conchita / Spanish\", \"Enrique / Spanish\", \"Miguel / Spanish (Latin America)\", \"Penelope / Spanish (Latin America)\", \"Astrid / Swedish\", \"Filiz / Turkish\", \"Gwyneth / Welsh\"","required":false,"in":"body","ref":"","_id":"579be1c7f4ad7b190094b6ce"},{"name":"tts_text","type":"string","default":"","desc":"Text used for text-to-speech conversion, maximum 800 characters","required":false,"in":"body","ref":"","_id":"579be1d11ea3140e0083b65f"},{"name":"is_temporary","type":"string","default":"N","desc":"'Y', 'N'.  Media file is temporary, will be deleted after a specified period.","required":false,"in":"body","ref":"","_id":"579be1ed5623be220083266f"},{"name":"expiration_date","type":"int","default":"0","desc":"If is_temporary is 'Y', media will be deleted after the specified time in seconds","required":false,"in":"body","ref":"","_id":"579be1f75623be2200832670"},{"name":"duration","type":"int","default":"","desc":"Length of media in seconds","required":false,"in":"body","ref":"","_id":"58a4b2cd89e3232300e5c445"},{"name":"notes","type":"string","default":"","desc":"Notes about the media object","required":false,"in":"body","ref":"","_id":"58a4b2cd89e3232300e5c444"},{"name":"randomized","type":"string","default":"N","desc":"'Y', 'N'.  Start playing the media file in random location, instead of from the beginning","required":false,"in":"body","ref":"","_id":"58a4b2cd89e3232300e5c443"}],"results":{"codes":[{"code":"{\n    \"id\": 623472,\n    \"voip_id\": 349303,\n    \"name\": \"My text-to-speech media with update\",\n    \"type\": \"greeting\",\n    \"created_at\": \"2017-03-17T06:38:26-07:00\",\n    \"created_at_epoch\": 1489757906,\n    \"duration\": null,\n    \"notes\": null,\n    \"expires_at\": null,\n    \"origin\": \"tts\",\n    \"is_temporary\": false,\n    \"randomized\": \"N\",\n    \"tts\": {\n        \"voice\": null,\n        \"text\": \"Hello, listpost media via TTS 2345\"\n    },\n    \"extension\": {\n        \"id\": 0,\n        \"voip_id\": 0,\n        \"name\": \"\",\n        \"extension\": 0\n    },\n}","language":"json","status":201,"name":"Result from TTS"},{"code":"{\n    \"id\": 629061,\n    \"voip_id\": 349034,\n    \"name\": \"Main Menu Hold Music\",\n    \"type\": \"hold_music\",\n    \"created_at\": \"2017-03-17T07:32:31-07:00\",\n    \"created_at_epoch\": 1489761151,\n    \"duration\": null,\n    \"notes\": null,\n    \"expires_at\": null,\n    \"origin\": \"file\",\n    \"is_temporary\": false,\n    \"randomized\": \"N\",\n    \"filename\": \"test.mp3\",\n}","status":201,"name":"Result from File Upload (Guzzle)","language":"json"},{"status":201,"name":"Result from File Upload (cURL)","language":"json","code":"{\n    \"id\": 661411,\n    \"voip_id\": 337171,\n    \"name\": \"Uploaded media name\",\n    \"type\": \"hold_music\",\n    \"created_at\": \"2017-08-27T10:19:29-07:00\",\n    \"created_at_epoch\": 1503854369,\n    \"duration\": null,\n    \"notes\": null,\n    \"expires_at\": null,\n    \"origin\": \"file\",\n    \"is_temporary\": false,\n    \"randomized\": \"N\",\n    \"filename\": \"myMusic.mp3\"\n}"}]},"settings":""},"next":{"description":"","pages":[]},"title":"Create Media","type":"endpoint","slug":"create-account-media","excerpt":"Add a media object to your account that can be used as a greeting or hold music.  Users may create a media by using the built-in Text-to-speech (TTS) facility or upload a file of their choice. (Note: The maximum size for media files or JSON objects included with a POST or PUT request is 10 MB)\n\nSee [Account Media](doc:account-media) for more info on the properties.\n\nNote: This API is for users with Account Owner scope access token. Users with Extension User scope token should invoke the Extension level Create Media API with the following definition:\n\nPOST https://api.phone.com/v4/accounts/:account_id/extensions/:extension_id/media","body":"The above examples show how to create a media file.  Example 1 uses TTS as greeting while Example 2 uploads a media file as Hold Music","updates":[],"order":3,"isReference":true,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"58ac63fa4ca6173b0026a336","githubsync":"","project":"55c8cff571d7580d0063a5e5","version":{"version":"4","version_clean":"4.0.0","codename":"","is_stable":true,"is_beta":true,"is_hidden":false,"is_deprecated":false,"categories":["57624356653c2d2200fec79d","57624356653c2d2200fec79e","57624356653c2d2200fec79f","57624356653c2d2200fec7a0","57624356653c2d2200fec7a1","57624356653c2d2200fec7a2","57624356653c2d2200fec7a3","57624356653c2d2200fec7a4","57624356653c2d2200fec7a5","57624356653c2d2200fec7a6","57624356653c2d2200fec7a7","57624356653c2d2200fec7a8","57624356653c2d2200fec7a9","57624356653c2d2200fec7aa","5779ca1b99b40b0e005abb3a","5779d198aea88b0e00f63277","5797d3ab17ced017003c4be4","57ac170ef1cdae0e0053cdfc","57dbfc723ed3450e00dc9e6d","5804d12d16161c0f0077df9b","5841064b652e5b0f0015a7c8","588b5e5f2966b2230009cbf9","58a68ebf3239fa0f00857619","58c23c8b4922930f0050ac91","58fd1460809fc30f00f2ee07","5934eaf5328680002d77de6a","594bf91601cfe6000f40f4c5","595c4ed696b447001ba0cf6d","596524495cee50001575f5be","5970d4f1313162004dd303b5","59780fac24dbd1001a1fa057","59a8cfd3ead78a002d63cafe","59e0323d93da1f001c9ec170","5b0c16f2be9fcb0003e28222","5ba8fd1a4c8c220003a08f0f","5ede526e75bc22005d0adecc"],"_id":"57624356653c2d2200fec79c","createdAt":"2016-06-16T06:12:38.244Z","releaseDate":"2016-06-16T06:12:38.244Z","__v":23,"project":"55c8cff571d7580d0063a5e5"},"__v":5,"category":{"sync":{"isSync":false,"url":""},"pages":[],"title":"Account Media","slug":"account-media","order":17,"from_sync":false,"reference":true,"_id":"57624356653c2d2200fec7a4","__v":0,"version":"57624356653c2d2200fec79c","project":"55c8cff571d7580d0063a5e5","createdAt":"2016-05-16T21:10:19.740Z"},"createdAt":"2017-02-21T15:59:54.813Z","user":"56f99ab84d2b4f3400edb636","parentDoc":null}

postCreate Media

Add a media object to your account that can be used as a greeting or hold music. Users may create a media by using the built-in Text-to-speech (TTS) facility or upload a file of their choice. (Note: The maximum size for media files or JSON objects included with a POST or PUT request is 10 MB) See [Account Media](doc:account-media) for more info on the properties. Note: This API is for users with Account Owner scope access token. Users with Extension User scope token should invoke the Extension level Create Media API with the following definition: POST https://api.phone.com/v4/accounts/:account_id/extensions/:extension_id/media

Definition

{{ api_url }}{{ page_api_url }}

Parameters

Path Params

account_id:
integer
Account ID

Body Params

name:
required
string
Name of media
origin:
required
string
'tts', 'file'
type:
string
'hold_music', 'greeting'
tts_voice:
string
"Mads / Danish", "Naja / Danish", "Lotte / Dutch", "Ruben / Dutch", "Nicole / English (Australia)", "Russell / English (Australia)", "Amy / English (Great Britain)", "Brian / English (Great Britain)", "Emma / English (Great Britain)", "Raveena / English (India)", "Ivy / English (US)", "Joanna / English (US)", "Joey / English (US)", "Justin / English (US)", "Kendra / English (US)", "Kimberly / English (US)", "Salli / English (US)", "Geraint / English (Wales)", "Celine / French", "Mathieu / French", "Chantal / French (Canada)", "Hans / German", "Marlene / German", "Vicki / German", "Dora / Icelandic", "Karl / Icelandic", "Carla / Italian", "Giorgio / Italian", "Mizuki / Liv", "Liv / Norwegian", "Jacek / Polish", "Jan / Polish", "Ewa / Polish", "Maja / Polish", "Ricardo / Portuguese", "Vitoria / Portuguese", "Cristiano / Portuguese (Brazil)", "Ines / Portuguese (Brazil)", "Carmen / Romanian", "Maxim / Russian", "Tatyana / Russian", "Conchita / Spanish", "Enrique / Spanish", "Miguel / Spanish (Latin America)", "Penelope / Spanish (Latin America)", "Astrid / Swedish", "Filiz / Turkish", "Gwyneth / Welsh"
tts_text:
string
Text used for text-to-speech conversion, maximum 800 characters
is_temporary:
stringN
'Y', 'N'. Media file is temporary, will be deleted after a specified period.
expiration_date:
integer0
If is_temporary is 'Y', media will be deleted after the specified time in seconds
duration:
integer
Length of media in seconds
notes:
string
Notes about the media object
randomized:
stringN
'Y', 'N'. Start playing the media file in random location, instead of from the beginning

Examples


Result Format


Documentation

The above examples show how to create a media file. Example 1 uses TTS as greeting while Example 2 uploads a media file as Hold Music

User Information

Try It Out

post
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}