Skip to content

Run your first job

A Job is one run of a step pipeline. You can create one immediately, or wrap a preset in a schedule that fires on cron.

Start a single step and wait for it to finish:

import { PlatformApiClient } from '@abeauvois/platform-sdk'
const client = new PlatformApiClient({ baseUrl: 'http://localhost:3000' })
await client.auth.signIn({ email: 'you@example.com', password: 'secret' })
// Kick off a single-step Gmail read job
const job = await client.jobs.createSingle('read_gmail', { filter: { label: 'Newsletter' } })
// Poll until it completes (or fails)
const finished = await client.jobs.waitForCompletion(job.id)
console.log(client.jobs.isCompleted(finished)) // true
console.log(client.jobs.getErrors(finished)) // string[]

For a multi-step chain in one shot (no cron), assemble a steps: JobStep[] array yourself and call client.jobs.create({ type: 'workflow-of-steps', steps }) — the same arbitrary-chain path the dashboard’s “Build custom flow” composer uses (see Presets).

Useful helpers on client.jobs: getProgress(job), getCurrentStep(job), isRunning(job), hasFailed(job), getErrors(job).

Most automation should run on a cron schedule. Each fire materializes a fresh Job, so multi-step presets just work:

await client.jobs.createSchedule({
slug: 'daily-triage',
preset: 'gmailTriage', // flagged Gmail thread → kanban task
cron: '0 7 * * *', // every day at 07:00
})
const schedules = await client.jobs.listSchedules()
await client.jobs.runScheduleNow('daily-triage') // trigger an out-of-band run

Schedule names are namespaced server-side as {userId}.{slug}. The overlap policy is skip-if-previous-still-running — see Scheduling.