Uploading files
Upload a file to Lightfield using the file upload lifecycle.
To upload a file to Lightfield, create an upload session, send the file bytes to its upload URL, then complete the upload.
Before you begin
Section titled “Before you begin”You will need:
- A valid API key
- The
files:createscope to create, complete, or cancel uploads - The
files:readscope if you want to verify the uploaded file or fetch a signed download URL
All Lightfield API calls in this flow use these headers:
Authorization: Bearer $LIGHTFIELD_API_KEYLightfield-Version: 2026-03-01Content-Type: application/jsonStep 1: Create an upload session
Section titled “Step 1: Create an upload session”Create a pending file upload with POST /v1/files.
Choose a purpose that matches how you will use the file. Each purpose has its own MIME type and size limits and determines where the file is stored.
| Purpose | Use for |
|---|---|
meeting_transcript | A plain-text or Markdown transcript of at most 20 MB to attach to a meeting. See Uploading meeting recordings. |
meeting_recording | Audio or video of at most 512 MB for a meeting’s uploaded transcript. Until it’s attached, only its uploader can read it. See Uploading meeting recordings. |
knowledge_user | A file staged in the authenticated user’s personal uploads area, accessible to the chat agent. See Uploading knowledge files. |
knowledge_workspace | A file staged in the organization’s shared uploads area, accessible to the chat agent. Requires the caller to be an org admin. See Uploading knowledge files. |
email_attachment | A file to attach to an email send or draft. Upload cap: 20 MB per file; Gmail allows 20 MB combined per message and Outlook allows 3 MB per attachment. See Emails and attachments. |
contact_avatar | A PNG, JPEG, WebP or GIF image of at most 8 MB to set as a contact’s photo. See Uploading contact avatars. |
This example uploads a text file with purpose: "meeting_transcript".
curl https://api.lightfield.app/v1/files \ -X POST \ -H "Authorization: Bearer $LIGHTFIELD_API_KEY" \ -H "Lightfield-Version: 2026-03-01" \ -H "Content-Type: application/json" \ -d '{ "purpose": "meeting_transcript", "filename": "manual-upload-check.txt", "mimeType": "text/plain", "sizeBytes": 29 }'This response excerpt shows the upload session fields used below:
{ "id": "fil_abc123", "filename": "manual-upload-check.txt", "status": "PENDING", "uploadUrl": "https://...", "uploadHeaders": { "content-type": "text/plain" }, "expiresAt": "2026-04-08T12:00:00.000Z"}Set FILE_ID to the returned id and UPLOAD_URL to uploadUrl. Save filename and all of uploadHeaders for the next steps. Replace the example values below with your session’s values:
export FILE_ID="fil_abc123"export UPLOAD_URL="https://..."Step 2: Upload the raw bytes
Section titled “Step 2: Upload the raw bytes”Upload the file contents directly to the returned uploadUrl.
printf 'hello from Lightfield upload\n' > /tmp/manual-upload-check.txt
curl -i -X PUT "$UPLOAD_URL" \ -H "content-type: text/plain" \ --data-binary @/tmp/manual-upload-check.txtUse the exact headers returned in uploadHeaders. The example only shows content-type, but your upload session may include additional required headers. For knowledge uploads, uploadHeaders will also contain if-none-match: *, and you must pass it on the PUT. Depending on the storage backend, the upload typically returns 200, 201, or 204.
Collision handling
Section titled “Collision handling”Knowledge uploads never overwrite an existing object. Two safeguards enforce this:
- Timestamped filenames.
POST /v1/filesstamps each filename with an epoch-millisecond suffix before the extension (playbook.md→playbook_1713045600000.md,archive.tar.gz→archive.tar_1713045600000.gz). The response’sfilenamefield returns the stored name. - Conditional PUT. The presigned URL for knowledge uploads is signed with
IfNoneMatch: *, and the requiredif-none-match: *header is included inuploadHeaders. If an object already exists at the target key, S3 rejects the PUT with412 Precondition Failed. The signed-headers policy means clients cannot strip the header without invalidating the signature.
There is no overwrite field on the create request. To replace an uploaded file, upload it again. The new timestamped name will land alongside the previous one.
Step 3: Complete the upload
Section titled “Step 3: Complete the upload”After the raw bytes have been uploaded successfully, finalize the file in Lightfield with POST /v1/files/{id}/complete.
curl https://api.lightfield.app/v1/files/$FILE_ID/complete \ -X POST \ -H "Authorization: Bearer $LIGHTFIELD_API_KEY" \ -H "Lightfield-Version: 2026-03-01" \ -H "Content-Type: application/json" \ -d '{}'You can include an MD5 checksum of the uploaded bytes. For the 29-byte file created above, use:
{ "md5": "88ea9abfae31e00a9cf4b09554f929f4"}Check that the completion response has status: "COMPLETED" before using the file ID. After a timeout or 409, retrieve the file and check its status before retrying completion.
Verify the upload
Section titled “Verify the upload”Check the stored metadata, or download the file to inspect its contents.
Read the file metadata
Section titled “Read the file metadata”Use Retrieve a file to check the stored status, filename and byte count.
curl https://api.lightfield.app/v1/files/$FILE_ID \ -H "Authorization: Bearer $LIGHTFIELD_API_KEY" \ -H "Lightfield-Version: 2026-03-01"Get a temporary download URL
Section titled “Get a temporary download URL”Call Get a file download URL, then download from the returned URL before expiresAt.
curl https://api.lightfield.app/v1/files/$FILE_ID/url \ -H "Authorization: Bearer $LIGHTFIELD_API_KEY" \ -H "Lightfield-Version: 2026-03-01"Set DOWNLOAD_URL to the response’s url, then fetch the bytes without Lightfield authentication headers:
curl "$DOWNLOAD_URL" -o downloaded-file.txtIf the URL expires, call the file URL endpoint again.
Cancel a pending upload
Section titled “Cancel a pending upload”Use Cancel a file upload if you no longer need a PENDING upload.
curl https://api.lightfield.app/v1/files/$FILE_ID/cancel \ -X POST \ -H "Authorization: Bearer $LIGHTFIELD_API_KEY" \ -H "Lightfield-Version: 2026-03-01"Check that the response has status: "CANCELLED". Only pending uploads can be cancelled.
Find an existing upload
Section titled “Find an existing upload”Use List files to find uploads visible to your key. Read data for the returned files and use each file’s id for retrieval. Retrieve a file by its ID when you need to check its current status.
curl "https://api.lightfield.app/v1/files?limit=25&offset=0" \ -H "Authorization: Bearer $LIGHTFIELD_API_KEY" \ -H "Lightfield-Version: 2026-03-01"Common errors
Section titled “Common errors”Returned by any /v1/files endpoint. 400 responses include a code field; 403, 404, and 409 use the standard envelope without one.
| Status | Code | Meaning |
|---|---|---|
400 | upload_verification_failed | The bytes are missing or the MD5 checksum did not match. Upload missing bytes while the URL is valid, or correct the checksum and retry completion. To replace bytes already stored by a knowledge upload, create a new session; its conditional PUT prevents overwrites. |
400 | upload_url_expired | The presigned URL has expired. Create a new upload session. |
400 | file_empty | The uploaded object is empty. Upload a non-empty file before completing it. For knowledge uploads, create a new session because the conditional PUT prevents replacing existing bytes. |
400 | file_too_large | At creation, the declared size exceeds the purpose’s limit. At completion, the actual uploaded size exceeds the global limit. |
400 | invalid_mime_type | The file’s MIME type is not allowed for the chosen purpose. The error’s param is mimeType. |
400 | purpose_requires_user | The chosen purpose requires a resolvable user identity. Workspace keys use their creator; see Knowledge uploads. |
400 | limit_too_large | GET /v1/files limit exceeds the maximum allowed page size. |
403 | n/a | The chosen purpose requires an organization admin and the current API key is not. |
404 | n/a | File does not exist or is not accessible to the current API key. |
409 | n/a | The file is in a state that does not allow the requested action, for example calling /complete on a canceled file, calling /cancel on a non-PENDING file, or downloading a file whose upload never completed. Repeating /complete after successful completion returns the completed file. |
See Errors for the standard error envelope.
Next steps
Section titled “Next steps”- Uploading meeting recordings: upload a transcript, with its audio or video, and attach it to a meeting.
- Uploading knowledge files: stage files for the chat agent to promote into your knowledge base.
- Uploading contact avatars: upload an image and set it as a contact’s photo.
- API Reference: full endpoint reference for files, meetings, and other resources.
- Errors: learn how to handle 4xx and 5xx responses.
Related documentation
Section titled “Related documentation”- In the app: Files and attachments explains where uploads belong. Chat, email and transcript upload paths have different limits.
- Endpoint contracts: create, complete and download URL.