Create an asset upload
import { FloraClient } from '@flora-ai/flora';
const client = new FloraClient({ apiKey: process.env['FLORA_API_KEY'] });
const asset = await client.assets.create({ source: 'signed-url', workspace_id: 'ws_abc123',});console.log(asset);curl -X POST 'https://app.flora.ai/api/v1/assets' \ -H 'Authorization: Bearer $FLORA_API_KEY' \ -H 'Content-Type: application/json' \ -d '{ "source": "signed-url", "workspace_id": "ws_abc123"}'Creates an asset via one of three paths. (1) Direct bytes: send multipart/form-data with a file part (≤4 MB) plus workspace_id — FLORA stores the bytes and returns a ready asset in one call. (2) Server-side fetch: send JSON with source set to any public HTTPS URL (≤50 MB) — FLORA fetches the bytes with SSRF protection (private/loopback/metadata IPs and redirects to them are blocked) and stores them. (3) Signed upload: send JSON with source=“signed-url” to reserve a presigned upload URL for files larger than 4 MB; upload the bytes, then call the complete endpoint. Allowed types: images (jpeg, png, webp, gif, avif, heic, heif), video (mp4, webm, quicktime), audio (mpeg, wav, ogg), and pdf; images are capped at 150 MP. Pass project_id on any path to also surface the asset on that project’s canvas. Mutating public API requests support an optional Idempotency-Key header for client retries; duplicate keys within two hours return idempotency_duplicate.
Error responses use the standard error body.
Authorizations
Section titled “Authorizations ”Request Body required
Section titled “Request Body required ”object
Asset source as a string: either “signed-url” to reserve a direct upload URL, or an allowlisted HTTPS URL for server-side fetch.
Workspace identifier. Use the public API ID returned by list workspaces; it must start with ws_.
Project identifier. Use the public API ID returned by list projects; it must start with prj_. When provided, the uploaded asset is also surfaced on the project’s canvas.
Destination folder
Asset content type
Asset file name
object
Raw file bytes to upload in a single request. Max 4 MB — larger files must use the signed-url flow. Allowed types: images, video, audio, pdf.
Workspace identifier. Must start with ws_.
Optional project to also surface the asset on. Must start with prj_.
Content type of the file. Defaults to the file part’s own Content-Type when omitted.
Original file name.
Destination folder.
Responses
Section titled “ Responses ”Asset upload created.
object
Asset identifier
Asset source: “url” (server-side fetch), “signed_url” (presigned upload reservation), or “direct” (multipart bytes streamed in this request).
Asset URL
Workspace identifier
object
Upload URL
Upload form fields
object
Upload URL (serialized)
Expiration time for the upload URL
Example
{ "asset_id": "asset_abc123", "uploaded_via": "url", "workspace_id": "ws_abc123", "visibility": "workspace", "status": "pending_upload", "upload": { "method": "POST", "content_type": "multipart/form-data", "file_field": "file" }, "upload_url": "https://storage.googleapis.com/flora-user-assets"}