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. Without content_type or a recognized filename extension, signed upload completion can identify MP3, WAV, M4A/M4B audio, and PDF from their headers, as well as supported images and video. For other audio, provide a recognized audio filename extension or an allowed content_type; completion does not inspect audio tracks. For signed Matroska, AVI, or Ogg video, provide a file_name ending in .mkv, .avi, or .ogv respectively and omit content_type; explicitly declaring their MIME types is not supported. Allowed types: images (jpeg, png, webp, gif, avif, heic, heif), video (mp4, webm, quicktime), audio (mpeg, wav, ogg, mp4/m4a), pdf, and GLB (model/gltf-binary). GLB requires project_id; signed GLB uploads also require exact local file length as size_bytes and use the returned raw-byte PUT descriptor. GLBs are validated before readiness. Images are capped at 150 MP. project_id associates the asset with a project; supported static media are surfaced on its canvas, while GLB Model3D assets are not auto-placed. 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 a public 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_. Static media uploads may be surfaced on the project’s canvas; GLB Model3D assets are associated with the project but are not auto-placed.
Destination folder
Asset content type
Asset file name. Signed uploads keep a supported filename extension. If the extension is missing or unsupported, the storage key uses the extension for a supported content_type, or .bin when content_type is omitted. Completion validates the uploaded bytes.
Exact file size in bytes; required for signed GLB uploads.
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
object
Resumable upload session URL
Required upload headers
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"}