Skip to content

Triggering from your app

Tag runs

Label a run with up to 10 tags when you trigger it, or from inside it, and find runs by their tags with runs.list.

On this page

A tag labels a run so you can find it again: by organization, user, document or kind of job. Tags work as Trigger.dev v4's do.

Tag a run when you trigger it#

import { tasks } from '@bokjoy/sdk'; const handle = await tasks.trigger(  'reports.build',  { orgId: 'org_42', month: '2026-10' },  {    idempotencyKey: 'report-org_42-2026-10',    tags: ['org_42', 'monthly'],  },); console.log(handle.id, handle.tags.join(','));

tags takes one string or a list. Every way to start a run takes it:

  • tasks.trigger and tasks.triggerAndWait (Python: trigger_and_wait).
  • Each item of tasks.batchTrigger, in its options.
  • Inside a task: ctx.trigger, ctx.triggerAndWait and each item of ctx.batchTriggerAndWait, in its options (Python: ctx.trigger(..., tags=...) and the same names in snake case).
  • Over HTTP: tags on POST /v1/runs and on each entry of POST /v1/runs/batch.

The run's tags lists them on its handle, on runs.retrieve and in every page of runs.list.

The rules#

  • At most 10 per run. More is a ValidationError, and no run starts.
  • 1 to 128 characters each, without NUL or a lone surrogate. Anything else is a ValidationError.
  • Exact. A tag keeps its case and its spaces, and matches only itself.
  • Once each. A tag given twice is kept once, where it first appears. The order is kept.
  • Idempotent triggers ignore them. A trigger that repeats an idempotencyKey returns the run it started, with that run's own tags, whatever tags the repeat names.
  • Debounced runs. In trailing mode a trigger that names tags replaces the run's tags with its own, as it replaces the payload. A trigger with tags: [], or none, leaves them. In leading mode the first trigger's tags stay.
  • A retry from failure keeps the failed run's tags. Schedule runs have none.
  • Hooks see the tags of the run they belong to, and tags.add in a hook tags that run, as on Trigger.dev. A hook run has no tags of its own.

Tag a run from inside it#

A task can add tags to its own run while it works:

export async function importFile({orgId, rows}, ctx) {  ctx.addTags([`org_${orgId}`, 'import']);  // Its children can carry the run's tags on.  ctx.trigger('reports.build', {orgId}, {key: 'report', tags: ctx.tags});  return {rows: rows.length};}
  • ctx.addTags (Python: ctx.add_tags) adds each tag the run does not have yet, after the ones it has. It counts as a progress update, like metadata.
  • Past 10 tags in all, none of them is added. Node's ctx.addTags throws and Python's ctx.add_tags raises ValueError, before either sends anything.
  • ctx.tags holds the run's tags when the attempt started: what it was triggered with, and what earlier attempts added. Tags this attempt adds are on the run as soon as the update lands, and in ctx.tags from the next attempt on. So in the sample, the report gets the tags the import was triggered with, not the two it just added.

Adding tags needs a control plane and worker agent from this release on. With an older one, ctx.addTags and every trigger with tags inside a task throw rather than leave the run untagged.

Find runs by tag#

runs.list with tag returns the runs that have any of the tags you name, newest first:

const { data } = await runs.list({ tag: ['org_42', 'org_7'], limit: 10 });

A tag that holds a comma cannot be filtered on, since the filter separates tags with commas: the clients refuse it with a ValidationError. List runs covers every filter and paging.

The console's run list filters by tag too, and shows each run's tags.