Update unstructured data
This API is used to update unstructured data by re-uploading a file. When you need to refresh or replace the content of existing unstructured data, this endpoint allows you to upload a new file that will replace the existing data. The unstructured data's metadata and configuration are preserved while the underlying data source is updated.
info
Obtain the authorization token needed to execute the request using POST /api/auth/login.
Update an unstructured data
Endpoint: PUT /api/nuggets/{id}
Request Parameters:
| Name | Located in | Description | Required | Type |
|---|---|---|---|---|
| id | path | ID of the unstructured data | Yes | string |
| X-MSTR-AuthToken | header | Authentication token | Yes | string |
| fileName | form-data | Name of the file being uploaded | No | string |
| fileLocation | form-data | Location of the file | No | string |
| fileType | form-data | Type of the file | No | string |
| fileSize | form-data | Size of the file in bytes | No | integer |
| file | form-data | The file to upload | Yes | binary |
Sample Curl:
# Replace with your actual values
curl -X PUT 'https://demo.microstrategy.com/MicroStrategyLibrary/api/nuggets/4B7EF8B549D2D32E941C3E9B7E0CD754' \
-H 'X-MSTR-AuthToken: pqu5mkrcbv4461hh5qprr9j5ve' \
-F 'file=@/path/to/your/document.pdf' \
-F 'fileName=document.pdf' \
-F 'fileType=application/pdf' \
-F 'fileSize=1024000'
Sample Response:
HTTP Status: 202 Accepted
{
"id": "4B7EF8B549D2D32E941C3E9B7E0CD754",
"status": "processing"
}
Notes:
- This API returns a 202 Accepted response, indicating that the file upload has been accepted and will be processed asynchronously.
- The unstructured data status will update to "Unloaded" initially and then processed in the background.
- You can check the processing status of the unstructured data using a separate status endpoint.
- The file should be uploaded as multipart/form-data.
Use Cases
Content Refresh:
The main use case for this API is to update existing unstructured data with fresh data:
- Document Updates: When a document that serves as a knowledge source has been updated, you can use this API to replace the old version with the new one while maintaining the same unstructured data ID and configuration.
- Data Refresh: For regularly updated datasets, you can schedule automated updates to ensure the AI agent always works with the latest information.
- Content Correction: If errors are found in the original uploaded content, you can quickly replace it with a corrected version without needing to reconfigure the agent.
Example implementation:
- Monitor source documents for changes using file system watchers or scheduled checks.
- When changes are detected, call this API to upload the updated file.
- Optionally implement a versioning system to track updates and allow rollbacks, if needed.
- Set up monitoring to track the processing status after upload and handle any errors.
Best Practices:
- Ensure the new file is compatible with the original file type to avoid processing errors.
- Consider implementing validation checks before uploading to verify file integrity.
- Keep track of upload timestamps and versions for audit purposes.
- Handle the asynchronous nature of the API by implementing proper status checking mechanisms.