Attach an asset to a canvas
import { FloraClient } from '@flora-ai/flora';
const client = new FloraClient({ apiKey: process.env['FLORA_API_KEY'] });
const asset = await client.projects.assets.attach({ projectId: '<projectId>', assetId: '<assetId>', width: 0, height: 0,});console.log(asset);curl -X POST 'https://app.flora.ai/api/v1/projects/<projectId>/assets/<assetId>/attach' \ -H 'Authorization: Bearer $FLORA_API_KEY' \ -H 'Content-Type: application/json' \ -d '{ "width": 0, "height": 0}'Attaches an existing ready asset to a project canvas as a static media node. Images and videos use their native aspect ratio by default. For a new image node with known dimensions, optionally set width or height in canvas pixels; an omitted side follows the native aspect ratio, and both sides must preserve it. The frame cannot shrink below its default size or grow beyond 1024 pixels on either edge. This does not change the asset. Sizing an already attached asset is rejected; use changeset update[].size instead. 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 ”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “ Path Parameters ”Project identifier
Project identifier
Asset identifier
Asset identifier
Request Body
Section titled “ Request Body ”object
Display width in canvas pixels for a static image. Omit height to derive it from the image’s aspect ratio.
Display height in canvas pixels for a static image. Omit width to derive it from the image’s aspect ratio.
Example generated
{ "width": 1, "height": 1}Responses
Section titled “ Responses ”Asset attached to canvas.
object
Project identifier
Asset identifier
Canvas node identifier
Project canvas URL
Example
{ "project_id": "prj_abc123", "asset_id": "asset_abc123", "node_id": "node_abc123"}