# Assets

## Create an asset upload

`client.assets.create(AssetCreateParamsbody, RequestOptionsoptions?): AssetCreateResponse`

**post** `/assets`

Creates an asset from a source string. Pass source="signed-url" to reserve a direct upload URL, or pass an allowlisted HTTPS URL for server-side fetch. Mutating public API requests support an optional Idempotency-Key header for client retries; duplicate keys within two hours return idempotency_duplicate.

### Parameters

- `body: AssetCreateParams`

  - `source: string`

    Asset source as a string: either "signed-url" to reserve a direct upload URL, or an allowlisted HTTPS URL for server-side fetch.

  - `workspace_id: string`

    Workspace identifier. Use the public API ID returned by list workspaces; it must start with ws_.

  - `content_type?: string`

    Asset content type

  - `file_name?: string`

    Asset file name

  - `folder?: string`

    Destination folder

### Returns

- `AssetCreateResponse`

  - `asset_id: string`

    Asset identifier

  - `status: "pending_upload" | "ready" | "failed"`

    - `"pending_upload"`

    - `"ready"`

    - `"failed"`

  - `uploaded_via: "url" | "signed_url"`

    Asset source

    - `"url"`

    - `"signed_url"`

  - `url: string`

    Asset URL

  - `visibility: "workspace"`

    - `"workspace"`

  - `workspace_id: string`

    Workspace identifier

  - `expires_at?: string`

    Expiration time for the upload URL

  - `upload?: Upload`

    - `content_type: "multipart/form-data"`

      - `"multipart/form-data"`

    - `file_field: "file"`

      - `"file"`

    - `form_fields: Record<string, string>`

      Upload form fields

    - `method: "POST"`

      - `"POST"`

    - `url: string`

      Upload URL

  - `upload_url?: string`

    Upload URL (serialized)

### Example

```typescript
import FLORA from '@flora-ai/flora';

const client = new FLORA({
  apiKey: process.env['FLORA_API_KEY'], // This is the default and can be omitted
});

const asset = await client.assets.create({ source: 'signed-url', workspace_id: 'ws_abc123' });

console.log(asset.asset_id);
```

#### Response

```json
{
  "asset_id": "asset_abc123",
  "status": "pending_upload",
  "uploaded_via": "url",
  "url": "https://example.com",
  "visibility": "workspace",
  "workspace_id": "ws_abc123",
  "expires_at": "2019-12-27T18:11:19.117Z",
  "upload": {
    "content_type": "multipart/form-data",
    "file_field": "file",
    "form_fields": {
      "foo": "string"
    },
    "method": "POST",
    "url": "https://example.com"
  },
  "upload_url": "https://upload.imagekit.io/api/v1/files/upload"
}
```

## Complete a signed asset upload

`client.assets.complete(stringassetID, RequestOptionsoptions?): AssetCompleteResponse`

**post** `/assets/{assetId}/complete`

Marks a signed asset upload as complete after the file has been uploaded. Mutating public API requests support an optional Idempotency-Key header for client retries; duplicate keys within two hours return idempotency_duplicate.

### Parameters

- `assetID: string`

  Asset identifier

### Returns

- `AssetCompleteResponse`

  - `asset_id: string`

    Asset identifier

  - `status: "pending_upload" | "ready" | "failed"`

    - `"pending_upload"`

    - `"ready"`

    - `"failed"`

  - `url: string | null`

    Asset URL

  - `visibility: "workspace"`

    - `"workspace"`

  - `workspace_id: string | null`

    Workspace identifier

  - `expires_at?: string`

    Expiration time for the upload URL

  - `failure_message?: string | null`

    Failure message when the asset is in failed status

  - `upload?: Upload`

    - `content_type: "multipart/form-data"`

      - `"multipart/form-data"`

    - `file_field: "file"`

      - `"file"`

    - `form_fields: Record<string, string>`

      Upload form fields

    - `method: "POST"`

      - `"POST"`

    - `url: string`

      Upload URL

  - `upload_url?: string`

    Upload URL (serialized)

