//this is the job we want to cancel runs for
client.defineJob({
  //this is the job id
  id: "my-job",
  name: "My first job",
  version: "1.0.0",
  trigger: invokeTrigger({ schema: z.number() }),
  run: async (payload, io, ctx) => {
    await io.logger.info(`Hello World ${payload}`);
  },
});

// Some time later...
const res = await client.cancelRunsForJob("my-job");
console.log(res.cancelledRunIds);
console.log(res.failedToCancelRunIds);

Parameters

jobId
string
required

The job ID to cancel the job runs for. This is the id you set when using client.defineJob() or new Job().

Returns

//this is the job we want to cancel runs for
client.defineJob({
  //this is the job id
  id: "my-job",
  name: "My first job",
  version: "1.0.0",
  trigger: invokeTrigger({ schema: z.number() }),
  run: async (payload, io, ctx) => {
    await io.logger.info(`Hello World ${payload}`);
  },
});

// Some time later...
const res = await client.cancelRunsForJob("my-job");
console.log(res.cancelledRunIds);
console.log(res.failedToCancelRunIds);