JSON API » codes » codes/files/download

Downloads a feature code sound file.

Input parameters

Requires authentication and the administrator, user, or wholesale role privileges.

NameTypeDescriptionRequiredDefault value
auth_usernameStringAuthentication username.Yes
auth_passwordStringAuthentication password.Yes
codeStringFeature code.Yes
fileStringWhich file to download. "message" or "screen".Yes
customerIntegerID of customer owning feature code.NoCustomer of authentication user.
checkInteger1 to just check if the file exists, 0 to download it.No0
encodingString"base64" to return file base64 encoded, "raw" to return raw data.No"raw"
wrapString"json" to return file in a JSON object, "none" to return plain file.No"json"

Responses

CodeDescription
200Success.
400Invalid file specified.
401The authentication details provided are invalid.
402Your role does not allow this.
404The feature code or file does not exist, or you do not have permission to view it.
500The sound file cannot be read.

If check=1 was specified and the file does not exist, 200 is returned.

Data returned

If checking, whether the file was found or not. If not checking, the sound file data plus name and mime-type.

Example: Download file (data truncated for brevity)

http://enswitch.example.com/api/json/codes/files/download/?auth_username=user;auth_password=password;code=100;file=message

{ "responses":[ { "code":"200", "key":"", "message":"OK" } ], "data":{ "id":123, "name":"example.wav", "mimetype":"audio/x-wav", "data":"RIFFn..." } }

Example: Check if file exists, and it does

http://enswitch.example.com/api/json/codes/files/download/?auth_username=user;auth_password=password;code=100;file=message;check=1

{ "responses":[ { "code":"200", "key":"", "message":"OK" } ], "data":{ "found":1 } }

Example: Check if file exists, and it doesn't

http://enswitch.example.com/api/json/codes/files/download/?auth_username=user;auth_password=password;code=100;file=message;check=1

{ "responses":[ { "code":"200", "key":"", "message":"OK" } ], "data":{ "found":0 } }

Change history

VersionChanges
3.15wrap parameter added.
3.13Function added.