Skip to main content

Overview

The Data API allows you to store custom data in collections with powerful semantic search capabilities using vector embeddings. Returns DataEntryInstance objects with direct property access.

Direct Access

Access entry.title not entry.data.title

Search Scores

Results include relevance scores

Instance Methods

Built-in update(), save(), and delete()

Array Methods

Use .map(), .filter() on search results

Return Shape Reference

Each method returns a different type. The most common mistake is treating Data.search() results like Data.get() results — they have different shapes.
Quick examples:

Key Features

Custom Collections

Store any JSON data in named collections

Vector Search

Semantic similarity search using AI embeddings

Flexible Schema

No fixed schema - store any structure

Filtering

Query by field values with operators

Methods

create()

Create a new entry in a collection.
collectionName
string
required
Name of the collection (e.g., ‘movies’, ‘customers’, ‘articles’)
data
object
required
Any JSON-serializable object to store
searchText
string
Text to index for vector search. Include all searchable content.
Returns:
Example:
Semantic search using vector embeddings.
collectionName
string
required
Name of the collection to search
searchText
string
required
Search text (natural language query)
limit
number
default:10
Maximum number of results to return
scoreThreshold
number
Minimum similarity score (0-1). Higher = more similar.
Returns: Array of DataEntryInstance objects, each with a score property. Similarity Scores:
  • 1.0 = Perfect match
  • 0.8-0.9 = Very similar
  • 0.6-0.7 = Somewhat similar
  • <0.6 = Low similarity
Example:

get()

Retrieve entries with optional filtering and pagination.
collectionName
string
required
Name of the collection
filter
object
Filter criteria (MongoDB-style queries)
page
number
default:1
Page number (1-indexed)
limit
number
default:10
Items per page
Returns:
Examples:

getEntry()

Retrieve a specific entry by ID.
Example:

update()

Update an existing entry.
collectionName
string
required
Name of the collection
entryId
string
required
ID of the entry to update
data
object
required
Data to merge with existing entry
searchText
string
Optional new text for vector search indexing
Returns:
Example:
Updates merge with existing data. Only the specified fields are updated; other fields are preserved.

DataEntryInstance Methods

When you retrieve or create data entries, you get a DataEntryInstance object with convenient instance methods.

save()

Save the current state of the data entry to the server. This is a convenience method that persists all changes made to the entry.
searchText
string
Optional new text for vector search indexing
Returns: Promise resolving to true if successful Example:
The save() method provides a simpler workflow - modify properties then save, rather than calling Data.update() with the collection name and entry ID.

update() (Instance Method)

Update the entry using the instance method.
Returns: Promise resolving to the updated data object Example:

delete() (Instance Method)

Delete the entry using the instance method.
Example:

Static Methods

delete()

Delete an entry using the static method.
Example:

Use Cases

Knowledge Base

Customer CRM

Task Management

Filter Operators

The Data API supports MongoDB-style filter operators:

Best Practices

Include all searchable content in searchText:
  • 0.8+: High precision, few results
  • 0.7: Balanced (recommended default)
  • 0.6: More results, lower precision
  • <0.6: May return irrelevant results
Use consistent field names across entries:
Track when entries are created/modified:

Vector Search Tips

Vector search uses AI to understand meaning, not just match keywords.Example:
  • Query: “affordable laptop for students”
  • Finds: “budget-friendly notebook for college”
  • Even though no words match exactly!
If your Data results don’t look right, log the raw return value before transforming it:
Then run lua logs --type skill --limit 5 after sending a test message to see the actual shape at runtime. See the Debugging Skills guide for the full 5-step workflow.

Next Steps

Custom Data Examples

See working examples

Build Your First Skill

Complete tutorial using Data API

Debugging Skills

Inspect runtime return values