Skip to content

Automation

Background jobs with retries, cron schedules, signed webhooks, an event feed and an audit log.

Jobs

A job is a piece of work that runs outside the request: now, after a delay, or at a set time.

Terminal
curl -X POST https://api.dianthan.com/v1/jobs \
  -H "X-API-Key: dn_live_…" -H "X-App-Id: app_…" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "http",
    "payload": { "url": "https://fieldnotes.app/api/rebuild-index", "body": { "full": true } },
    "delay_seconds": 60,
    "max_attempts": 5
  }'
TypeDoes
httpCalls an HTTPS URL on one of the app's registered domains, with optional headers and body. Any non-2xx response counts as a failure.
emailSends an email. The payload is the same as POST /v1/messages/email.
webhookDelivers an event to one of your webhook endpoints.
logWrites an analytics event. Useful for scheduled markers.
  • Schedule with delay_seconds or run_at (ISO 8601). Leave both out to run as soon as possible.
  • max_attempts is 1 to 25. Failed attempts are retried with exponential backoff.
  • Inspect with GET /v1/jobs/:id, cancel with POST /v1/jobs/:id/cancel, run a failed job again with POST /v1/jobs/:id/retry.

Schedules

Terminal
curl -X POST https://api.dianthan.com/v1/schedules \
  -H "X-API-Key: dn_live_…" -H "X-App-Id: app_…" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "nightly-digest",
    "cron": "0 6 * * *",
    "type": "http",
    "payload": { "url": "https://fieldnotes.app/api/digest" }
  }'

A schedule creates a job at each time it fires. Pause it with PATCH /v1/schedules/:id and {"enabled": false}. Schedules are checked every few minutes, so use a job with run_at when you need exact timing.

Webhooks

Subscribe an endpoint to events:

Terminal
curl -X POST https://api.dianthan.com/v1/webhooks \
  -H "X-API-Key: dn_live_…" -H "X-App-Id: app_…" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://fieldnotes.app/api/hooks","events":["user.created","subscription.updated"]}'

Each delivery is signed with the webhook's secret. Check the signature before you trust the body. Deliveries are kept, so you can inspect them with GET /v1/webhooks/:id/deliveries and retry any of them with POST /v1/webhooks/:id/deliveries/:delivery_id/retry. Send a test event with POST /v1/webhooks/:id/test.

Events and the audit log

  • GET /v1/events is the app's append-only stream of what happened: users created, files uploaded, subscriptions changed.
  • GET /v1/audit-log records who did what, with which credential, from which IP. Filter it by actor, action or resource.

Neither can be edited or deleted through the API.

In preview: workflows. These are multi-step jobs that wait for each other, for a period of time or for an event, and resume after a failure.