TokenLab

Worlds

Prepare Media Asset Upload

Creates a World Labs media asset upload target

POST
/v1/worlds/media-assets/prepare-upload

Create a World Labs media asset record and receive an upload URL for an image or video. Upload the binary file to upload_info.upload_url, then reference the returned media_asset.media_asset_id from world_prompt with source: "media_asset".

The asset is available only in the Workspace that created it.

Request Body

file_namestringrequired

Original file name, up to 64 characters.

kindstringrequired

Media type: image or video.

extensionstring | null

Optional extension such as png, jpg, or mp4.

metadataobject | null

Custom metadata stored with the asset.

Response

media_assetobject

Prepared World Labs media asset metadata.

upload_info.upload_urlstring

Signed URL for uploading the file.

upload_info.upload_methodstring

HTTP method to use when uploading the binary file to upload_info.upload_url, when returned.

upload_info.required_headersobject

Headers to include with the binary upload, when returned.

Request

curl -X POST "https://api.tokenlab.sh/v1/worlds/media-assets/prepare-upload" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "file_name": "reference.png",
    "kind": "image",
    "extension": "png"
  }'
{  "media_asset": {    "created_at": "2019-08-24T14:15:22Z",    "file_name": "string",    "kind": "image",    "media_asset_id": "string",    "extension": "string",    "metadata": {},    "updated_at": "2019-08-24T14:15:22Z"  },  "upload_info": {    "upload_method": "string",    "upload_url": "http://example.com",    "curl_example": "string",    "required_headers": {      "property1": "string",      "property2": "string"    }  }}

Authorization

BearerAuth
AuthorizationBearer <token>

API Key authentication. Create or manage API keys in Dashboard > API > API Keys.

In: header

Request Body

application/json

Response

application/json

application/json