decision control
Guides

Scheduled jobs

Run a decision on a schedule over records fetched from an HTTP endpoint or a SQL query.

A scheduled job runs a published decision on a cron schedule, over a list of records it fetches from a data source. It is separate from the decision engine: the job decides when to fetch, what to queue and which version to use; every record then runs as an ordinary execution, with its own trace and actions.

cron tick → fetch (HTTP / SQL) → records → queue → workers → decision → execution

Jobs live under Scheduled jobs in the console and need the schedule.manage permission (project admins and owners by default). Reading a run's progress needs execution.read.

Configure a job

SettingWhat it does
Cron and timezoneFive fields (minute hour day-of-month month day-of-week), evaluated in an IANA timezone.
Decision, environmentThe decision to run and the environment whose deployment latest means for this job.
SourceAn HTTP endpoint (GET/POST, optional credential, records_path) or a SQL query.
Mapping{ "input_field": expression } over { record, run }. Empty passes the record as it is.
Idempotency keyAn expression over { record }. Defaults to record.id, then to a hash of the mapped input.
Max concurrencyThe most records of this job in flight at once, across all workers.
Max attempts, backoffFailed records are retried with exponential backoff (base × 2ⁿ, ±20% jitter) up to the attempt limit.
Max recordsA run never queues more than this (and never more than SCHEDULED_MAX_RECORDS).

HTTP sources go through the same screened client as every other outbound call: private addresses are refused unless OUTBOUND_ALLOWED_HOSTS lists them, redirects are not followed and the response is size-limited. records_path is a dotted path such as data.items to the array of records; leave it empty when the response is the array. A credential is sent as a bearer token, basic auth or an API-key header, according to its type. Set Auth header name when the backend expects its own header (for example api-key instead of X-API-Key): only the name changes, the value keeps the type's format.

SQL sources use a project Postgres connection. Only a single SELECT (or WITH … SELECT) is accepted and it runs in a read-only transaction with a timeout.

Every outbound request carries a default User-Agent (DecisionControl/1.0) unless you set your own in Headers: many gateways and CDNs answer a request with none by 403.

Use Preview to fetch the first records and see what they map to, without queueing anything.

Paginated sources

When an endpoint hands out its records in pages, pick a Pagination strategy on the HTTP source. The run reads page after page, in order, and queues the records together, still capped by Max records.

StrategyHow the next page is asked for
NoneA single request (the default).
Page numberA page parameter (default page, first page 1) and a size parameter (default pageSize).
OffsetAn offset parameter (default offset, from 0) and a limit parameter (default limit).
CursorThe value at Next cursor path in each response goes into the cursor parameter.
Next URLThe URL at Next URL path is requested as it is. It must be on the same origin as the source, because the credential travels with it.

Records per page defaults to 100 (up to 10,000). The paging parameters travel in the query string, or in the JSON body of a POST. Reading stops when the cursor or URL is missing, when a page is empty or short, or earlier if you set a stop rule: a has-more, total pages or total records path, or a continue_when expression. A token that repeats is treated as a loop, not a new page.

Limits and failures: Page limit (default 100, up to 10,000) and optionally a maximum duration and a requests-per-second ceiling. A failed page is retried (page_retries, default 2). If it still fails, If a page fails decides: keep what was read and process it (the default), or fail the run and cancel what has not started. The run shows how many pages were read.

Preview and the source test report what the first page said about the next one, so you can check the paths before saving.

Dates in the request

{{today}} and {{yesterday}} in an HTTP source's URL, body or header values become YYYY-MM-DD dates, for example ?created_date={{today}}. The day is read in the job's timezone at the run's scheduled time, so every page and retry of one run asks for the same day. Any other {{…}} is refused when you save.

Mapping and idempotency tips

The Mapping, Headers and idempotency fields use a JSON editor that checks the syntax as you type; a field that is not valid JSON blocks saving. Use Preview to see, for each of the first records, its idempotency key, mapped input and any error, without queueing anything.

  • Map only what the decision's input schema asks for: a record that does not match fails at once instead of being retried.
  • Pick a key that identifies the business record ({ "var": "record.reference" }), not a value that changes between runs. Keys deduplicate within a run only; if the endpoint can return the same record on two days, ask for a window with {{yesterday}} or filter it at the source.

Versions: one per run

When a run starts it resolves latest for the job's environment once and pins that exact version. Every record of the run uses it, even if a new version is published or deployed halfway through. The run shows the pinned version, and each execution it creates carries it.

No duplicates

Every record gets an idempotency key. Within a run a key is queued once: a record that appears twice in the fetched list is skipped and counted as a duplicate. The key is also stored as the execution's external id, and a worker that crashed after deciding but before saving adopts the execution that already exists instead of deciding the record again.

Each run covers the whole list again — records are deduplicated per run, not across runs.

Runs, retries and errors

StatusMeaning
fetchingPinning the version and pulling records from the source.
runningRecords are queued and being processed.
succeededEvery record succeeded.
partialSome records failed.
failedThe source could not be read, or every record failed.
cancelledStopped by a member; records not started were cancelled.
skippedA tick arrived while the previous run was still going.

A record whose source or upstream call failed transiently is retried with backoff. A record the decision rejects (for example, an input that does not match its schema) fails at once, and its execution is recorded. Open a run to see each record's attempts, last error and execution, and use Retry failed to queue the failed records again on the same pinned version.

A worker that stops mid-record loses its lease after SCHEDULED_ITEM_LEASE_MS; another worker takes the record over. Ticks missed while the platform was down collapse into one run.

When the source fails

When the source cannot be read the run is failed and stores what is needed to tell why. Open the run and expand Error details:

  • request: method, URL and headers that were sent, with secrets masked (the credential's header, anything named like authorization, token or key, and sensitive query parameters).
  • response: HTTP status, every response header except cookies (server, www-authenticate, retry-after, a WAF's rule id…) and the first 2,000 characters of the body.
  • duration_ms, and network_error (ECONNRESET, ENOTFOUND…) when no response arrived.
  • For a body that is not a list, the response_shape (its top-level keys) to fix records_path.

A record's last error carries its code, for example [UPSTREAM_TIMEOUT] ….

Run statistics

Open a job's Last runs overview to see how it has behaved over the last 24 hours, 7, 30 or 90 days: runs (ok, partial, failed), run success rate, record success rate, average duration with p95 and max, records and duration over time, runs by status and trigger, and the most common record errors. The figures are aggregated over every run in the window, not just the runs loaded on screen. The same data is at GET /api/v1/scheduled-jobs/:id/stats?days=30 (1 to 90 days).

Events and metrics

Webhooks can subscribe to scheduled_run.completed and scheduled_run.failed. Prometheus exposes dc_scheduled_runs_total and dc_scheduled_items_total.

API

/api/v1/scheduled-jobs: create, list, change, pause/resume, delete, POST /:id/run, POST /:id/preview, GET /:id/runs, and under /runs/:runId the run, its /items, /retry-failed and /cancel. See the API reference for the schemas.

On this page