How to Insert a Media File

To insert a media file into a collection, make a POST request to the /v1/resource/insert/ endpoint with the required parameters in the body and make sure you use the audio type. Supported audio file types include .3ga, .8svx, .aac, .ac3, .aif, .aiff, .alac, .amr, .ape, .au, .dss, .flac, .flv, .m4a, .m4b, .m4p, .m4r, .mp3, .mpga, .ogg, .oga, .mogg, .opus, .qcp, .tta, .voc, .wav, .wma, .wv.

To use the audio type, the resource can either be provided as URLs or if you are using our SDKs the resource can be the path to the media file. Note: File paths only work with our SDKs if you are calling our API’s directly, all files must be provided as URLs. You can consider services like Amazon S3, Cloudinary, or similar platforms to host your files and provide their URLs to the API.

Request Example (Media file as URL)

from wetro import Wetrocloud
    
# Initialize the Wetrocloud client
client = Wetrocloud(api_key="your_api_key")
    
# Insert a media file into a Collection
insert_response = client.collection.insert_resource(
    collection_id="my_unique_collection_id",
    resource="https://res.cloudinary.com/dxcb59rb3/video/upload/v1744140560/PodcastingHouse-20181018-TheBriefingRoom_z6kfeq.mp3", 
    type="audio"
)
    
print(insert_response)

Request Example (File Path)

from wetro import Wetrocloud
    
# Initialize the Wetrocloud client
client = Wetrocloud(api_key="your_api_key")
    
# Insert a media file into a Collection
insert_response = client.collection.insert_resource(
    collection_id="my_unique_collection_id",
    resource="./folder/example.mp3", # Replace with your actual file path
    type="audio"
)
    
print(insert_response)

Successful Response

A successful response confirms the operation and tracks token usage.

Example Response

{
  "resource_id": "79621681-b680-4918-948d-d7f8c482426a",
  "success": true,
  "tokens": 35
}
FieldDescription
successIndicates whether the resource was inserted successfully.
tokensNumber of tokens consumed during the operation.
resource_idUnique ID for the resource, this is required when removing a resource