Macro tables aggregate rows from multiple obra_tablas across different obras into a single view. Each macro table has a set of columns (source, custom, or computed) and an optional set of source obra_tablas.
Sources can be selected in two modes:
Explicit — specific obra_tablas are linked to the macro table.
Template (sourceMode: "template") — sources are resolved dynamically based on a defaultTablaId pattern, matching tables across all obras in the tenant.
List macro tables
Returns all macro tables for the authenticated user’s active tenant, including their columns and resolved sources.
Response
Array of macro table objects. Show MacroTable properties
Display name (unique per tenant).
Source selection settings (includes sourceMode).
Number of resolved source tablas.
Column definitions. source, custom, or computed.
Field key from source rows (for source columns). Prefix obra. to reference obra fields.
Data type (text, number, date, etc.).
Column configuration (aggregation settings, computed type, etc.).
ISO 8601 creation timestamp.
ISO 8601 update timestamp.
curl 'https://<domain>/api/macro-tables' \
--cookie 'sb-access-token=<session>'
{
"macroTables" : [
{
"id" : "mt-uuid-..." ,
"tenantId" : "tenant-uuid-..." ,
"name" : "Resumen de materiales" ,
"description" : null ,
"settings" : { "sourceMode" : "explicit" },
"sourceCount" : 3 ,
"sources" : [
{ "id" : "src-uuid-..." , "macroTableId" : "mt-uuid-..." , "obraTablaId" : "ot-uuid-..." , "position" : 0 }
],
"columns" : [
{ "id" : "col-uuid-..." , "macroTableId" : "mt-uuid-..." , "columnType" : "source" , "sourceFieldKey" : "material" , "label" : "Material" , "dataType" : "text" , "position" : 0 , "config" : {} }
],
"createdAt" : "2024-05-01T00:00:00Z" ,
"updatedAt" : "2024-06-01T00:00:00Z"
}
]
}
Create a macro table
Creates a new macro table with sources and columns. At least one source and one column are required.
Request body
Display name. Must be unique within the tenant.
Source selection settings.
Source obra_tablas. Must contain at least one item. UUID of the obra_tabla to include as a source. Must belong to an obra in the tenant.
Column definitions. Must contain at least one item. source, custom, or computed.
Required for source columns. Field key from source rows or obra.<fieldName> to reference obra fields.
Response
The newly created macro table with its sources and columns.
curl -X POST 'https://<domain>/api/macro-tables' \
--cookie 'sb-access-token=<session>' \
--header 'Content-Type: application/json' \
--data '{
"name": "Resumen de materiales",
"sources": [{ "obraTablaId": "ot-uuid-..." }],
"columns": [
{ "label": "Material", "columnType": "source", "sourceFieldKey": "material", "dataType": "text" },
{ "label": "Cantidad", "columnType": "source", "sourceFieldKey": "cantidad", "dataType": "number" }
]
}'
{
"macroTable" : {
"id" : "mt-uuid-..." ,
"name" : "Resumen de materiales" ,
"sources" : [{ "id" : "src-uuid-..." , "obraTablaId" : "ot-uuid-..." , "position" : 0 }],
"columns" : [
{ "id" : "col-1-uuid" , "label" : "Material" , "columnType" : "source" , "dataType" : "text" , "position" : 0 , "config" : {} },
{ "id" : "col-2-uuid" , "label" : "Cantidad" , "columnType" : "source" , "dataType" : "number" , "position" : 1 , "config" : {} }
]
}
}
Get a macro table
GET /api/macro-tables/{id}
Returns a single macro table by UUID, including fully resolved sources (with obra and tabla metadata) and columns.
Path parameters
Response
The macro table object. In template source mode, sources include dynamically resolved obra_tablas.
Update a macro table
PATCH /api/macro-tables/{id}
Partially updates a macro table. Supplying sources or columns replaces those lists entirely (existing entries are deleted and new ones inserted). Fields not supplied are left unchanged.
When columns is supplied, existing custom values for deleted columns are also removed via cascade.
Path parameters
Request body
New description (empty string sets it to null).
Updated source selection settings.
Replacement source list. Replaces all existing sources.
Replacement column list. Replaces all existing columns.
Response
The updated macro table with resolved sources and columns.
Delete a macro table
DELETE /api/macro-tables/{id}
Permanently deletes a macro table and all related data (sources, columns, and custom values) via cascade.
Path parameters
Response
List rows
GET /api/macro-tables/{id}/rows
Returns aggregated rows from all resolved source tablas, with source and custom column values mapped. Supports pagination, search, and structured filters.
Path parameters
Query parameters
Results per page. Clamped between 1 and 200.
Full-text search across all display columns.
Filter rows to only those from the obra with this UUID.
URL-encoded JSON object of structured filters keyed by column ID.
Response
Paginated array of row objects. Each row contains:
id — UUID of the source row from obra_tabla_rows
_sourceTablaId — UUID of the source tabla
_sourceTablaName — Name of the source tabla
_obraId — UUID of the parent obra
_obraName — Name of the parent obra
One key per column ID with the resolved value
Column definitions for the macro table.
Show Pagination properties
curl 'https://<domain>/api/macro-tables/mt-uuid-.../rows?page=1&limit=25' \
--cookie 'sb-access-token=<session>'
{
"rows" : [
{
"id" : "row-uuid-..." ,
"_sourceTablaId" : "ot-uuid-..." ,
"_sourceTablaName" : "Materiales" ,
"_obraId" : "obra-uuid-..." ,
"_obraName" : "Escuela N° 42" ,
"col-1-uuid" : "Cemento Portland" ,
"col-2-uuid" : 50
}
],
"columns" : [
{ "id" : "col-1-uuid" , "label" : "Material" , "columnType" : "source" , "dataType" : "text" , "position" : 0 },
{ "id" : "col-2-uuid" , "label" : "Cantidad" , "columnType" : "source" , "dataType" : "number" , "position" : 1 }
],
"pagination" : { "page" : 1 , "limit" : 25 , "total" : 1 , "totalPages" : 1 , "hasNextPage" : false , "hasPreviousPage" : false }
}
Save custom values
POST /api/macro-tables/{id}/rows
Upserts custom column values for one or more rows. Only columns with columnType: "custom" are accepted; values for other column types are silently ignored.
Path parameters
Request body
customValues
CustomValueInput[]
required
Array of custom values to upsert. Show CustomValueInput fields
UUID of the obra_tabla_rows row this value belongs to.
UUID of the custom macro table column.
The value to store (any JSON-serializable type).
Response
Number of custom values upserted.
curl -X POST 'https://<domain>/api/macro-tables/mt-uuid-.../rows' \
--cookie 'sb-access-token=<session>' \
--header 'Content-Type: application/json' \
--data '{
"customValues": [
{
"sourceRowId": "row-uuid-...",
"columnId": "col-custom-uuid",
"value": "Aprobado"
}
]
}'
{ "ok" : true , "updated" : 1 }
Returns the role-based sidebar visibility assignments for a macro table, along with all available roles for the tenant. Requires admin or owner role (or superadmin).
Path parameters
Response
Current sidebar assignments. Show Assignment properties
UUID of the assigned role.
Display position in the sidebar.
All roles available for the tenant. Machine-readable role key.
Display name of the tenant that owns this macro table.
Replaces the sidebar role assignments for a macro table. Roles present in roleIds are added; roles previously assigned but not in the list are removed.
Path parameters
Request body
Array of role UUIDs that should have this macro table visible in their sidebar.
Response
curl -X POST 'https://<domain>/api/macro-tables/mt-uuid-.../sidebar' \
--cookie 'sb-access-token=<session>' \
--header 'Content-Type: application/json' \
--data '{ "roleIds": ["role-uuid-1", "role-uuid-2"] }'
List table templates
GET /api/macro-tables/templates
Returns the default tabla templates defined for the tenant. Templates represent reusable tabla structures that can be used as the basis for macro table source selection in template mode.
Response
Show DefaultTabla properties
UUID of the default tabla.
Number of columns defined in this template.
curl 'https://<domain>/api/macro-tables/templates' \
--cookie 'sb-access-token=<session>'
{
"templates" : [
{
"id" : "tmpl-uuid-..." ,
"name" : "Planilla de materiales" ,
"description" : "Estructura estándar para registro de materiales" ,
"sourceType" : "materials" ,
"columnCount" : 5
}
]
}