Skip to main content
This recipe shows how to upload files directly to the Gloo AI Data Engine using the Upload Files API. You’ll learn to upload single files, batch multiple files, associate custom IDs, and add metadata to your content. Upload once. Search instantly. Build faster. The Upload Files API lets you send any file directly to Gloo for real-time processing and indexing. Within minutes, your content becomes searchable, context-aware, and ready for AI-driven interactions.

Prerequisites

Before starting, ensure you have:
The Upload Files API requires an API key for authentication. If you haven’t set up authentication yet, follow the Authentication Tutorial.

Understanding the Upload Files API

The Upload Files API allows you to upload documents that get processed and made available for search and AI interaction. The primary endpoint is: POST /ingestion/v2/files

Key Features

  • Direct File Upload: Send files via multipart/form-data
  • Multi-File Support: Upload multiple files in a single request
  • Automatic Processing: Files are parsed, indexed, and made searchable
  • Format Detection: Automatic detection and processing of various file types
  • Duplicate Detection: Identifies and reports duplicate content

Required Fields

The Upload Files API requires two form fields:
  • publisher_id: Your publisher ID from Gloo AI Studio
  • files: The file(s) to upload (use the field name files, not file)

Supported File Types

  • PDF documents
  • Microsoft Word (.doc, .docx)
  • Plain text (.txt)
  • Markdown (.md)
  • And more

Step 1: Basic Single File Upload

Let’s start with uploading a single file. This demonstrates the core API call with proper authentication.

Expected Response


Step 2: Multi-File Upload

You can upload multiple files in a single request for better efficiency.
You can mix file types freely - the endpoint automatically detects and processes each format.

Expected Response


Step 3: Using Producer ID

The producer_id query parameter lets you associate your internal ID with an uploaded file. This is useful for tracking and updating content from your system.
If the producer_id field is supplied with a multi-file upload, the ID will be ignored. Producer IDs must have a one-to-one relationship with a file.

Step 4: Adding Metadata to Uploaded Content

After uploading files, you can add or update metadata using the Update Item Metadata endpoint. Identify content by either Gloo’s item_id (returned from the upload) or your producer_id.
Only the fields you include are updated; omitted fields remain unchanged.

Available Metadata Fields

If you provide both item_id and producer_id, the service will prefer item_id when loading the target item. This allows for the producer_id to be updated.

Step 5: Verifying Your Upload

After uploading content, you can verify it in Gloo AI Studio:
  1. Log in to Gloo AI Studio
  2. Navigate to the Data Engine section from the main sidebar
  3. Click on Your Data
You’ll see your uploaded files with their processing status and metadata.

Complete Example

Here’s a complete example that combines authentication, file upload, and metadata update:

Troubleshooting

Error: 401 Unauthorized

Cause: API key is incorrect or has been revoked. Solution: Verify your API key is correct and has not been revoked.

Error: 403 Forbidden

Cause: Insufficient permissions for the publisher. Solution: Verify you have access to the specified publisher in Gloo AI Studio.

Error: 413 Request Entity Too Large

Cause: File size exceeds the limit. Solution: Check the API limits and consider splitting large files.

Error: Duplicate detected

Cause: A file with identical content already exists. Solution: This is informational - the file won’t be processed again. Check the duplicates array in the response.

Working Code Sample

View Complete Code

Clone or browse the complete working examples for all 6 languages (JavaScript, TypeScript, Python, PHP, Go, Java) with setup instructions.

Next Steps

Now that you can upload files to the Data Engine, explore:
  1. Search API - Query your uploaded content
  2. Chat Integration - Use uploaded content in conversations
  3. Manage Content - Manage and update your content
  4. Upload Files API - For additional API information
  5. Update Item Metadata API - For additional API information