genroc

docs / Guides / Process definition

Actions

Learn what tasks can do.

An action is what a task does. We have several types.

TypeWhat it doesExplained in
fetchCalls an HTTP endpoint and reads the response.below
delayWaits for a duration or until a point in time.below
childStarts one child process and waits for its result.Child processes
child_mapStarts several named child processes and waits for all of them.Child processes
child_listStarts a child process for each item of an array and waits for all.Child processes
externalWaits for an answer from outside, e.g. a worker or a person.External tasks

A task without an action does no work; it only evaluates its output and switch.

Fetch

Calls a REST API endpoint. It is inspired by Node.js fetch and has similar properties.

  - id: create_ticket
    action:
      type: fetch
      method: post
      url: "${config.api_url}/tickets"
      headers:
        Authorization: "Bearer ${config.api_token}"
      body:                    # sent as JSON
        email: "$: input.email"
        subject: "$: input.subject"
      responses:               # the response type, read as self.result
        201:
          type: object
          properties:
            ticket_id: { type: string }
          required: [ticket_id]
    output:
      ticket_id: "$: self.result.ticket_id"
    switch: next

This action sends a POST request with a JSON body and expects a 201 status with valid JSON that fits the defined schema. The response JSON is available as self.result and is referenced in the output field.

If the status isn't accepted, fetch fails with http.<status> (e.g. http.404); if the body doesn't fit the schema, with result.invalid. Both can be handled in on_error. Check error handling for details.

Here is a list of the fields available on the fetch action:

FieldRequiredMeaning
methodyesHTTP method, lowercase: get, post, put, …
urlyesThe request URL; can contain ${…} templates.
headersRequest headers; each value a string.
queryQuery parameters appended to the URL. A parameter whose value is null is left out.
bodyThe request body; an object is sent as JSON.
responsesResponse types by status. A 2xx entry types self.result; others type the error body (more).
accepted_statusStatuses that count as success; any 2xx by default (more).
timeoutTime limit for one attempt, 30s by default; each retry gets a new one (more).

In the task's output and switch, the response is available as self.result (the body), self.status and self.headers.

Delay

It parks the instance for a specified amount of time. The waiting costs nothing, because it's just a record in the database, not an active process.

The instance keeps the running status, but the engine continues with execution only after the specified time.

  - id: wait_duration
    action:
      type: delay
      for: 30s
    switch: next

  # or

  - id: wait_until
    action:
      type: delay
      until: "mon 09:00"
      tz: "Europe/Prague"
    switch: next

Available fields:

FieldMeaning
forHow long to wait: 30s, 2h30m, 7d, 1mo. A plain number is milliseconds.
untilWhen to stop waiting: 2026-09-01 08:00, +2d 08:00 (in two days at 8:00), or a pattern like mon 09:00 (next Monday).
tzThe time zone until and calendar units (d, w, mo, y) are read in: Europe/Prague or +02:00. UTC by default.

Use exactly one of for and until. The full syntax is in the delay syntax reference.

You can use expressions in for and until, but they only accept numbers, as milliseconds (for is relative and until absolute). If the value of until is in the past, the instance just continues immediately.

Child, child_map, child_list

This is a family of actions that spawn child processes.

Read more about them at child processes.

External

An action that is resolved by an external system or a human.

Read more at external tasks.

Optional schema fields

There are optional *_schema fields for certain shapes within tasks and the process definition.

FieldWhereDeclares
body_schemafetchthe request body
query_schemafetchthe query parameters
input_schemachild, child_list, each entry of child_map, externalthe input sent to the child or worker
output_schemaa task, and the process itselfthe task's or process's output

They keep the shapes from drifting. The shapes are checked against the schemas when you apply the definition, and the schemas also drive editor completion.

You can also use a schema to solve optional vs. nullable field problems. Genroc adjusts the shape at runtime in the following way:

  • an optional field that comes out as null is removed
  • a required nullable field that is missing from the shape is added as null

Defaults are not applied by these schemas.

Genroc uses these fields extensively when importing child process schemas with the $process: resolver (read child processes).