{"metadata":{"image":[],"title":"","description":""},"api":{"url":"/accounts/:account_id/media/:media_id","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->put(\"accounts/349303/media/623472\", ['json' => [\n        'name' => 'My Text To Speech Media with update',\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 updating 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('PUT', 'https://api.phone.com/v4/accounts/349303/media/624526', [\n    'headers' => [\n        'authorization' => 'Bearer zPzOJy6K1zdfdfaEnaaaaaCxBcTLl5zTV5AUm'\n    ],\n    'multipart' => [\n        [\n            'name' => 'json',\n            'contents' => '{ \"name\" : \"Main Menu Hold Music Updated\", \"origin\" : \"file\", \"type\" : \"hold_music\" }'\n        ],\n        [\n            'name' => 'file',\n            'contents' => fopen(__DIR__ . '/test2.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"}]},"method":"put","params":[{"name":"account_id","type":"int","default":"","desc":"Account ID","required":true,"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":"'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', 'shouty', 'shygirl', 'tamika', 'tophat', 'vittoria', 'vixen', 'vlad', 'walter', 'whispery', 'william', 'wiseguy', 'zach'","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"},{"name":"media_id","type":"int","default":"","desc":"Media ID","required":true,"in":"path","ref":"","_id":"58cbf64331c89a0f00960e4e"}],"results":{"codes":[{"name":"Result from TTS","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\": \"Thanks for calling, press 1 for Diane, 2 for David\"\n    },\n    \"extension\": {\n        \"id\": 0,\n        \"voip_id\": 0,\n        \"name\": \"\",\n        \"extension\": 0\n    },\n}","language":"json","status":201},{"status":201,"name":"Result from File Upload","language":"json","code":"{\n    \"id\": 624526,\n    \"id\": 629061,\n    \"voip_id\": 349303,\n    \"name\": \"Main Menu Hold Music Updated\",\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\": \"test2.mp3\"\n}"}]},"settings":""},"next":{"description":"","pages":[]},"title":"Replace Media","type":"endpoint","slug":"replace-account-media","excerpt":"Update a media object to your account.  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 Replace Media API with the following definition:\n\nPUT https://api.phone.com/v4/accounts/:account_id/extensions/:extension_id/media/:media_id","body":"The above examples show how to update a media file.  Example 1 uses TTS as greeting while Example 2 uploads a media file as Hold Music\n[block:api-header]\n{\n  \"title\": \"\"\n}\n[/block]","updates":[],"order":4,"isReference":true,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"58cbe5710fdf192f00f3a865","githubsync":"","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":1,"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"},"parentDoc":null,"project":"55c8cff571d7580d0063a5e5","createdAt":"2017-03-17T13:32:33.350Z","user":"56f99ab84d2b4f3400edb636"}

putReplace Media

Update a media object to your account. 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 Replace Media API with the following definition: PUT https://api.phone.com/v4/accounts/:account_id/extensions/:extension_id/media/:media_id

Definition

{{ api_url }}{{ page_api_url }}

Parameters

Path Params

account_id:
required
integer
Account ID
media_id:
required
integer
Media ID

Body Params

name:
required
string
Name of media
origin:
required
string
'tts', 'file'
type:
string
'hold_music', 'greeting'
tts_voice:
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', 'shouty', 'shygirl', 'tamika', 'tophat', 'vittoria', 'vixen', 'vlad', 'walter', 'whispery', 'william', 'wiseguy', 'zach'
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 update a media file. Example 1 uses TTS as greeting while Example 2 uploads a media file as Hold Music [block:api-header] { "title": "" } [/block]

User Information

Try It Out

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