What You’ll Need
Before you begin, ensure you have:- A bunny.net account (Log in or sign up for a free trial).
Understanding the Upload Process
Uploading a video through the HTTP API involves two main steps:- Create the video object in your library (metadata and title).
- Upload the video file in binary format using a PUT request.
Creating a Video
Before uploading any video content, you must first create a video object in your library. This step is often overlooked, so please ensure it’s completed before proceeding with the upload.This step tells Bunny Stream that you’re about to upload a new video and gives it a title and optional metadata. It doesn’t upload the video yet, just sets up the “slot” for it.You can find full details about the available parameters in the Stream API Reference.
How to Create a Video:
Make an authenticated POST request to the following endpoint:-
AccessKey: Your Stream API key -
Accept: application/json -
Content-Type: application/json
-
title: The name of your video. This will appear in the library UI. -
collectionId(optional): The ID of a collection in your library where this video should be placed. -
thumbnailTime(optional): The time (in milliseconds) to use when extracting the main video thumbnail.
- A unique videoId (guid)
- The libraryId
- Basic metadata such as title and creation date
videoId from this response in the next step.
Uploading the Video File
Once the video object is created, you can proceed to upload the actual video file. Full API reference: Stream API Reference. Upload Endpoint:Fetching Videos from a Remote URL (Optional)
If you already have a video file hosted on another platform or server, bunny.net allows you to fetch it directly using a remote URL, saving you the trouble of downloading and re-uploading manually. The documentation link to this can be found in the Stream API Reference.The URL you provide must be accessible by bunny.net’s fetch system. You can use the optional
headers parameter to include custom HTTP headers with the fetch request, enabling authentication methods such as:- Basic Authentication (via the
Authorizationheader) - Static API keys (via custom headers like
X-API-KeyorAuthorization: Bearer <token>)
headers parameter.bash