# Files ## Upload a file `$ luma-agents-cli files create` **post** `/files` Upload a file to your namespace, then reference it from a generation via ImageRef.file_id (as source, image_ref[], video.start_frame, keyframes, and so on). Two upload modes share this endpoint, selected by Content-Type: - multipart/form-data — send the bytes inline in the `file` part. Best for small files (subject to an inline size cap; larger files must use the presigned flow). The returned file is already `pending` ingest. - application/json — request a presigned upload. The response `upload` envelope tells you where to PUT the bytes; afterward call POST /files/{file_id}/complete to start ingest. Use this for larger files. ### Parameters - `--mime-type: string` MIME type of the bytes you will upload. - `--size-bytes: number` Exact size in bytes of the object you will PUT. Up to 5 GiB (the S3 single-PUT ceiling). - `--expires-at: optional string` Optional TTL. After this time Luma may automatically delete the file and reclaim its bytes. - `--filename: optional string` Optional original filename to record. - `--purpose: optional "input" or "reference"` How the file is intended to be used in a generation. `input` is the primary subject (e.g. the source image for an edit); `reference` is style/content guidance. - `--user-id: optional string` Optional opaque end-user tag for abuse attribution. Mirrors the user_id field on POST /generations. ### Returns - `create_file_response: object { id, file, state, upload }` Result of POST /files. In the multipart (inline) flow `upload` is null and the file is already `pending` ingest. In the presigned (JSON) flow `upload` carries the PUT envelope and the file stays `pending` until you call POST /files/{file_id}/complete. Top-level `id` and `state` are conveniences that mirror `file.id` and `file.state`; the full record is always under `file`. - `id: string` File identifier. - `file: object { id, created_at, mime_type, 8 more }` A file in the caller's namespace. - `id: string` File identifier, referenced as ImageRef.file_id. - `created_at: string` Creation timestamp. - `mime_type: string` MIME type of the stored bytes (for example, image/jpeg). - `purpose: "input" or "reference"` How the file is intended to be used in a generation. `input` is the primary subject (e.g. the source image for an edit); `reference` is style/content guidance. - `"input"` - `"reference"` - `size_bytes: number` Size of the stored object in bytes. - `state: "pending" or "ready" or "failed" or "deleted"` Lifecycle state of an uploaded file. `pending` until bytes are received and the ingest pipeline runs; `ready` once it can be referenced from a generation; `failed` if ingest/moderation rejected it; `deleted` once the file has been deleted. - `"pending"` - `"ready"` - `"failed"` - `"deleted"` - `deleted_at: optional string` When the file was deleted; null otherwise. - `expires_at: optional string` TTL set at upload, if any. After this time Luma may automatically delete the file and reclaim its bytes — you don't need to call DELETE yourself. - `failure_reason: optional string` Human-readable reason when state is failed. - `filename: optional string` Original filename supplied at upload, if any. - `user_id: optional string` The opaque end-user tag supplied at upload, echoed back unchanged. Abuse-attribution only; not an access-control primitive. - `state: "pending" or "ready" or "failed" or "deleted"` Lifecycle state of an uploaded file. `pending` until bytes are received and the ingest pipeline runs; `ready` once it can be referenced from a generation; `failed` if ingest/moderation rejected it; `deleted` once the file has been deleted. - `"pending"` - `"ready"` - `"failed"` - `"deleted"` - `upload: optional object { expires_at, method, url, headers }` Where to PUT the file bytes for a presigned (JSON) upload. Issue an HTTP PUT of the raw bytes to `url` with the given `headers`, then call POST /files/{file_id}/complete. - `expires_at: string` When the presigned URL expires. - `method: string` HTTP method to use for the upload — always PUT. - `url: string` Presigned S3 URL to PUT the bytes to. - `headers: optional map[string]` Headers that must be sent with the PUT request. ### Example ```cli luma-agents-cli files create \ --auth-token 'My Auth Token' \ --mime-type x \ --size-bytes 1 ``` #### Response ```json { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "file": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "created_at": "2019-12-27T18:11:19.117Z", "mime_type": "mime_type", "purpose": "input", "size_bytes": 0, "state": "pending", "deleted_at": "2019-12-27T18:11:19.117Z", "expires_at": "2019-12-27T18:11:19.117Z", "failure_reason": "failure_reason", "filename": "filename", "user_id": "user_id" }, "state": "pending", "upload": { "expires_at": "2019-12-27T18:11:19.117Z", "method": "method", "url": "https://example.com", "headers": { "foo": "string" } } } ``` ## List files `$ luma-agents-cli files list` **get** `/files` List the files in your namespace, newest first. Keyset-paginated: when has_more is true, pass next_cursor back as cursor. ### Parameters - `--cursor: optional string` Opaque pagination cursor from a prior response's next_cursor. - `--limit: optional number` Maximum files to return (1–100). Defaults to 25. - `--purpose: optional "input" or "reference"` Filter to files with this purpose. - `--state: optional "pending" or "ready" or "failed" or "deleted"` Filter to files in this state. ### Returns - `file_list: object { data, has_more, next_cursor }` Keyset-paginated page of files, newest first. When has_more is true, pass next_cursor back as the cursor query parameter to fetch the next page. next_cursor is opaque. - `data: array of File` Files in this page. - `id: string` File identifier, referenced as ImageRef.file_id. - `created_at: string` Creation timestamp. - `mime_type: string` MIME type of the stored bytes (for example, image/jpeg). - `purpose: "input" or "reference"` How the file is intended to be used in a generation. `input` is the primary subject (e.g. the source image for an edit); `reference` is style/content guidance. - `"input"` - `"reference"` - `size_bytes: number` Size of the stored object in bytes. - `state: "pending" or "ready" or "failed" or "deleted"` Lifecycle state of an uploaded file. `pending` until bytes are received and the ingest pipeline runs; `ready` once it can be referenced from a generation; `failed` if ingest/moderation rejected it; `deleted` once the file has been deleted. - `"pending"` - `"ready"` - `"failed"` - `"deleted"` - `deleted_at: optional string` When the file was deleted; null otherwise. - `expires_at: optional string` TTL set at upload, if any. After this time Luma may automatically delete the file and reclaim its bytes — you don't need to call DELETE yourself. - `failure_reason: optional string` Human-readable reason when state is failed. - `filename: optional string` Original filename supplied at upload, if any. - `user_id: optional string` The opaque end-user tag supplied at upload, echoed back unchanged. Abuse-attribution only; not an access-control primitive. - `has_more: boolean` Whether more files exist beyond this page. - `next_cursor: optional string` Opaque cursor for the next page, when has_more is true. ### Example ```cli luma-agents-cli files list \ --auth-token 'My Auth Token' ``` #### Response ```json { "data": [ { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "created_at": "2019-12-27T18:11:19.117Z", "mime_type": "mime_type", "purpose": "input", "size_bytes": 0, "state": "pending", "deleted_at": "2019-12-27T18:11:19.117Z", "expires_at": "2019-12-27T18:11:19.117Z", "failure_reason": "failure_reason", "filename": "filename", "user_id": "user_id" } ], "has_more": true, "next_cursor": "next_cursor" } ``` ## Complete a presigned upload `$ luma-agents-cli files complete` **post** `/files/{file_id}/complete` Finalize a presigned upload after you have PUT the bytes to the upload URL. Kicks off ingest/moderation and returns the file, which transitions to `ready` (or `failed`) asynchronously — poll GET /files/{file_id} to observe the terminal state. ### Parameters - `--file-id: string` File UUID returned by POST /files. ### Returns - `file: object { id, created_at, mime_type, 8 more }` A file in the caller's namespace. - `id: string` File identifier, referenced as ImageRef.file_id. - `created_at: string` Creation timestamp. - `mime_type: string` MIME type of the stored bytes (for example, image/jpeg). - `purpose: "input" or "reference"` How the file is intended to be used in a generation. `input` is the primary subject (e.g. the source image for an edit); `reference` is style/content guidance. - `"input"` - `"reference"` - `size_bytes: number` Size of the stored object in bytes. - `state: "pending" or "ready" or "failed" or "deleted"` Lifecycle state of an uploaded file. `pending` until bytes are received and the ingest pipeline runs; `ready` once it can be referenced from a generation; `failed` if ingest/moderation rejected it; `deleted` once the file has been deleted. - `"pending"` - `"ready"` - `"failed"` - `"deleted"` - `deleted_at: optional string` When the file was deleted; null otherwise. - `expires_at: optional string` TTL set at upload, if any. After this time Luma may automatically delete the file and reclaim its bytes — you don't need to call DELETE yourself. - `failure_reason: optional string` Human-readable reason when state is failed. - `filename: optional string` Original filename supplied at upload, if any. - `user_id: optional string` The opaque end-user tag supplied at upload, echoed back unchanged. Abuse-attribution only; not an access-control primitive. ### Example ```cli luma-agents-cli files complete \ --auth-token 'My Auth Token' \ --file-id 182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e ``` #### Response ```json { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "created_at": "2019-12-27T18:11:19.117Z", "mime_type": "mime_type", "purpose": "input", "size_bytes": 0, "state": "pending", "deleted_at": "2019-12-27T18:11:19.117Z", "expires_at": "2019-12-27T18:11:19.117Z", "failure_reason": "failure_reason", "filename": "filename", "user_id": "user_id" } ``` ## Get a file `$ luma-agents-cli files get` **get** `/files/{file_id}` Retrieve metadata for a single file in your namespace. ### Parameters - `--file-id: string` File UUID. ### Returns - `file: object { id, created_at, mime_type, 8 more }` A file in the caller's namespace. - `id: string` File identifier, referenced as ImageRef.file_id. - `created_at: string` Creation timestamp. - `mime_type: string` MIME type of the stored bytes (for example, image/jpeg). - `purpose: "input" or "reference"` How the file is intended to be used in a generation. `input` is the primary subject (e.g. the source image for an edit); `reference` is style/content guidance. - `"input"` - `"reference"` - `size_bytes: number` Size of the stored object in bytes. - `state: "pending" or "ready" or "failed" or "deleted"` Lifecycle state of an uploaded file. `pending` until bytes are received and the ingest pipeline runs; `ready` once it can be referenced from a generation; `failed` if ingest/moderation rejected it; `deleted` once the file has been deleted. - `"pending"` - `"ready"` - `"failed"` - `"deleted"` - `deleted_at: optional string` When the file was deleted; null otherwise. - `expires_at: optional string` TTL set at upload, if any. After this time Luma may automatically delete the file and reclaim its bytes — you don't need to call DELETE yourself. - `failure_reason: optional string` Human-readable reason when state is failed. - `filename: optional string` Original filename supplied at upload, if any. - `user_id: optional string` The opaque end-user tag supplied at upload, echoed back unchanged. Abuse-attribution only; not an access-control primitive. ### Example ```cli luma-agents-cli files get \ --auth-token 'My Auth Token' \ --file-id 182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e ``` #### Response ```json { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "created_at": "2019-12-27T18:11:19.117Z", "mime_type": "mime_type", "purpose": "input", "size_bytes": 0, "state": "pending", "deleted_at": "2019-12-27T18:11:19.117Z", "expires_at": "2019-12-27T18:11:19.117Z", "failure_reason": "failure_reason", "filename": "filename", "user_id": "user_id" } ``` ## Delete a file `$ luma-agents-cli files delete` **delete** `/files/{file_id}` Delete a file. The file is deleted immediately and this cannot be undone through the API: it can no longer be retrieved, listed, or referenced from new generations. Where file retention is enabled for your API client, its stored bytes are then permanently deleted by a background job, not during this request, and stored bytes another live artifact still references are kept; otherwise the bytes stay stored until a Luma operator purges them. A `failed` file, or a file past its `expires_at`, can also be deleted until its stored bytes have been purged. Repeating DELETE returns 204 until the stored bytes have been purged, and 404 after that. Returns 204 with no body. ### Parameters - `--file-id: string` File UUID. ### Example ```cli luma-agents-cli files delete \ --auth-token 'My Auth Token' \ --file-id 182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e ``` ## Domain Types ### Create File Response - `create_file_response: object { id, file, state, upload }` Result of POST /files. In the multipart (inline) flow `upload` is null and the file is already `pending` ingest. In the presigned (JSON) flow `upload` carries the PUT envelope and the file stays `pending` until you call POST /files/{file_id}/complete. Top-level `id` and `state` are conveniences that mirror `file.id` and `file.state`; the full record is always under `file`. - `id: string` File identifier. - `file: object { id, created_at, mime_type, 8 more }` A file in the caller's namespace. - `id: string` File identifier, referenced as ImageRef.file_id. - `created_at: string` Creation timestamp. - `mime_type: string` MIME type of the stored bytes (for example, image/jpeg). - `purpose: "input" or "reference"` How the file is intended to be used in a generation. `input` is the primary subject (e.g. the source image for an edit); `reference` is style/content guidance. - `"input"` - `"reference"` - `size_bytes: number` Size of the stored object in bytes. - `state: "pending" or "ready" or "failed" or "deleted"` Lifecycle state of an uploaded file. `pending` until bytes are received and the ingest pipeline runs; `ready` once it can be referenced from a generation; `failed` if ingest/moderation rejected it; `deleted` once the file has been deleted. - `"pending"` - `"ready"` - `"failed"` - `"deleted"` - `deleted_at: optional string` When the file was deleted; null otherwise. - `expires_at: optional string` TTL set at upload, if any. After this time Luma may automatically delete the file and reclaim its bytes — you don't need to call DELETE yourself. - `failure_reason: optional string` Human-readable reason when state is failed. - `filename: optional string` Original filename supplied at upload, if any. - `user_id: optional string` The opaque end-user tag supplied at upload, echoed back unchanged. Abuse-attribution only; not an access-control primitive. - `state: "pending" or "ready" or "failed" or "deleted"` Lifecycle state of an uploaded file. `pending` until bytes are received and the ingest pipeline runs; `ready` once it can be referenced from a generation; `failed` if ingest/moderation rejected it; `deleted` once the file has been deleted. - `"pending"` - `"ready"` - `"failed"` - `"deleted"` - `upload: optional object { expires_at, method, url, headers }` Where to PUT the file bytes for a presigned (JSON) upload. Issue an HTTP PUT of the raw bytes to `url` with the given `headers`, then call POST /files/{file_id}/complete. - `expires_at: string` When the presigned URL expires. - `method: string` HTTP method to use for the upload — always PUT. - `url: string` Presigned S3 URL to PUT the bytes to. - `headers: optional map[string]` Headers that must be sent with the PUT request. ### File - `file: object { id, created_at, mime_type, 8 more }` A file in the caller's namespace. - `id: string` File identifier, referenced as ImageRef.file_id. - `created_at: string` Creation timestamp. - `mime_type: string` MIME type of the stored bytes (for example, image/jpeg). - `purpose: "input" or "reference"` How the file is intended to be used in a generation. `input` is the primary subject (e.g. the source image for an edit); `reference` is style/content guidance. - `"input"` - `"reference"` - `size_bytes: number` Size of the stored object in bytes. - `state: "pending" or "ready" or "failed" or "deleted"` Lifecycle state of an uploaded file. `pending` until bytes are received and the ingest pipeline runs; `ready` once it can be referenced from a generation; `failed` if ingest/moderation rejected it; `deleted` once the file has been deleted. - `"pending"` - `"ready"` - `"failed"` - `"deleted"` - `deleted_at: optional string` When the file was deleted; null otherwise. - `expires_at: optional string` TTL set at upload, if any. After this time Luma may automatically delete the file and reclaim its bytes — you don't need to call DELETE yourself. - `failure_reason: optional string` Human-readable reason when state is failed. - `filename: optional string` Original filename supplied at upload, if any. - `user_id: optional string` The opaque end-user tag supplied at upload, echoed back unchanged. Abuse-attribution only; not an access-control primitive. ### File List - `file_list: object { data, has_more, next_cursor }` Keyset-paginated page of files, newest first. When has_more is true, pass next_cursor back as the cursor query parameter to fetch the next page. next_cursor is opaque. - `data: array of File` Files in this page. - `id: string` File identifier, referenced as ImageRef.file_id. - `created_at: string` Creation timestamp. - `mime_type: string` MIME type of the stored bytes (for example, image/jpeg). - `purpose: "input" or "reference"` How the file is intended to be used in a generation. `input` is the primary subject (e.g. the source image for an edit); `reference` is style/content guidance. - `"input"` - `"reference"` - `size_bytes: number` Size of the stored object in bytes. - `state: "pending" or "ready" or "failed" or "deleted"` Lifecycle state of an uploaded file. `pending` until bytes are received and the ingest pipeline runs; `ready` once it can be referenced from a generation; `failed` if ingest/moderation rejected it; `deleted` once the file has been deleted. - `"pending"` - `"ready"` - `"failed"` - `"deleted"` - `deleted_at: optional string` When the file was deleted; null otherwise. - `expires_at: optional string` TTL set at upload, if any. After this time Luma may automatically delete the file and reclaim its bytes — you don't need to call DELETE yourself. - `failure_reason: optional string` Human-readable reason when state is failed. - `filename: optional string` Original filename supplied at upload, if any. - `user_id: optional string` The opaque end-user tag supplied at upload, echoed back unchanged. Abuse-attribution only; not an access-control primitive. - `has_more: boolean` Whether more files exist beyond this page. - `next_cursor: optional string` Opaque cursor for the next page, when has_more is true. ### File Purpose - `file_purpose: "input" or "reference"` How the file is intended to be used in a generation. `input` is the primary subject (e.g. the source image for an edit); `reference` is style/content guidance. - `"input"` - `"reference"` ### File State - `file_state: "pending" or "ready" or "failed" or "deleted"` Lifecycle state of an uploaded file. `pending` until bytes are received and the ingest pipeline runs; `ready` once it can be referenced from a generation; `failed` if ingest/moderation rejected it; `deleted` once the file has been deleted. - `"pending"` - `"ready"` - `"failed"` - `"deleted"` ### Presigned Upload - `presigned_upload: object { expires_at, method, url, headers }` Where to PUT the file bytes for a presigned (JSON) upload. Issue an HTTP PUT of the raw bytes to `url` with the given `headers`, then call POST /files/{file_id}/complete. - `expires_at: string` When the presigned URL expires. - `method: string` HTTP method to use for the upload — always PUT. - `url: string` Presigned S3 URL to PUT the bytes to. - `headers: optional map[string]` Headers that must be sent with the PUT request.