### Example

```typescript
import FLORA from '@flora-ai/flora';

const client = new FLORA({
  apiKey: process.env['FLORA_API_KEY'], // This is the default and can be omitted
});

const response = await client.assets.complete('asset_abc123');

console.log(response.asset_id);
```

#### Response

```json
{
  "asset_id": "asset_abc123",
  "status": "pending_upload",
  "url": "https://example.com",
  "visibility": "workspace",
  "workspace_id": "ws_abc123",
  "expires_at": "2019-12-27T18:11:19.117Z",
  "failure_message": "failure_message",
  "upload": {
    "content_type": "multipart/form-data",
    "file_field": "file",
    "form_fields": {
      "foo": "string"
    },
    "method": "POST",
    "url": "https://example.com"
  },
  "upload_url": "https://upload.imagekit.io/api/v1/files/upload"
}
```

## Retry a signed asset upload

`client.assets.retry(stringassetID, RequestOptionsoptions?): AssetRetryResponse`

**post** `/assets/{assetId}/retry`

Creates a fresh signed upload reservation for a failed or expired asset upload. Mutating public API requests support an optional Idempotency-Key header for client retries; duplicate keys within two hours return idempotency_duplicate.

### Parameters

- `assetID: string`

  Asset identifier

### Returns

- `AssetRetryResponse`

  - `asset_id: string`

    Asset identifier

  - `status: "pending_upload" | "ready" | "failed"`

    - `"pending_upload"`

    - `"ready"`

    - `"failed"`

  - `url: string | null`

    Asset URL

  - `visibility: "workspace"`

    - `"workspace"`

  - `workspace_id: string | null`

    Workspace identifier

  - `expires_at?: string`

    Expiration time for the upload URL

  - `failure_message?: string | null`

    Failure message when the asset is in failed status

  - `upload?: Upload`

    - `content_type: "multipart/form-data"`

      - `"multipart/form-data"`

    - `file_field: "file"`

      - `"file"`

    - `form_fields: Record<string, string>`

      Upload form fields

    - `method: "POST"`

      - `"POST"`

    - `url: string`

      Upload URL

  - `upload_url?: string`

    Upload URL (serialized)

### Example

```typescript
import FLORA from '@flora-ai/flora';

const client = new FLORA({
  apiKey: process.env['FLORA_API_KEY'], // This is the default and can be omitted
});

const response = await client.assets.retry('asset_abc123');

console.log(response.asset_id);
```

#### Response

```json
{
  "asset_id": "asset_abc123",
  "status": "pending_upload",
  "url": "https://example.com",
  "visibility": "workspace",
  "workspace_id": "ws_abc123",
  "expires_at": "2019-12-27T18:11:19.117Z",
  "failure_message": "failure_message",
  "upload": {
    "content_type": "multipart/form-data",
    "file_field": "file",
    "form_fields": {
      "foo": "string"
    },
    "method": "POST",
    "url": "https://example.com"
  },
  "upload_url": "https://upload.imagekit.io/api/v1/files/upload"
}
```

## List assets

`client.assets.list(AssetListParamsquery?, RequestOptionsoptions?): AssetsCursorPage<AssetListResponse>`

**get** `/assets`

Returns assets visible to the authenticated public API key. Filter by workspace, project canvas, search query, cursor, and limit without exposing raw file bytes or internal graph data.

### Parameters

- `query: AssetListParams`

  - `cursor?: string`

    Opaque cursor for fetching the next page

  - `limit?: number`

    Maximum number of results to return

  - `project_id?: string`

    Project identifier

  - `query?: string`

    Search query

  - `workspace_id?: string`

    Workspace identifier

### Returns

