How to use the StackOne Documents API and File Picker to create a Document-Aware AI Assistant with access to files and folders from users’ documents (picked from cloud storages or knowledge bases).
documents/api-reference/
.Every API endpoint can be provided as a tool within an agent through StackOne’s AI Library (nodejs, python)account.created
and documents_files.updated
events.
API Reference: Webhooks Guide
Webhook Integration Details
account.created
- Triggered when users successfully authenticate new document accountsdocuments_files.updated
- Fired when files are modified, moved, or have metadata changesdocuments_files.deleted
- Notifies when files are removed or access is revokedStrategy | When to Use | Implementation |
---|---|---|
Scheduled Sync | Batch processing, tolerance for delays | Cron jobs that re-index files periodically (hourly/daily) |
Webhook-Driven | Real-time requirements, immediate updates | React to documents_files.updated events |
Manual Sync | User-controlled updates, debugging | Admin dashboard triggers for specific accounts/files |
multiple: true
for per-user account linking.
Additional API: List Accounts to retrieve connected document provider accounts
Picker Implementation Details
onFilesPicked
callback receives different response formats depending on what was selected:folderSelectionEnabled: true
is set, users can select entire folders. The response will include folder IDs in the selection. To retrieve all files within selected folders (including nested subfolders), use the List Files API with the folder_id
parameter and nested_files: true
option to automatically fetch all nested content.onFilesPicked
is typically required for document management use cases. Other callbacks (onOpen
, onClose
, onCancel
, onError
) are optional and depend on specific user actions or error conditions.Provider | Picker Type | Navigation | Multi-Select | File Types |
---|---|---|---|---|
SharePoint | Native | Site → Drive → Folder → File | ✅ | All documents |
OneDrive | Native | Drive → Folder → File | ✅ | All documents |
Google Drive | Native | Drive → Folder → File | ✅ | All documents |
Confluence | Custom | Space → Page | ✅ | Pages/Documents |
Notion | Custom | Workspace → Page | ✅ | Pages/Blocks |
Strategy | When to Use | Implementation |
---|---|---|
Scheduled Sync | Batch processing, tolerance for delays | Cron jobs that re-index files periodically using stored file/folder IDs |
Webhook-Driven | Real-time requirements, immediate updates | React to documents_files.updated events for instant synchronization |
Manual Sync | User-controlled updates, debugging | Admin dashboard triggers for specific accounts/files |
documents_files.updated
webhooks are received
Optional: Upload File for agent-generated content
Issue | Symptoms | Solution |
---|---|---|
Authentication Errors | 401 Unauthorized responses | Refresh OAuth tokens through StackOne Connect |
File Access Denied | 403 Forbidden when accessing files | Verify user permissions in source provider |
Slow File Listings | Timeout errors when listing large folders | Implement pagination and chunked requests |
Upload Failures | Files not appearing after upload | Check provider-specific upload limits and file type restrictions |