Packages

Coordinator SDK

A typed client for the coordinator's scheduled webhook API.

@scrape-admin/coordinator-sdk wraps Coordinator's REST API in a small, typed client built on ofetch, so callers get autocomplete and type-checking against @scrape-admin/coordinator-schema instead of hand-rolling fetch calls and headers.

Creating a client

createCoordinatorClient takes the coordinator's base URL and the calling tenant's ID, which is sent on every request as the x-tenant-id header required by the coordinator's authentication:

import { createCoordinatorClient } from '@scrape-admin/coordinator-sdk'

const coordinator = createCoordinatorClient({
  baseUrl: 'http://localhost:3001',
  tenantId: 'my-tenant',
})

scheduledWebhooks

The client exposes one namespace, scheduledWebhooks, mirroring the coordinator's /api/v1/webhooks/scheduled API:

MethodRequestReturns
scheduledWebhooks.list()GET /ScheduledWebhook[]
scheduledWebhooks.create(payload)POST /ScheduledWebhook
scheduledWebhooks.get(id)GET /:idScheduledWebhook
scheduledWebhooks.update(id, payload)PATCH /:idScheduledWebhook
scheduledWebhooks.delete(id)DELETE /:idScheduledWebhook
scheduledWebhooks.runs(id).list()GET /:id/runsScheduledWebhookRun[]
scheduledWebhooks.runs(id).trigger(payload?)POST /:id/runsScheduledWebhookRun[]
scheduledWebhooks.runs(id).get(runId)GET /:id/runs/:runIdScheduledWebhookRun

payload for create/update is validated against CreateScheduledWebhook/UpdateScheduledWebhook from @scrape-admin/coordinator-schema: one or more destinations, an optional payload body, and a cronExpression.

// Schedule a webhook to fire every 5 minutes
const webhook = await coordinator.scheduledWebhooks.create({
  destinations: [{ url: 'https://example.com/hooks/scrape-complete' }],
  cronExpression: '*/5 * * * *',
})

// Update its schedule
await coordinator.scheduledWebhooks.update(webhook.id, { cronExpression: '0 * * * *' })

// Trigger a run immediately, outside the cron schedule
const [run] = await coordinator.scheduledWebhooks.runs(webhook.id).trigger()

// Inspect run history
const runs = await coordinator.scheduledWebhooks.runs(webhook.id).list()
const sameRun = await coordinator.scheduledWebhooks.runs(webhook.id).get(run.id)

// Stop scheduling it
await coordinator.scheduledWebhooks.delete(webhook.id)

Every call throws (via ofetch) on a non-2xx response, so wrap calls in try/catch where a failed request should be handled rather than bubbling up.

Copyright © 2026