Batch Write
/api/v1/tools/batch-write
Write records to multiple tables in a single transaction.
Supports:
- Batch references: Use "_ref" to label records, "@refname" to reference them
- Natural keys: Use human-readable values for foreign keys (e.g., recipe name)
- Automatic FK ordering: Tables are inserted in dependency order
- Upsert mode: Update existing records based on match columns
- Dry run: Validate without committing changes
Body Parameters
tables: map[array of map[unknown]]
Map of table_name to list of records to insert.
Returns
refs: map[string]
Map of _ref labels to their created IDs.
records: optional map[array of map[unknown]]
Created/updated records (only if return_records=True).
success: optional boolean
Whether the operation succeeded.
Batch Write
curl https://platform.labric.co//api/v1/tools/batch-write \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $LABRIC_API_KEY" \
-d '{
"tables": {
"foo": [
{
"foo": "bar"
}
]
}
}'
{
"refs": {
"foo": "string"
},
"summary": {
"foo": {
"created": 0,
"updated": 0
}
},
"plan": {
"insert_order": [
"string"
],
"operations": [
{
"foo": "bar"
}
]
},
"records": {
"foo": [
{
"foo": "bar"
}
]
},
"success": true
}
Returns Examples
{
"refs": {
"foo": "string"
},
"summary": {
"foo": {
"created": 0,
"updated": 0
}
},
"plan": {
"insert_order": [
"string"
],
"operations": [
{
"foo": "bar"
}
]
},
"records": {
"foo": [
{
"foo": "bar"
}
]
},
"success": true
}