Data stores JSON entries in named collections that belong to the agent and retrieves them by id, by a Lua Query filter, or by semantic search over an entry’s searchText. Available in tools, jobs, webhooks, triggers, processors, and workflow code steps. For one record per end user, use User instead.
Verified against lua-cli 3.33.0.
Quick example
Methods
collections()
Lists the agent’s collections with entry counts, timestamps, and the status of any declared indexes.CustomDataCollectionInfo[]
One entry per collection.
number
Number of collections.
Failed to list custom data collections.
Local runs only. The deployed runtime doesn’t expose
collections() yet and fails with Data.collections is not a function. Inspect index status from lua test.create()
Creates an entry and, whensearchText is given, indexes it for search().
string
required
Collection name, for example
movies.Record<string, any>
required
Any JSON-serializable object.
string | { searchText?: string; index?: Array<string | string[]> }
A string sets
searchText, the text search() embeds; include every term you expect queries to use. An object also accepts index: the data fields this agent filters on, each a single path ('businessId') or a compound of two paths (['country', 'businessId']). Declare indexes on every write; the platform builds them asynchronously and removes an index 14 days after its last declaration or matching filtered read. A compound index serves filters on its leftmost field alone or on both fields. Over-limit or invalid declarations are rejected and reported in collections(), never trimmed.DataEntryInstance
The stored entry. Fields of
data are readable directly (entry.title) and through entry.data.Failed to create custom data entry when the platform rejects the write.
Local runs only. The deployed runtime doesn’t accept the options object yet and fails with
searchText must be a string. In deployed code, pass searchText as a plain string.get()
Returns one page of entries that match a filter.string
required
Collection to read.
LuaQuery
Matches fields of each entry’s
data. Grammar, operators, and limits are on the Lua Query page. Omit it to page through everything.number
default:1
Page number, starting at 1.
number
default:10
Entries per page. The maximum is 100.
CustomDataEntry[]
Plain entries, not
DataEntryInstance objects: read fields through entry.data.Pagination
currentPage, totalPages, totalCount, limit, hasNextPage, hasPrevPage, nextPage (number or null), and prevPage (number or null).FILTER_* code (see Lua Query errors). A filter on an undeclared field of a large collection fails with an error that names the field and the index declaration to add.
getEntry()
Returns one entry by id.string
required
Collection to read.
string
required
The entry’s
id.DataEntryInstance.
Example
Failed to get custom data entry when no entry has that id.
update()
Merges fields into an entry and optionally replaces itssearchText.
string
required
Collection that holds the entry.
string
required
The entry’s
id.Record<string, any>
required
Fields to add or replace. Other fields are kept.
string | { searchText?: string; index?: Array<string | string[]> }
As on
create(): a string replaces searchText; an object may also refresh index declarations.string
success on a completed write.string
Human-readable result.
Failed to update custom data entry when no entry has that id or the platform rejects the write.
Local runs only. The deployed runtime doesn’t accept the options object yet and fails with
searchText must be a string. In deployed code, pass searchText as a plain string.search()
Returns the entries whosesearchText is semantically closest to a query.
string
required
Collection to search.
string
required
Natural-language query.
number
default:10
Maximum number of results. The maximum is 20.
number
default:0.6
Minimum similarity from 0 to 1. Results with a lower score are dropped.
DataEntryInstance, each with a score from 0 to 1, best match first. Not the { data, pagination } envelope that get() returns.
Example
delete()
Deletes one entry.string
required
Collection that holds the entry.
string
required
The entry’s
id.string
success on a completed delete.string
Human-readable result.
Failed to delete custom data entry when no entry has that id.
DataEntryInstance
The objectcreate(), getEntry(), and search() return. Fields of data are readable and writable directly (entry.subject) and through entry.data; direct assignments stay local until save().
string
Entry id.
string
The entry’s collection.
Record<string, any>
The stored object.
number
Similarity from 0 to 1. Set on
search() results only.update()
Merges fields into the entry on the server and locally.data.
Errors — Failed to update custom data entry, with the platform’s error as cause.
patch()
Sets and removes top-level fields, and optionally replaces or clearssearchText, in one request.
Record<string, any>
Fields to set. A
null value is stored as null.string[]
Top-level fields to remove.
string | null
A replacement
searchText, or null to clear it.data after the mutation.
Errors — Failed to patch custom data entry, with the platform’s error as cause.
unset()
Removes top-level fields; shorthand forpatch({ unset: fields }).
delete()
Deletes the entry.true.
Errors — Failed to delete custom data entry, with the platform’s error as cause.
save()
Writes the whole localdata to the server, optionally with a replacement searchText.
true.
Example
Failed to save data entry, with the platform’s error as cause.
toJSON()
Returns{ ...data, score, id, collectionName }, which is what JSON.stringify(entry) and console.log(entry) print.
Limits
Types
DataEntryInstance and LuaQuery are exported. The result shapes (CustomDataEntry, GetCustomDataResponse, CreateCustomDataOptions, CustomDataCollectionsResponse, UpdateCustomDataResponse, DeleteCustomDataResponse) are not; name them from the method that returns them.
See also
User— one persistent record per end user- Lua Query — the filter grammar
get()accepts - Store and search data — how-to
- Custom data REST API — the same collections over HTTP

