Skip to content
Files, email and meetings

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.

You will need:

  • A valid API key
  • The files:create scope to create, complete, or cancel uploads
  • The files:read scope 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_KEY
Lightfield-Version: 2026-03-01
Content-Type: application/json

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.

PurposeUse for
meeting_transcriptA plain-text or Markdown transcript of at most 20 MB to attach to a meeting. See Uploading meeting recordings.
meeting_recordingAudio 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_userA file staged in the authenticated user’s personal uploads area, accessible to the chat agent. See Uploading knowledge files.
knowledge_workspaceA 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_attachmentA 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_avatarA 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".

Terminal window
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:

Terminal window
export FILE_ID="fil_abc123"
export UPLOAD_URL="https://..."

Upload the file contents directly to the returned uploadUrl.

Terminal window
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.txt

Use 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.

Knowledge uploads never overwrite an existing object. Two safeguards enforce this:

  • Timestamped filenames. POST /v1/files stamps each filename with an epoch-millisecond suffix before the extension (playbook.md → playbook_1713045600000.md, archive.tar.gz → archive.tar_1713045600000.gz). The response’s filename field returns the stored name.
  • Conditional PUT. The presigned URL for knowledge uploads is signed with IfNoneMatch: *, and the required if-none-match: * header is included in uploadHeaders. If an object already exists at the target key, S3 rejects the PUT with 412 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.

After the raw bytes have been uploaded successfully, finalize the file in Lightfield with POST /v1/files/{id}/complete.

Terminal window
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.

Check the stored metadata, or download the file to inspect its contents.

Use Retrieve a file to check the stored status, filename and byte count.

Terminal window
curl https://api.lightfield.app/v1/files/$FILE_ID \
-H "Authorization: Bearer $LIGHTFIELD_API_KEY" \
-H "Lightfield-Version: 2026-03-01"

Call Get a file download URL, then download from the returned URL before expiresAt.

Terminal window
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:

Terminal window
curl "$DOWNLOAD_URL" -o downloaded-file.txt

If the URL expires, call the file URL endpoint again.

Use Cancel a file upload if you no longer need a PENDING upload.

Terminal window
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.

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.

Terminal window
curl "https://api.lightfield.app/v1/files?limit=25&offset=0" \
-H "Authorization: Bearer $LIGHTFIELD_API_KEY" \
-H "Lightfield-Version: 2026-03-01"

Returned by any /v1/files endpoint. 400 responses include a code field; 403, 404, and 409 use the standard envelope without one.

StatusCodeMeaning
400upload_verification_failedThe 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.
400upload_url_expiredThe presigned URL has expired. Create a new upload session.
400file_emptyThe 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.
400file_too_largeAt creation, the declared size exceeds the purpose’s limit. At completion, the actual uploaded size exceeds the global limit.
400invalid_mime_typeThe file’s MIME type is not allowed for the chosen purpose. The error’s param is mimeType.
400purpose_requires_userThe chosen purpose requires a resolvable user identity. Workspace keys use their creator; see Knowledge uploads.
400limit_too_largeGET /v1/files limit exceeds the maximum allowed page size.
403n/aThe chosen purpose requires an organization admin and the current API key is not.
404n/aFile does not exist or is not accessible to the current API key.
409n/aThe 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.