POST
/
v1
/
files
/
upload-urls
Python
from magic_hour import Client
from os import getenv

client = Client(token=getenv("API_TOKEN"))
res = client.v1.files.upload_urls.create(
    items=[
        {"extension": "mp4", "type_": "video"},
        {"extension": "mp3", "type_": "audio"},
    ]
)
{
  "items": [
    {
      "upload_url": "https://videos.magichour.ai/api-assets/id/video.mp4?auth-value=1234567890",
      "expires_at": "2024-07-25T16:56:21.932Z",
      "file_path": "api-assets/id/video.mp4"
    },
    {
      "upload_url": "https://videos.magichour.ai/api-assets/id/audio.mp3?auth-value=1234567890",
      "expires_at": "2024-07-25T16:56:21.932Z",
      "file_path": "api-assets/id/audio.mp3"
    }
  ]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <api_key>, where <api_key> is your API key. To get your API key, go to Developer Hub and click "Create new API Key".

Body

application/json

Body

items
object[]
required

The list of assets to upload. The response array will match the order of items in the request body.

Minimum length: 1
Example:
[
{ "type": "video", "extension": "mp4" },
{ "type": "audio", "extension": "mp3" }
]

Response

Success

items
object[]
required

The list of upload URLs and file paths for the assets. The response array will match the order of items in the request body. Refer to the Input Files Guide for more details.

Example:
[
{
"upload_url": "https://videos.magichour.ai/api-assets/id/video.mp4?auth-value=1234567890",
"expires_at": "2024-07-25T16:56:21.932Z",
"file_path": "api-assets/id/video.mp4"
},
{
"upload_url": "https://videos.magichour.ai/api-assets/id/audio.mp3?auth-value=1234567890",
"expires_at": "2024-07-25T16:56:21.932Z",
"file_path": "api-assets/id/audio.mp3"
}
]