Overview
Import complete Apple Health data exports via XML files using one of two methods:- S3 Presigned URL (Recommended) - For large files, uses direct S3 upload. The frontend handles this automatically; the scripts below are for manual or testing purposes.
- Direct Upload - For smaller files or testing, uploads directly to the API
Authentication
All endpoints require authentication via Bearer token (user login) or API key.Endpoints
Method 1: S3 Presigned URL (Recommended)
Best for large files (10MB+). Uploads directly to S3, then processes asynchronously.Step 1: Request Presigned URL
The ID of the user to import data for
Custom filename (max 200 characters)
URL expiration time in seconds (60 - 3600)
Maximum file size in bytes (1KB - 500MB). Default is 50MB.
Step 2: Upload File to S3
Use theupload_url and form_fields from the previous response to upload your XML file:
Important: When uploading to S3 with presigned POST, you must include all
form_fields as form data, and the file field must be last.Complete Example Workflow
- S3 Presigned URL (Recommended)
- Direct Upload
1
Login to Get Access Token
2
Request Presigned URL
3
Upload File to S3
4
Processing Happens Automatically
The system automatically:
- Detects the S3 upload via S3 event notification → SNS
- SNS sends an HTTPS notification to the backend
process_aws_uploadCelery task downloads and processes the XML file- Imports workouts and time series data to database
View Complete Script (Copy & Run)
View Complete Script (Copy & Run)
upload_xml_s3.py
Data Imported
Workouts
- Activity type (running, cycling, swimming, etc.)
- Duration and timestamps
- Distance, calories, elevation
- Heart rate statistics (min/max/avg)
Time Series Samples
- Heart rate
- Steps
- Active energy
- Distance
- Blood oxygen
- And 100+ other metrics
Best Practices
Use S3 for Large Files
Files over 10MB should use the presigned URL method to avoid timeouts
Handle Async Processing
Import processing is asynchronous. Don’t expect immediate data availability
Monitor Task Status
Use Celery Flower or logs to monitor processing status
Dedupe Handled Automatically
Records with the same external_id won’t be duplicated
Related
- Apple Health Setup Guide - Complete guide with export instructions
- Quick Integration - Getting started
- Error Handling - Common errors and solutions

