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.
Available in deployed agents and in
lua test. Until September 27, 2026 the deployed runtime lacked collections() and failed with Data.collections is not a function.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.
Both forms work in deployed agents and in
lua test: a string, or { searchText, index }. Until September 27, 2026 the deployed runtime rejected the object with searchText must be a string and never forwarded index; code written around that can move to the object form.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.
Both forms work in deployed agents and in
lua test: a string, or { searchText, index }. Until September 27, 2026 the deployed runtime rejected the object with searchText must be a string and never forwarded index; code written around that can move to the object form.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.
shared()
Opens an organization’s shared collection: the same methods asData, on data several agents of the organization read and some of them write. Available in lua-cli 3.50.0 and later.
string
required
The shared collection’s name, as an org admin created it: 1 to 128 of
A-Z a-z 0-9 _ . -. Any other value throws at once with code === 'shared_data_invalid_name'.SharedDataAPI with collections, create, get, getEntry, update, patch, increment, search and delete: the signatures, return shapes, filters, indexes and limits of the matching Data methods. A shared collection can hold several collections, named by the first argument as with Data. An entry instance it returns (update(), patch(), save(), delete()) writes back to the shared collection.
Access — set by an org admin per collection, never by agent code (Share a collection between agents):
Every write is recorded in the organization’s audit log with the agent, the collection and the entry id, never the value. The embedding work for
searchText and search() is billed to the calling agent.
Example
code is:
Limits
The same limits apply to a shared collection opened with
shared(); its indexes count against the shared collection, not the calling agent.
Types
DataEntryInstance, LuaQuery, the SharedDataAPI type that shared() returns, and the SharedDataError class 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
- Share a collection between agents — create a shared collection and choose its readers and writers

