Bulk Operations
The Bulk Operations API allows administrators to perform large-scale operations such as bulk user imports, batch updates, and asynchronous job tracking. This API is designed for efficiency and handles both synchronous (small batches) and asynchronous (large batches) processing.
Overview
Key Features:
Bulk user import/update (up to 10,000 users per request)
Synchronous processing for small batches (< 100 users)
Asynchronous processing with job tracking for large batches (>= 100 users)
Job status monitoring with S3 download links
Error tracking and validation
30-day job retention with automatic cleanup
Permissions: All bulk operations require admin or super admin privileges.
User Import
Bulk Import Users
Import or update multiple users in a single request.
POST /v1/bulk/usersRequest Body:
users
array
Yes
Array of user objects (max 10,000)
options
object
No
Import options
User Object Fields:
userId
string
Conditional
User ID (required if email not provided)
string
Conditional
Email address (required if userId not provided)
customFields
object
No
Custom profile fields
metadata
object
No
Additional metadata
Import Options:
upsert
boolean
true
Update existing users or create new ones
skipDuplicates
boolean
false
Skip duplicate users instead of updating
sendWelcomeEmail
boolean
false
Send welcome email to new users
Example Request (Small Batch - Synchronous):
Example Response (Synchronous - < 100 users):
Example Request (Large Batch - Asynchronous):
Example Response (Asynchronous - >= 100 users):
Processing Modes
Synchronous Processing (< 100 users)
For small batches, the API processes users immediately and returns results synchronously:
Processes in batches of 25 (DynamoDB BatchWrite limit)
Returns complete results in the response
No job tracking required
Ideal for: Real-time imports, small data migrations
Asynchronous Processing (>= 100 users)
For large batches, the API creates a background job:
Uploads user data to S3
Creates a job record for tracking
Returns job ID immediately (202 Accepted)
Background Lambda processes the job
Poll job status endpoint for progress
Ideal for: Large imports, scheduled migrations
Job Tracking
Get Job Status
Check the status and progress of a bulk operation job.
Path Parameters:
jobId
string
Yes
Job ID from bulk operation response
Example Request:
Example Response (In Progress):
Example Response (Completed):
Job Statuses:
pending- Job created, waiting to startprocessing- Job is being processedcompleted- Job finished successfullyfailed- Job failed due to system error
Validation
User Validation Rules
Each user object is validated before processing:
Required Fields:
At least one of:
userIdoremail
Email Validation:
Must match regex:
^[^\s@]+@[^\s@]+\.[^\s@]+$
Custom Fields Validation:
Must be an object (if provided)
Cannot be a string, array, or primitive
Example Validation Errors:
Use Cases
1. Initial Data Migration
Import existing user base from another system:
2. Batch User Updates
Update custom fields for multiple users:
3. Job Status Polling
Monitor job progress:
4. CSV Import
Import users from CSV file:
Error Handling
Request Validation Errors
Empty Users Array:
Too Many Users:
Invalid JSON:
Job Errors
Job Not Found:
System Error:
Limits and Quotas
Users per request
10,000
Synchronous threshold
100 users
Batch write size (DynamoDB)
25 users
Job retention
30 days (TTL)
Download URL expiry
1 hour
Max concurrent jobs
Unlimited (queued)
Best Practices
Batch Size: Use 1,000-5,000 users per request for optimal performance
Error Handling: Always check for validation errors in the response
Job Tracking: Poll job status every 5-10 seconds for large batches
Idempotency: Include unique
userIdvalues to prevent duplicatesData Validation: Validate data before import to minimize errors
Progress Monitoring: Track
processedcount relative tototalRecordsDownload Results: Download job results within 1 hour (signed URL expiry)
Retry Logic: Implement retry logic for failed requests with exponential backoff
Performance Considerations
Synchronous Operations (< 100 users)
Processes in ~2-5 seconds
Blocks until complete
Use for: Real-time imports, small updates
Asynchronous Operations (>= 100 users)
Returns immediately with job ID
Processing time: ~1-2 seconds per 100 users
Use for: Large imports, scheduled tasks
Example Processing Times:
100 users: ~1-2 seconds (async)
500 users: ~5-10 seconds (async)
1,000 users: ~10-20 seconds (async)
10,000 users: ~1-2 minutes (async)
Data Export
When a job completes, a download URL is provided for:
Complete results with success/failure status
Detailed error messages
Row-level error tracking
Download URL Format:
Note: Download URLs expire after 1 hour for security.
Related APIs
User Profiles API - Individual user management
Audience API - Internal bulk operations
Transactions API - Bulk transaction operations
Support
For questions about the Bulk Operations API:
Documentation: https://products.monterosa.co/mic/reference
Support: [email protected]
Last updated

