Skip to main content
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

GET /api/macro-tables
string
Returns all macro tables for the authenticated user’s active tenant, including their columns and resolved sources.

Response

macroTables
MacroTable[]
required
Array of macro table objects.
curl 'https://<domain>/api/macro-tables' \
  --cookie 'sb-access-token=<session>'

Create a macro table

POST /api/macro-tables
string
Creates a new macro table with sources and columns. At least one source and one column are required.

Request body

name
string
required
Display name. Must be unique within the tenant.
description
string
Optional description.
settings
object
Source selection settings.
sources
SourceInput[]
required
Source obra_tablas. Must contain at least one item.
columns
ColumnInput[]
required
Column definitions. Must contain at least one item.

Response

macroTable
MacroTable
required
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" }
    ]
  }'

Get a macro table

GET /api/macro-tables/{id}
string
Returns a single macro table by UUID, including fully resolved sources (with obra and tabla metadata) and columns.

Path parameters

id
string
required
UUID of the macro table.

Response

macroTable
MacroTable
required
The macro table object. In template source mode, sources include dynamically resolved obra_tablas.

Update a macro table

PATCH /api/macro-tables/{id}
string
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

id
string
required
UUID of the macro table.

Request body

name
string
New display name.
description
string
New description (empty string sets it to null).
settings
object
Updated source selection settings.
sources
SourceInput[]
Replacement source list. Replaces all existing sources.
columns
ColumnInput[]
Replacement column list. Replaces all existing columns.

Response

macroTable
MacroTable
required
The updated macro table with resolved sources and columns.

Delete a macro table

DELETE /api/macro-tables/{id}
string
Permanently deletes a macro table and all related data (sources, columns, and custom values) via cascade.

Path parameters

id
string
required
UUID of the macro table.

Response

ok
boolean
required
Always true on success.

List rows

GET /api/macro-tables/{id}/rows
string
Returns aggregated rows from all resolved source tablas, with source and custom column values mapped. Supports pagination, search, and structured filters.

Path parameters

id
string
required
UUID of the macro table.

Query parameters

page
number
default:"1"
Page number.
limit
number
default:"50"
Results per page. Clamped between 1 and 200.
q
string
Full-text search across all display columns.
obraId
string
Filter rows to only those from the obra with this UUID.
filters
string
URL-encoded JSON object of structured filters keyed by column ID.

Response

rows
MacroTableRow[]
required
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
columns
Column[]
required
Column definitions for the macro table.
pagination
object
required
curl 'https://<domain>/api/macro-tables/mt-uuid-.../rows?page=1&limit=25' \
  --cookie 'sb-access-token=<session>'

Save custom values

POST /api/macro-tables/{id}/rows
string
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

id
string
required
UUID of the macro table.

Request body

customValues
CustomValueInput[]
required
Array of custom values to upsert.

Response

ok
boolean
required
Always true on success.
updated
number
required
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"
      }
    ]
  }'

Get sidebar assignments

GET /api/macro-tables/{id}/sidebar
string
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

id
string
required
UUID of the macro table.

Response

assignments
object[]
required
Current sidebar assignments.
roles
object[]
required
All roles available for the tenant.
tenantName
string | null
required
Display name of the tenant that owns this macro table.

Set sidebar assignments

POST /api/macro-tables/{id}/sidebar
string
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

id
string
required
UUID of the macro table.

Request body

roleIds
string[]
required
Array of role UUIDs that should have this macro table visible in their sidebar.

Response

ok
boolean
required
Always true on success.
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
string
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

templates
DefaultTabla[]
required
curl 'https://<domain>/api/macro-tables/templates' \
  --cookie 'sb-access-token=<session>'

Build docs developers (and LLMs) love