Upload a Custom Ringtone

Upload a custom ringtone.

Request URL

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

Request parameters

Parameter Required Type Description
file Yes File The custom ringtone file.
Note: Only a file in ".wav" or ".mp3" format is allowed, and the file size must not exceed 4MB.
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 filename of the custom ringtone already exists.
  • force: Upload the custom ringtone.
    Note: If no duplicate filename exists, add the custom ringtone directly; otherwise, overwrite the existing one.
type No String The file type.
Note: This parameter is required when a file is created rather than replaced.

Valid value:

  • backend
old_file No String The filename of the custom ringtone to be replaced, including the file extension (e.g., "demo_ringtone.wav").
Note:
  • You can query the filename of the custom ringtone using Search Custom Ringtones.
  • Only the filename of the custom ringtone uploaded from local storage (type: backend) is allowed.
new_file No String The new filename used to update the filename of the replaced ringtone, including the file extension (e.g., "demo_ringtone.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 custom ringtone files.
Note: This parameter is returned only when the number of custom ringtone files reaches the limit.

Example

Request example

POST /openapi/v1.0/custom_ringtone/upload?access_token=gwakjgu9ZBUfz36wql4ndsVKkryI0kdj HTTP/1.1

Host: yeastardocs.example.yeastarcloud.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="demo_ringtone.wav"
Content-Type: audio/wav

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

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

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

Response example

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