{"_id":"58cbe5710fdf192f00f3a865","githubsync":"","version":{"_id":"57624356653c2d2200fec79c","__v":22,"project":"55c8cff571d7580d0063a5e5","createdAt":"2016-06-16T06:12:38.244Z","releaseDate":"2016-06-16T06:12:38.244Z","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"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"","version_clean":"4.0.0","version":"4"},"__v":1,"category":{"_id":"57624356653c2d2200fec7a4","__v":0,"version":"57624356653c2d2200fec79c","project":"55c8cff571d7580d0063a5e5","sync":{"url":"","isSync":false},"reference":true,"createdAt":"2016-05-16T21:10:19.740Z","from_sync":false,"order":17,"slug":"account-media","title":"Account Media"},"parentDoc":null,"project":"55c8cff571d7580d0063a5e5","user":"56f99ab84d2b4f3400edb636","updates":[],"next":{"pages":[],"description":""},"createdAt":"2017-03-17T13:32:33.350Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"examples":{"codes":[{"name":"Text-to-Speech (TTS)","language":"php","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}"},{"name":"Upload a Local File","language":"php","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}"}]},"method":"put","results":{"codes":[{"status":201,"language":"json","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}","name":"Result from TTS"},{"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}","language":"json","name":"Result from File Upload","status":201}]},"settings":"","auth":"required","params":[{"_id":"56f9c415338fbb2000ec3711","ref":"","in":"path","required":true,"desc":"Account ID","default":"","type":"int","name":"account_id"},{"_id":"579be149f4ad7b190094b6cd","ref":"","in":"body","required":true,"desc":"Name of media","default":"","type":"string","name":"name"},{"_id":"579be1c7f4ad7b190094b6cf","ref":"","in":"body","required":true,"desc":"'tts', 'file'","default":"","type":"string","name":"origin"},{"_id":"579be1c7f4ad7b190094b6d0","ref":"","in":"body","required":false,"desc":"'hold_music', 'greeting'","default":"","type":"string","name":"type"},{"_id":"579be1c7f4ad7b190094b6ce","ref":"","in":"body","required":false,"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'","default":"","type":"string","name":"tts_voice"},{"_id":"579be1d11ea3140e0083b65f","ref":"","in":"body","required":false,"desc":"Text used for text-to-speech conversion, maximum 800 characters","default":"","type":"string","name":"tts_text"},{"_id":"579be1ed5623be220083266f","ref":"","in":"body","required":false,"desc":"'Y', 'N'.  Media file is temporary, will be deleted after a specified period.","default":"N","type":"string","name":"is_temporary"},{"_id":"579be1f75623be2200832670","ref":"","in":"body","required":false,"desc":"If is_temporary is 'Y', media will be deleted after the specified time in seconds","default":"0","type":"int","name":"expiration_date"},{"_id":"58a4b2cd89e3232300e5c445","ref":"","in":"body","required":false,"desc":"Length of media in seconds","default":"","type":"int","name":"duration"},{"_id":"58a4b2cd89e3232300e5c444","ref":"","in":"body","required":false,"desc":"Notes about the media object","default":"","type":"string","name":"notes"},{"_id":"58a4b2cd89e3232300e5c443","ref":"","in":"body","required":false,"desc":"'Y', 'N'.  Start playing the media file in random location, instead of from the beginning","default":"N","type":"string","name":"randomized"},{"_id":"58cbf64331c89a0f00960e4e","ref":"","in":"path","required":true,"desc":"Media ID","default":"","type":"int","name":"media_id"}],"url":"/accounts/:account_id/media/:media_id"},"isReference":true,"order":4,"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]","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","slug":"replace-account-media","type":"endpoint","title":"Replace Media"}

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