Upload an MOH Audio File

Upload an audio file to a specified MOH (music on hold) playlist.

Request URL

POST {base_url}/{api_path}/moh_files/upload?access_token={access_token}

Request parameters

Parameter Required Type Description
file Yes File The audio file.
Note: Only a file in ".wav", ".mp3" or ".gsm" format is allowed, and the file size must not exceed 8MB.
is_check No String The operation mode.
Note: This parameter is required and available only when the parameters old_file and new_file are not included in the request.

Valid value:

  • ask: Check whether the name of the audio file already exists.
  • force: Upload the audio file.
    Note: If no duplicate filename exists, add the audio directly; otherwise, overwrite the existing one.
owner Yes String The name of the MOH playlist.
Note: You can query the name of the MOH playlist using Query MoH Playlists.
old_file No String The name of the audio file to be replaced, including the file extension (e.g., "WhisperingPine.wav").
Note:

You can query the name of the audio file using Query MOH Audio File List.

new_file No String The new name used to update the name of the replaced audio file, including the file extension (e.g., "WhisperingPine.wav").
Note: The file extension must be the same as the old file.

Response parameters

Parameter Type Description
errcode Integer Returned error code.
  • 0: Succeed.
  • Non-zero value: Failed.
Note: You can check the error code and error message in Error Code and Error Message.
errmsg String Returned message.
  • SUCCESS: Succeed.
  • FAILURE: Failed.
upper_limited Integer The limit for MOH audio files.
Note: This parameter is returned when the number of either MOH playlists or audio files per playlist reaches the limit.

Example

Request example

POST /openapi/v1.0/moh_files/upload?access_token=gwakjgu9ZBUfz36wql4ndsVKkryI0kdj HTTP/1.1
Host: 192.168.5.150:8088
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="demo_track.wav"
Content-Type: audio/wav

<binary audio content>
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="is_check"

force
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="owner"

demo_list
------WebKitFormBoundary7MA4YWxkTrZu0gW--
Figure 1. Request example in Postman

Response example

HTTP/1.1 200 OK
{
  "errcode": 0,
  "errmsg": "SUCCESS"
}