Skip to main content

Data Table API

DataTableClient manages n8n data tables — tables, columns, and rows with filtering and upsert support.

This is one of the most flexible handles in the client. The row methods have typed overloads so the return type changes based on flags like returnType and returnData.

Access

const dataTable = client.dataTables();

Methods

Common Tasks

  • create tables for lightweight operational data
  • insert rows in batches
  • update rows with filters
  • upsert one logical record based on a filter
  • manage table columns separately from row data

list(params?)

List data tables.

const { data, nextCursor } = await client.dataTables().list({
limit: 10,
filter: 'name',
sortBy: 'createdAt:desc',
});

get(id)

Get a data table by ID.

const table = await client.dataTables().get('dt-123');

create(data)

Create a new data table.

const table = await client.dataTables().create({
name: 'User Events',
columns: [
{ name: 'event', type: 'string' },
{ name: 'createdAt', type: 'date' },
],
});

Column types supported at creation time: string, number, boolean, date, json. The json type is available when creating columns but may not appear in read responses from the API.

update(id, data)

Update a data table.

const updated = await client.dataTables().update('dt-123', {
name: 'User Events v2',
});

delete(id)

Delete a data table.

await client.dataTables().delete('dt-123');

Row Operations

listRows(dataTableId, params?)

List rows in a data table.

const { data, nextCursor } = await client.dataTables().listRows('dt-123', {
filter: 'event=login',
sortBy: 'timestamp:desc',
search: 'alice',
});

insertRows(dataTableId, data)

Insert rows into a data table.

const rowIds = await client.dataTables().insertRows('dt-123', {
data: [
{ event: 'login', createdAt: '2024-01-01T00:00:00Z' },
{ event: 'logout', createdAt: '2024-01-01T01:00:00Z' },
],
returnType: 'id',
});

updateRows(dataTableId, data)

Update rows matching a filter.

const updatedRows = await client.dataTables().updateRows('dt-123', {
filter: {
filters: [{ columnName: 'event', condition: 'eq', value: 'login' }],
},
data: { event: 'sign_in' },
returnData: true,
});

upsertRow(dataTableId, data)

Insert or update a single row.

const row = await client.dataTables().upsertRow('dt-123', {
filter: {
filters: [{ columnName: 'event', condition: 'eq', value: 'login' }],
},
data: { event: 'login', createdAt: '2024-01-01T00:00:00Z' },
returnData: true,
});

deleteRows(dataTableId, params)

Delete rows matching a filter.

const result = await client.dataTables().deleteRows('dt-123', {
filter: JSON.stringify({
type: 'and',
filters: [{ columnName: 'event', condition: 'eq', value: 'logout' }],
}),
returnData: true,
dryRun: false,
});

Column Operations

listColumns(dataTableId)

List columns in a data table.

const columns = await client.dataTables().listColumns('dt-123');

createColumn(dataTableId, data)

Add a column to a data table.

const column = await client.dataTables().createColumn('dt-123', {
name: 'user_id',
type: 'string',
});

updateColumn(dataTableId, columnId, data)

Update a column.

const updated = await client.dataTables().updateColumn('dt-123', 'col-1', {
name: 'user_identifier',
});

deleteColumn(dataTableId, columnId)

Delete a column.

await client.dataTables().deleteColumn('dt-123', 'col-1');

Return Type Narrowing

Some row operations change their return type based on the request flags:

const count = await client.dataTables().insertRows('dt-123', {
data: [{ event: 'login' }],
});
// { count: number }

const ids = await client.dataTables().insertRows('dt-123', {
data: [{ event: 'login' }],
returnType: 'id',
});
// number[]

DataTableResource

Use getResource(), listResources(), or createResource() to get a bound DataTableResource instance.

const resource = await client.dataTables().getResource('dt-123');
const created = await client.dataTables().createResource({
name: 'User Events',
columns: [
{ name: 'event', type: 'string' },
{ name: 'createdAt', type: 'date' },
],
});

Properties

PropertyTypeDescription
idstringData table ID
namestringData table name

Table methods

MethodReturnsDescription
refresh()thisRe-fetch the table from the API
update(data)thisUpdate the table — replaces snapshot with the API response
patch(data)thisConvenience update — merges partial fields into the current table snapshot before updating
delete()voidDelete the table

Row methods

Row methods on the resource mirror the corresponding client methods but with the table ID pre-filled.

MethodReturnsDescription
listRows(params?)DataTableRowListResponseList rows in the table
insertRows(data)overloadsInsert rows — return type depends on returnType
updateRows(data)overloadsUpdate rows matching a filter
upsertRow(data)overloadsInsert or update a single row
deleteRows(params)overloadsDelete rows matching a filter

Column methods

MethodReturnsDescription
listColumns()DataTableColumn[]List columns in the table
createColumn(data)DataTableColumnAdd a column — patches snapshot to include it
updateColumn(columnId, data)DataTableColumnUpdate a column — replaces matching entry in snapshot
deleteColumn(columnId)voidDelete a column — removes it from the snapshot

Snapshot management

refresh(), update(), and patch() call replaceSnapshot(). Column methods (createColumn, updateColumn, deleteColumn) call mergeSnapshot() to patch the columns array locally without re-fetching the full table.

Example

const table = await client.dataTables().createResource({
name: 'Events',
columns: [{ name: 'event', type: 'string' }],
});

await table.createColumn({ name: 'timestamp', type: 'date' });

const rows = await table.insertRows({
data: [{ event: 'login' }],
returnType: 'all',
});

await table.deleteColumn(table.data.columns[0].id);