Batch Operations
Send multiple events or objects in a single request for efficient data ingestion. Ideal for ETL pipelines, historical imports, and high-volume integrations.
Batch Size Limit: Maximum 100 items per batch request. For larger imports, split your data into multiple batch calls.
Event Batch
Send multiple events in a single request. Each event in the batch is processed independently, so partial failures are possible. Each event follows the same schema as the single event endpoint, including support for object qualifiers.
Request Body
- Name
events- Type
- array
- Required
- required
- Description
- Array of event objects. Each event follows the same schema as the single event endpoint. Maximum 100 events per batch.
Request
curl -X POST 'https://api.flowmyna.com/api/public/v1/event/batch' \
-H 'Authorization: Bearer fm_live_xxx' \
-H 'Content-Type: application/json' \
-d '{
"events": [
{
"event": "Case Opened",
"timestamp": "2024-01-01T09:00:00Z",
"objects": [{"type": "Case", "id": "CASE-001"}],
"properties": {"priority": "high"}
},
{
"event": "Case Assigned",
"timestamp": "2024-01-01T09:15:00Z",
"objects": [
{"type": "Case", "id": "CASE-001"},
{"type": "Agent", "id": "AGENT-A"}
]
},
{
"event": "Case Resolved",
"timestamp": "2024-01-01T14:30:00Z",
"objects": [{"type": "Case", "id": "CASE-001"}],
"properties": {"resolution": "fixed"}
}
]
}'Response
{
"success": true,
"processed": 3,
"failed": 0,
"event_ids": [
"550e8400-e29b-41d4-a716-446655440001",
"550e8400-e29b-41d4-a716-446655440002",
"550e8400-e29b-41d4-a716-446655440003"
],
"errors": []
}Object Batch
Create or update multiple objects at once using upsert semantics. Useful for syncing data from external systems. This endpoint is idempotent — objects are created if they don't exist, or their properties are merged if they do.
Request Body
- Name
objects- Type
- array
- Required
- required
- Description
- Array of object definitions. Each object follows the same schema as the single upsert endpoint. Maximum 100 objects per batch.
Request
curl -X POST 'https://api.flowmyna.com/api/public/v1/object/batch' \
-H 'Authorization: Bearer fm_live_xxx' \
-H 'Content-Type: application/json' \
-d '{
"objects": [
{
"type": "Customer",
"id": "CUST-001",
"properties": {"name": "Alice", "tier": "gold"}
},
{
"type": "Customer",
"id": "CUST-002",
"properties": {"name": "Bob", "tier": "silver"}
},
{
"type": "Customer",
"id": "CUST-003",
"properties": {"name": "Charlie", "tier": "bronze"}
}
]
}'Response
{
"success": true,
"processed": 3,
"failed": 0,
"objects": [
{"object_id": "550e8400-e29b-41d4-a716-446655440001", "object_type": "Customer", "external_id": "CUST-001", "created": true},
{"object_id": "550e8400-e29b-41d4-a716-446655440002", "object_type": "Customer", "external_id": "CUST-002", "created": true},
{"object_id": "550e8400-e29b-41d4-a716-446655440003", "object_type": "Customer", "external_id": "CUST-003", "created": false}
],
"errors": []
}Batch Error Handling
Batch operations process items independently. If some items fail validation, others will still succeed:
Partial Failure Response
{
"success": false,
"processed": 98,
"failed": 2,
"event_ids": ["...", "..."],
"errors": [
"Event 15: Invalid timestamp format 'Jan 15 2024'",
"Event 42: Object type name exceeds 100 characters"
]
}Always check failed > 0 and inspect the errors array for details on what went wrong.
SDK Examples
Batch Operations with SDKs
from flowmyna import FlowMyna
from datetime import datetime, timedelta
client = FlowMyna(api_key="fm_live_xxx")
# Batch record events
events = []
base_time = datetime(2024, 1, 1, 9, 0, 0)
for i, case_id in enumerate(["CASE-001", "CASE-002", "CASE-003"]):
events.append({
"event": "Case Opened",
"timestamp": (base_time + timedelta(hours=i)).isoformat() + "Z",
"objects": [{"type": "Case", "id": case_id}],
"properties": {"source": "email"}
})
result = client.record_event_batch(events)
print(f"Processed: {result.processed}, Failed: {result.failed}")
# Batch upsert objects
customers = [
{"type": "Customer", "id": f"CUST-{i:03d}", "properties": {"index": i}}
for i in range(100)
]
result = client.upsert_object_batch(customers)
print(f"Upserted {result.processed} customers")Best Practices
- Prefer batching — 1 request with 50 events beats 50 requests with 1 event
- Stay under the limit — Split large imports into chunks of 100
- Handle partial failures — Log errors and retry failed items
- Order matters for history — Send events in chronological order within a batch