batchCreateJobs()
Signature
client.batchCreateJobs(payload: JobBatchCreatePayload): Promise<JobBatchCreateResponse>Parameters#
| Param | Type | Description |
|---|---|---|
jobs | JobCreatePayload[] | Array of job objects to create (max 100) |
Usage#
ts
import { VeloraClient } from '@rimora/velora'
import fetch from 'node-fetch'
const client = new VeloraClient({
apiKey: process.env.VELORA_API_KEY,
fetch: fetch as any
})
const result = await client.batchCreateJobs({
jobs: [
{
name: 'Daily Report',
target_url: 'https://example.com/hook1',
schedule_cron: '0 9 * * *'
},
{
name: 'Weekly Summary',
target_url: 'https://example.com/hook2',
schedule_cron: '0 10 * * 0'
}
]
})
console.log(`Created ${result.created} jobs, failed ${result.failed}`)
// The endpoint is: POST /api/v1/jobs/batchResponse#
JobBatchCreateResponse
{
"jobs": [
{ "id": "9f4a1c2b-3d4e-5f6a-7b8c-9d0e1f2a3b4c", "status": "active" },
{ "id": "a1b2c3d4-5e6f-7g8h-9i0j-1k2l3m4n5o6p", "status": "active" }
],
"total": 2,
"created": 2,
"failed": 0
}Maximum 100 jobs per request. Subject to your plan's job limit. Jobs that fail validation (e.g., invalid target_url or schedule_cron) will be skipped and included in the 'failed' count.
Required scope#
Requires: jobs:create (or jobs:write, admin, *)
Common errors#
| Status | error | Cause |
|---|---|---|
400 | validation_error | jobs is required and must be an array |
400 | validation_error | Maximum 100 jobs per request |
403 | job_limit_exceeded | Plan job limit reached |
401 | invalid_api_key | Missing or revoked API key |
403 | insufficient_scope | Key lacks jobs:create scope |