- `AssetListResponse`

  - `asset_id: string | null`

    Asset identifier

  - `content_type: string`

    Asset content type

  - `created_at: number | null`

  - `description: string | null`

    Asset description

  - `height: number | null`

  - `name: string | null`

    Asset name

  - `size_bytes: number | null`

  - `status: "pending_upload" | "ready" | "failed"`

    - `"pending_upload"`

    - `"ready"`

    - `"failed"`

  - `upload_content_type: string | null`

    Content type provided at upload time

  - `uploaded_via: string`

    Asset source

  - `url: string | null`

    Asset URL

  - `width: number | null`

  - `workspace_id: string | null`

    Workspace identifier

  - `node_id?: string | null`

    Associated node identifier

  - `project_id?: string | null`

    Project identifier

### Example

```typescript
import FLORA from '@flora-ai/flora';

const client = new FLORA({
  apiKey: process.env['FLORA_API_KEY'], // This is the default and can be omitted
});

// Automatically fetches more pages as needed.
for await (const assetListResponse of client.assets.list()) {
  console.log(assetListResponse.asset_id);
}
```

#### Response

```json
{
  "assets": [
    {
      "asset_id": "asset_abc123",
      "content_type": "content_type",
      "created_at": 0,
      "description": "description",
      "height": 0,
      "name": "name",
      "size_bytes": 0,
      "status": "pending_upload",
      "upload_content_type": "upload_content_type",
      "uploaded_via": "uploaded_via",
      "url": "url",
      "width": 0,
      "workspace_id": "ws_abc123",
      "node_id": "node_abc123",
      "project_id": "prj_abc123"
    }
  ],
  "meta": {
    "next_cursor": "eyJvZmZzZXQiOjIwfQ",
    "total_estimate": 0
  }
}
```

## Get an asset

`client.assets.retrieve(stringassetID, RequestOptionsoptions?): AssetRetrieveResponse`

**get** `/assets/{assetId}`

Returns metadata for one asset when it is accessible to the authenticated public API key. Missing and inaccessible assets both return 404.

### Parameters

- `assetID: string`

  Asset identifier

### Returns

- `AssetRetrieveResponse`

  - `asset_id: string`

    Asset identifier

  - `content_type: string`

    Asset content type

  - `created_at: string | null`

    Asset creation time (ISO 8601 datetime)

  - `description: string | null`

    Asset description

  - `failure_message: string | null`

    Failure message when the asset is in failed status

  - `height: number | null`

  - `name: string | null`

    Asset name

  - `size_bytes: number | null`

  - `status: "pending_upload" | "ready" | "failed"`

    - `"pending_upload"`

    - `"ready"`

    - `"failed"`

  - `upload_content_type: string | null`

    Content type provided at upload time

  - `uploaded_via: string`

    Asset source

  - `url: string | null`

    Asset URL

  - `width: number | null`

  - `workspace_id: string | null`

    Workspace identifier

### Example

```typescript
import FLORA from '@flora-ai/flora';

const client = new FLORA({
  apiKey: process.env['FLORA_API_KEY'], // This is the default and can be omitted
});

const asset = await client.assets.retrieve('asset_abc123');

console.log(asset.asset_id);
```

#### Response

```json
{
  "asset_id": "asset_abc123",
  "content_type": "content_type",
  "created_at": "2019-12-27T18:11:19.117Z",
  "description": "description",
  "failure_message": "failure_message",
  "height": 0,
  "name": "name",
  "size_bytes": 0,
  "status": "pending_upload",
  "upload_content_type": "upload_content_type",
  "uploaded_via": "uploaded_via",
  "url": "url",
  "width": 0,
  "workspace_id": "ws_abc123"
}
```

## Domain Types

### Asset Create Response

