Upload mobile builds or web app URLs programmatically via the API
These endpoints allow you to upload mobile app builds or web app URLs programmatically. For most use cases, we recommend using our GitHub Action instead.All requests require an API key in the X-API-Key header. See API Reference for authentication details.
Environment name to associate this app with (e.g., staging, production). Apps with the same bundle ID but different environments are treated as separate apps. Must match an existing environment in your organization. If omitted, the app is assigned to your default environment.
Key-value variables to attach to this build. Available in flow instructions via ${env:KEY}. Accepts a string ("KEY1=VALUE1,KEY2=VALUE2") or a JSON object ({"KEY1": "VALUE1"}). See Build Variables.
If you use Expo EAS, you can upload to Autosana directly from an EAS build hook instead of using the GitHub Action. This avoids keeping a GitHub Actions runner idle while waiting for the EAS build to finish, saving CI minutes.
EAS build hook script and setup
Create an eas-build-on-success.sh file in your project root (next to package.json). EAS automatically runs this script when a build completes successfully.
Replace com.example.myapp with your bundle ID, MyApp.app with your .app bundle name, and "My App" with your app’s display name.
eas-build-on-success.sh
Copy
Ask AI
#!/usr/bin/env bashset -euo pipefailupload_to_autosana() { if [[ -z "${AUTOSANA_API_KEY:-}" ]]; then echo "AUTOSANA_API_KEY is not set, skipping upload." return 0 fi local platform="$EAS_BUILD_PLATFORM" local commit_sha="${EAS_BUILD_GIT_COMMIT_HASH:-unknown}" local bundle_id="com.example.myapp" local app_name="My App" if [[ "$platform" == "ios" ]]; then local app_path app_path=$(find . -name "MyApp.app" -type d 2>/dev/null | head -1) if [[ -z "$app_path" ]]; then echo "Error: Could not find .app bundle" return 1 fi local filename="app-simulator.zip" local artifact="/tmp/${filename}" pushd "$(dirname "$app_path")" zip -r "$artifact" "$(basename "$app_path")" popd elif [[ "$platform" == "android" ]]; then local artifact artifact=$(find . -name "*.apk" -type f 2>/dev/null | head -1) if [[ -z "$artifact" ]]; then echo "Error: Could not find .apk file" return 1 fi local filename=$(basename "$artifact") else echo "Unsupported platform: $platform" return 1 fi local start_response start_response=$(curl -sf -X POST https://backend.autosana.ai/api/ci/start-upload \ -H "X-API-Key: $AUTOSANA_API_KEY" \ -H "Content-Type: application/json" \ -d "{ \"bundle_id\": \"$bundle_id\", \"platform\": \"$platform\", \"filename\": \"$filename\" }") local upload_url file_path upload_url=$(echo "$start_response" | jq -r '.upload_url') file_path=$(echo "$start_response" | jq -r '.file_path') if [[ -z "$upload_url" || "$upload_url" == "null" ]]; then echo "Error: Failed to get presigned URL" echo "Response: $start_response" return 1 fi if ! curl -sf -X PUT "$upload_url" \ -H "Content-Type: application/octet-stream" \ --data-binary "@$artifact"; then echo "Error: Failed to upload file to presigned URL" return 1 fi if ! curl -sf -X POST https://backend.autosana.ai/api/ci/confirm-upload \ -H "X-API-Key: $AUTOSANA_API_KEY" \ -H "Content-Type: application/json" \ -d "{ \"bundle_id\": \"$bundle_id\", \"platform\": \"$platform\", \"uploaded_file_path\": \"$file_path\", \"name\": \"$app_name\", \"commit_sha\": \"$commit_sha\" }"; then echo "Error: Failed to confirm upload" return 1 fi echo "Uploaded to Autosana successfully"}upload_to_autosana || echo "Warning: Autosana upload failed, continuing..."
Make the script executable and commit it to your repo:
Copy
Ask AI
chmod +x eas-build-on-success.sh
Then add your API key as an EAS secret:
Copy
Ask AI
eas secret:create --name AUTOSANA_API_KEY --value your-api-key-here --scope project
When you trigger a build (eas build --platform ios --profile preview-simulator --non-interactive), EAS runs the hook automatically after the build succeeds — no --wait flag or GitHub runner required.
Unique identifier for your web app. Must be lowercase alphanumeric with hyphens only (e.g., my-web-app). This identifier is used to track your web app across deployments.
Environment name to associate this app with (e.g., staging, production). Apps with the same app ID but different environments are treated as separate apps. Must match an existing environment in your organization. If omitted, the app is assigned to your default environment.
Key-value variables to attach to this build. Available in flow instructions via ${env:KEY}. Accepts a string ("KEY1=VALUE1,KEY2=VALUE2") or a JSON object ({"KEY1": "VALUE1"}). See Build Variables.