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.

One-off run

Start a built-in preset 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 Gmail read job for the last 7 days
const job = await client.jobs.startWorkflow('gmail', { filter: 'newer_than:7d' })
// 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[]

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

Schedule a preset

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-veille',
preset: 'veille', // Gmail "Veille" label → enrich → Notion
cron: '0 7 * * *', // every day at 07:00
})
const schedules = await client.jobs.listSchedules()
await client.jobs.runScheduleNow('daily-veille') // 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.

What’s next