> For the complete documentation index, see [llms.txt](https://docs.flora.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flora.ai/api/reference/assets/uploadasset.md).

# 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), 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.

```http
POST https://app.flora.ai/api/v1/assets
```

* **Auth:** API key as a bearer token, `Authorization: Bearer $FLORA_API_KEY`. See [Authentication](https://docs.flora.ai/api/platform/authentication.md).
* **TypeScript SDK:** `client.assets.create()`.
* **Idempotency:** optional `Idempotency-Key` header. See [Idempotency](https://docs.flora.ai/api/platform/idempotency.md).
* **Operation ID:** `uploadAsset`.

## Example

{% tabs %}
{% tab title="cURL" %}

```bash
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"
}'
```

{% endtab %}

{% tab title="cURL (file upload)" %}

```bash
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'
```

{% endtab %}

{% tab title="TypeScript SDK" %}

```typescript
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);
```

{% endtab %}
{% endtabs %}

## Request body

Required. Send one of: `application/json`, `multipart/form-data`.

### JSON (`application/json`)

| Field          | Type    | Required | Description                                                                                                                                                                                                                                                     |
| -------------- | ------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `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\_. Static media uploads may be surfaced on the project's canvas; GLB Model3D assets are associated with the project but are not auto-placed. 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`.                                                                                                                                                                                                                           |
| `size_bytes`   | integer | No       | Exact file size in bytes; required for signed GLB uploads. At least 1. Example: `1048576`.                                                                                                                                                                      |

### Multipart form (`multipart/form-data`)

| Field          | Type   | Required | Description                                                                                                                                   |
| -------------- | ------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `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.

| Field          | Type               | Required | Description                                                                                                                                                                           |
| -------------- | ------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `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       | See the `upload` shapes below.                                                                                                                                                        |
| `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                                                                                                                                                    |

<details>

<summary>upload shapes</summary>

Field paths in this block are relative to `upload`.

`upload` takes one of 2 shapes, set by `content_type`.

**Shape 1: `content_type` is `multipart/form-data`.**

| Field          | Type          | Required | Description                   |
| -------------- | ------------- | -------- | ----------------------------- |
| `url`          | string (uri)  | Yes      | Upload URL                    |
| `method`       | string        | Yes      | Always `POST`.                |
| `content_type` | string        | Yes      | Always `multipart/form-data`. |
| `file_field`   | string        | Yes      | Always `file`.                |
| `form_fields`  | map of string | Yes      | Upload form fields            |

**Shape 2: `content_type` is `model/gltf-binary`.**

| Field          | Type          | Required | Description                  |
| -------------- | ------------- | -------- | ---------------------------- |
| `url`          | string (uri)  | Yes      | Resumable upload session URL |
| `method`       | string        | Yes      | Always `PUT`.                |
| `content_type` | string        | Yes      | Always `model/gltf-binary`.  |
| `headers`      | map of string | Yes      | Required upload headers      |

</details>

## Errors

Every error has the same body: `error.code`, `error.message`, and `error.fields` on validation errors. See [Errors](https://docs.flora.ai/api/platform/errors.md) for how to recover from each code.

| Status | Code                                         | Meaning                                                                             |
| ------ | -------------------------------------------- | ----------------------------------------------------------------------------------- |
| 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.                              |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.flora.ai/api/reference/assets/uploadasset.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
