Skip to content
Files, email and meetings

Uploading knowledge files

Upload files to the chat agent's uploads area so you can promote them into your knowledge base.

Stage files for the Lightfield chat agent using the file upload lifecycle.

A knowledge_user or knowledge_workspace upload stages a file for the agent. Completing the upload does not add it to Knowledge, and no API call promotes it. After completion, follow Files uploaded through the API to choose its audience and ask the agent to promote it.

You will need:

  • A valid API key whose caller resolves to a specific user
  • The files:create scope to create and complete uploads
  • The files:read scope if you want to verify the uploaded file or fetch a signed download URL
  • For knowledge_workspace: the caller must be an org admin

Choose the purpose that matches who the file is for.

PurposeWhere the file landsWho can upload
knowledge_userThe authenticated user’s personal uploads areaAny caller with a resolvable user identity
knowledge_workspaceThe organization’s shared uploads areaOrg admins only

Non-admin callers that request knowledge_workspace are rejected with 403.

Knowledge uploads use the three-step upload lifecycle:

  1. POST /v1/files
  2. PUT <uploadUrl>
  3. POST /v1/files/{id}/complete

For knowledge uploads, set the purpose, keep the timestamped filename returned in the response, and send the if-none-match: * header from uploadHeaders. See Collision handling in the file upload guide for details.

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": "knowledge_user",
"filename": "playbook.md",
"mimeType": "text/markdown",
"sizeBytes": 4821
}'

Replace sizeBytes with the byte count of your actual playbook.md file. This response excerpt shows the fields needed for the upload:

{
"id": "fil_abc123",
"filename": "playbook_1713045600000.md",
"status": "PENDING",
"uploadUrl": "https://...",
"uploadHeaders": {
"content-type": "text/markdown",
"if-none-match": "*"
},
"expiresAt": "2026-04-08T12:00:00.000Z"
}

The server adds a timestamp to the stored filename. Use the returned filename when referring to the file in chat.

Follow Upload the raw bytes using every header in uploadHeaders, including if-none-match: *. Do not replace those headers with your Lightfield API credentials.

Follow Complete the upload. Once the file is COMPLETED, the agent can read it from the uploads area. Ask the agent to promote the file before using it as Knowledge.

StatusCodeMeaning
400purpose_requires_userThe API key has no resolvable user identity. Use a key whose user or creator is still active in the workspace.
403—knowledge_workspace was requested by a non-admin caller.
412(S3 response)The presigned PUT’s if-none-match: * precondition failed. Create a new upload session to get a fresh timestamped key.

See Errors for general error handling.

  • Uploading files: reference guide for the underlying file upload lifecycle.
  • API keys: authenticate requests and handle invalid keys.
  • API Reference: full endpoint reference for files and other resources.