Skip to main content
You can attach up to 256 KB of metadata to a run. Metadata is accessible from inside the run function, via the REST API, Realtime, and in the dashboard. Use it to store additional structured information — for example, user identifiers, progress state, intermediate results, or deployment status.

Setting metadata at trigger time

Pass a metadata object when triggering a run:

Reading metadata inside a run

Use metadata.current() to get the entire metadata object, or metadata.get(key) to retrieve a specific key:
/trigger/my-task.ts
Both methods work anywhere inside the run function — including helper functions called from it:
Calling metadata.current() or metadata.get() outside of a run function always returns undefined. Calling update methods outside of a run is a no-op. This makes it safe to use metadata methods anywhere in shared utilities without guarding.
Metadata methods also work inside task lifecycle hooks:

Updates API

All update methods (except flush and stream) are synchronous and non-blocking. The SDK periodically flushes changes to the database in the background, so you can call them as often as needed without impacting run performance.

set

Set the value of a specific key:

del

Delete a key from the metadata object:

replace

Replace the entire metadata object:

append

Append a value to an array key (creates the array if the key does not exist):

remove

Remove a specific value from an array key:

increment / decrement

Atomically increment or decrement a numeric key:

flush

Force an immediate write to the database. Use this when you need the metadata to be persisted before a checkpoint or external call:

Fluent API

All update methods return the updater object, so you can chain them:

Parent & root updates

A child task can update the metadata of its parent or the root task. This is useful for rolling up progress across a task hierarchy.
/trigger/tasks.ts
All update methods are available on metadata.parent and metadata.root, and they support chaining:

Example: tracking progress across parallel child tasks

/trigger/csv-processing.ts
Combined with Realtime, this pattern gives you a live progress bar in your frontend.

Inspecting metadata

Dashboard

Metadata for a run is displayed in the run details view in the Trigger.dev dashboard.

API

Retrieve a run’s metadata using runs.retrieve():
See the runs.retrieve() reference for full details.

Type-safe metadata

Metadata is loosely typed by default — it accepts any JSON-serializable object. Wrap the metadata API with a Zod schema for full type safety:
Values like Date are serialized to strings when stored. Use z.coerce.date() or equivalent to deserialize them on retrieval.
Constraints on the metadata value:

Size limit

The maximum metadata size is 256 KB. Exceeding this throws an error. If you are self-hosting, you can increase the limit with the TASK_RUN_METADATA_MAXIMUM_SIZE environment variable (value in bytes).