POST /upload
Upload Pricing2Yaml configuration files to make them available for analysis via the chat endpoint. Uploaded files are stored in the static directory and can be referenced in subsequent queries.Endpoint
Request
This endpoint expects a multipart form data request with a file upload.YAML file containing Pricing2Yaml configurationContent-Type: Must be
application/yaml or application/x-yamlFile Extension: .yaml or .ymlResponse
Status Code:201 Created
The name of the uploaded file
The relative path where the file can be accessed (e.g.,
/static/overleaf-2023.yaml)Examples
Upload with cURL
Upload with Python
Upload with JavaScript
Response Example
Error Responses
400 Bad Request - Invalid Content Type
400 Bad Request - Missing File
Sample Pricing2Yaml File
Here’s an example of a valid Pricing2Yaml file structure:overleaf-2023.yaml
Using Uploaded Files
After uploading a file, you can reference it in chat queries:Option 1: Automatic Reference (Single Upload)
If only one file has been uploaded, H.A.R.V.E.Y. automatically uses it:Option 2: Explicit YAML Content
Pass the YAML content directly in the chat request:Option 3: Static File Reference
Access the uploaded file directly via the static files endpoint:File Management
Uploaded files are:- Stored in the directory specified by
HARVEY_STATIC_DIRenvironment variable - Tracked in an in-memory pricing context database
- Associated with a unique identifier (filename without extension)
- Accessible via the static files endpoint at
/static/{filename}
Deleting Uploaded Files
To remove an uploaded file:204 No Content (success) or 404 Not Found
Best Practices
Validate Before Upload
Ensure your Pricing2Yaml file follows the correct schema. Use the
/chat endpoint with a validation query after upload.Descriptive Filenames
Use clear, descriptive filenames like
github-2024.yaml or slack-enterprise.yaml for easy identification.Version Control
Include version information in the YAML file’s
version field to track changes over time.Test Uploads
After uploading, test with a simple query like “Summarize this pricing” to confirm the file is accessible.
Limitations
- Only YAML files are accepted (MIME type:
application/yamlorapplication/x-yaml) - File size limits depend on your FastAPI configuration
- Files are stored in memory and on disk; large numbers of uploads may impact performance
- No authentication/authorization is required (consider adding in production)
- Uploaded files persist until explicitly deleted or the service restarts
Related Endpoints
Chat Endpoint
Use uploaded files in pricing queries
Pricing2Yaml Spec
Learn about the Pricing2Yaml format
Implementation Reference
The upload functionality is implemented in:harvey_api/src/harvey_api/app.py:155(upload endpoint)harvey_api/src/harvey_api/file_manager.py:8(file storage)harvey_api/src/harvey_api/pricing_context.py(context tracking)