- Overview
- Platform setup and administration
- Platform setup and administration
- Platform architecture
- Data Bridge onboarding overview
- Connecting a Peak-managed data lake
- Connecting a customer-managed data lake
- Creating an AWS IAM role for Data Bridge
- Connecting a Snowflake data warehouse
- Connecting a Redshift data warehouse (public connectivity)
- Connecting a Redshift data warehouse (private connectivity)
- Reauthorizing a Snowflake OAuth connection
- Using Snowflake with Peak
- SQL Explorer overview
- Roles and permissions
- User management
- Inventory management solution
- Commercial pricing solution
- Merchandising solution

Supply Chain & Retail Solutions user guide
Uploading files via command line with signed URLs
Use command-line tools like curl and PowerShell to upload files to Peak via signed URLs. This approach is useful for quick uploads or integrating file uploads into shell scripts and automated workflows.
Prerequisites
Before uploading files via command line, ensure you have the following:
- You have
curlinstalled (available by default on Linux, macOS, and Windows 10+). - You have a tenant API key.
- You have the file ready for upload on your local machine.
Steps using curl
Use curl to generate a signed URL, then upload your file.
- Open a terminal or command prompt.
- Navigate to the directory containing your file.
- Generate a signed URL:
curl -X POST "https://api.peak.ai/file/signedurl/client" \ -H "Content-Type: application/json" \ -H "Authorization: YOUR_TENANT_API_KEY" \ -d '{"fileName":"salesrecords20180627121537.csv"}'curl -X POST "https://api.peak.ai/file/signedurl/client" \ -H "Content-Type: application/json" \ -H "Authorization: YOUR_TENANT_API_KEY" \ -d '{"fileName":"salesrecords20180627121537.csv"}' - Copy the signed URL returned in the response body.
- Signed URLs are valid for 900 seconds (15 minutes). Generate a new URL if the current one expires.
- Upload the file using a
PUTrequest:curl -X PUT -H "Content-Type: text/csv" --data-binary "@your-file.csv" "YOUR_SIGNED_URL_HERE"curl -X PUT -H "Content-Type: text/csv" --data-binary "@your-file.csv" "YOUR_SIGNED_URL_HERE" - Verify the response:
- A successful upload returns a 200 status code.
- If you see errors, check the response message for details.
The fileName value in the signed URL request must follow supported naming and extension rules. For details, see File formats and naming conventions.
Steps using PowerShell (Windows)
Use PowerShell to generate a signed URL, then upload your file.
- Open PowerShell.
- Navigate to the directory containing your file.
- Generate a signed URL:
$headers = @{ "Content-Type" = "application/json" "Authorization" = "YOUR_TENANT_API_KEY" } $body = @{ fileName = "your-file.csv" } | ConvertTo-Json $signedUrlResponse = Invoke-RestMethod -Uri "https://api.peak.ai/file/signedurl/client" -Method POST -Headers $headers -Body $body $signedUrl = $signedUrlResponse.Trim('"')$headers = @{ "Content-Type" = "application/json" "Authorization" = "YOUR_TENANT_API_KEY" } $body = @{ fileName = "your-file.csv" } | ConvertTo-Json $signedUrlResponse = Invoke-RestMethod -Uri "https://api.peak.ai/file/signedurl/client" -Method POST -Headers $headers -Body $body $signedUrl = $signedUrlResponse.Trim('"') - Upload the file:
$headers = @{"Content-Type" = "text/csv"} $response = Invoke-WebRequest -Uri $signedUrl -Method PUT -InFile "your-file.csv" -Headers $headers Write-Host "Status Code: $($response.StatusCode)"$headers = @{"Content-Type" = "text/csv"} $response = Invoke-WebRequest -Uri $signedUrl -Method PUT -InFile "your-file.csv" -Headers $headers Write-Host "Status Code: $($response.StatusCode)"
Result
Your file uploads to Peak's file storage. The terminal outputs the HTTP status code. A 200 status code indicates successful upload. The file becomes available for processing according to your configured data feeds and triggers.
Example with verbose output
To see detailed upload progress and response headers:
curl -X PUT -H "Content-Type: text/csv" --data-binary "@your-file.csv" "YOUR_SIGNED_URL_HERE" -v
curl -X PUT -H "Content-Type: text/csv" --data-binary "@your-file.csv" "YOUR_SIGNED_URL_HERE" -v
The -v flag provides verbose output including:
- Connection details
- Request headers sent
- Response headers received
- Upload progress
Automating uploads with shell scripts
Create a reusable shell script to automate file uploads:
#!/bin/bash
# upload_to_peak.sh
SIGNED_URL="$1"
FILE_PATH="$2"
if [ -z "$SIGNED_URL" ] || [ -z "$FILE_PATH" ]; then
echo "Usage: ./upload_to_peak.sh <signed_url> <file_path>"
exit 1
fi
if [ ! -f "$FILE_PATH" ]; then
echo "Error: File not found: $FILE_PATH"
exit 1
fi
echo "Uploading $FILE_PATH..."
RESPONSE=$(curl -X PUT -H "Content-Type: text/csv" --data-binary "@$FILE_PATH" "$SIGNED_URL" -w "%{http_code}" -o /dev/null -s)
if [ "$RESPONSE" -eq 200 ]; then
echo "✓ Upload successful"
exit 0
else
echo "✗ Upload failed with status code: $RESPONSE"
exit 1
fi
#!/bin/bash
# upload_to_peak.sh
SIGNED_URL="$1"
FILE_PATH="$2"
if [ -z "$SIGNED_URL" ] || [ -z "$FILE_PATH" ]; then
echo "Usage: ./upload_to_peak.sh <signed_url> <file_path>"
exit 1
fi
if [ ! -f "$FILE_PATH" ]; then
echo "Error: File not found: $FILE_PATH"
exit 1
fi
echo "Uploading $FILE_PATH..."
RESPONSE=$(curl -X PUT -H "Content-Type: text/csv" --data-binary "@$FILE_PATH" "$SIGNED_URL" -w "%{http_code}" -o /dev/null -s)
if [ "$RESPONSE" -eq 200 ]; then
echo "✓ Upload successful"
exit 0
else
echo "✗ Upload failed with status code: $RESPONSE"
exit 1
fi
Make the script executable and use it:
chmod +x upload_to_peak.sh
./upload_to_peak.sh "YOUR_SIGNED_URL" "your-file.csv"
chmod +x upload_to_peak.sh
./upload_to_peak.sh "YOUR_SIGNED_URL" "your-file.csv"
Troubleshooting
If you encounter errors during upload, refer to the following common issues and solutions:
- 401 Unauthorized - Verify that the
Authorizationheader contains a valid tenant API key when generating the signed URL. - 403 Forbidden - The signed URL may have expired. Request a new signed URL.
- 400 Bad Request (invalid file extension) - Use a supported extension such as
.gz,.csv,.txt,.json, or.xml. - 400 Bad Request (invalid filename) - Verify that the file name follows Peak naming rules.
- HTTP/1.1 100 Continue - This can appear while the file is still uploading. Wait for the final response status.
- curl: command not found - Install curl or use PowerShell on Windows.
- Failed to open file - Check that the file path is correct and you have read permissions.