- `AssetCreateResponse`

  - `asset_id: string`

    Asset identifier

  - `status: "pending_upload" | "ready" | "failed"`

    - `"pending_upload"`

    - `"ready"`

    - `"failed"`

  - `uploaded_via: "url" | "signed_url"`

    Asset source

    - `"url"`

    - `"signed_url"`

  - `url: string`

    Asset URL

  - `visibility: "workspace"`

    - `"workspace"`

  - `workspace_id: string`

    Workspace identifier

  - `expires_at?: string`

    Expiration time for the upload URL

  - `upload?: Upload`

    - `content_type: "multipart/form-data"`

      - `"multipart/form-data"`

    - `file_field: "file"`

      - `"file"`

    - `form_fields: Record<string, string>`

      Upload form fields

    - `method: "POST"`

      - `"POST"`

    - `url: string`

      Upload URL

  - `upload_url?: string`

    Upload URL (serialized)

### Asset Complete Response

- `AssetCompleteResponse`

  - `asset_id: string`

    Asset identifier

  - `status: "pending_upload" | "ready" | "failed"`

    - `"pending_upload"`

    - `"ready"`

    - `"failed"`

  - `url: string | null`

    Asset URL

  - `visibility: "workspace"`

    - `"workspace"`

  - `workspace_id: string | null`

    Workspace identifier

  - `expires_at?: string`

    Expiration time for the upload URL

  - `failure_message?: string | null`

    Failure message when the asset is in failed status

  - `upload?: Upload`

    - `content_type: "multipart/form-data"`

      - `"multipart/form-data"`

    - `file_field: "file"`

      - `"file"`

    - `form_fields: Record<string, string>`

      Upload form fields

    - `method: "POST"`

      - `"POST"`

    - `url: string`

      Upload URL

  - `upload_url?: string`

    Upload URL (serialized)

### Asset Retry Response

- `AssetRetryResponse`

  - `asset_id: string`

    Asset identifier

  - `status: "pending_upload" | "ready" | "failed"`

    - `"pending_upload"`

    - `"ready"`

    - `"failed"`

  - `url: string | null`

    Asset URL

  - `visibility: "workspace"`

    - `"workspace"`

  - `workspace_id: string | null`

    Workspace identifier

  - `expires_at?: string`

    Expiration time for the upload URL

  - `failure_message?: string | null`

    Failure message when the asset is in failed status

  - `upload?: Upload`

    - `content_type: "multipart/form-data"`

      - `"multipart/form-data"`

    - `file_field: "file"`

      - `"file"`

    - `form_fields: Record<string, string>`

      Upload form fields

    - `method: "POST"`

      - `"POST"`

    - `url: string`

      Upload URL

  - `upload_url?: string`

    Upload URL (serialized)

### Asset List Response

- `AssetListResponse`

  - `asset_id: string | null`

    Asset identifier

  - `content_type: string`

    Asset content type

  - `created_at: number | null`

  - `description: string | null`

    Asset description

  - `height: number | null`

  - `name: string | null`

    Asset name

  - `size_bytes: number | null`

  - `status: "pending_upload" | "ready" | "failed"`

    - `"pending_upload"`

    - `"ready"`

    - `"failed"`

  - `upload_content_type: string | null`

    Content type provided at upload time

  - `uploaded_via: string`

    Asset source

  - `url: string | null`

    Asset URL

  - `width: number | null`

  - `workspace_id: string | null`

    Workspace identifier

  - `node_id?: string | null`

    Associated node identifier

  - `project_id?: string | null`

    Project identifier

### Asset Retrieve Response

- `AssetRetrieveResponse`

  - `asset_id: string`

    Asset identifier

  - `content_type: string`

    Asset content type

  - `created_at: string | null`

    Asset creation time (ISO 8601 datetime)

  - `description: string | null`

    Asset description

  - `failure_message: string | null`

    Failure message when the asset is in failed status

  - `height: number | null`

  - `name: string | null`

    Asset name

  - `size_bytes: number | null`

  - `status: "pending_upload" | "ready" | "failed"`

    - `"pending_upload"`

    - `"ready"`

    - `"failed"`

  - `upload_content_type: string | null`

    Content type provided at upload time

  - `uploaded_via: string`

    Asset source

  - `url: string | null`

    Asset URL

  - `width: number | null`

  - `workspace_id: string | null`

    Workspace identifier
