Create an asset upload
Create an asset upload with the FLORA API: POST /assets.
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, mp4/m4a), 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.
POST https://app.flora.ai/api/v1/assetsAuth: API key as a bearer token,
Authorization: Bearer $FLORA_API_KEY. See Authentication.TypeScript SDK:
client.assets.create().Idempotency: optional
Idempotency-Keyheader. See Idempotency.Operation ID:
uploadAsset.
Example
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"
}'curl -X POST 'https://app.flora.ai/api/v1/assets' \
-H "Authorization: Bearer $FLORA_API_KEY" \
-F 'file=@./hero.png' \
-F 'workspace_id=ws_abc123'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);Request body
Required. Send one of: application/json, multipart/form-data.
JSON (application/json)
source
string
Yes
Asset source as a string: either "signed-url" to reserve a direct upload URL, or a public HTTPS URL for server-side fetch. Example: signed-url.
workspace_id
string
Yes
Workspace identifier. Use the public API ID returned by list workspaces; it must start with ws_. Example: ws_abc123.
project_id
string
No
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. Example: prj_abc123.
folder
string
No
Destination folder. Example: campaign-assets.
content_type
string
No
Asset content type. Example: image/png.
file_name
string
No
Asset file name. Example: hero.png.
Multipart form (multipart/form-data)
file
file
Yes
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_id
string
Yes
Workspace identifier. Must start with ws_. Example: ws_abc123.
project_id
string
No
Optional project to also surface the asset on. Must start with prj_. Example: prj_abc123.
content_type
string
No
Content type of the file. Defaults to the file part's own Content-Type when omitted. Example: image/png.
file_name
string
No
Original file name. Example: hero.png.
folder
string
No
Destination folder. Example: campaign-assets.
Responses
201: Asset upload created.
asset_id
string
Yes
Asset identifier. Pattern: ^asset_\S+$. Example: asset_abc123.
uploaded_via
string
Yes
Asset source: "url" (server-side fetch), "signed_url" (presigned upload reservation), or "direct" (multipart bytes streamed in this request). One of: url, signed_url, direct.
url
string (uri)
Yes
Asset URL
workspace_id
string
Yes
Workspace identifier. Pattern: ^ws_\S+$. Example: ws_abc123.
visibility
string
Yes
Always workspace.
status
string
Yes
One of: pending_upload, ready, failed.
upload
object
No
upload.url
string (uri)
Yes
Upload URL
upload.method
string
Yes
Always POST.
upload.content_type
string
Yes
Always multipart/form-data.
upload.file_field
string
Yes
Always file.
upload.form_fields
map of string
Yes
Upload form fields
upload_url
string
No
Upload URL (serialized). Example: https://storage.googleapis.com/flora-user-assets.
expires_at
string (date-time)
No
Expiration time for the upload URL
Errors
Every error has the same body: error.code, error.message, and error.fields on validation errors. See Errors for how to recover from each code.
400
invalid_json, input_validation_error
The body isn't valid JSON, or an input failed validation (fields lists each one).
401
unauthorized, invalid_api_key
The API key is missing, invalid or revoked.
402
insufficient_credits
The workspace balance is too low for this request.
403
forbidden, paid_plan_required
The key can't do this, or the workspace plan doesn't include it.
404
not_found
The resource doesn't exist or isn't visible to this key.
409
idempotency_duplicate, revision_conflict
Duplicate Idempotency-Key or a stale base_revision.
429
rate_limited
Too many requests. Back off and retry.
500
unknown_error, internal_error
Something failed on FLORA's side. Retry with backoff.
503
temporarily_unavailable
Authorization is temporarily unavailable. Retry later.
Last updated
Was this helpful?