Call the server API
Use the HTTP API when the Getriebe server should own the workflow, identities
and durable state. Start the in-memory demo server from
Getting Started. This walkthrough uses a POSIX shell,
curl, and jq. Run each block in the same shell.
Establish both sessions
Section titled “Establish both sessions”The demo uses one requester and one reviewer. Each authenticated session has its own cookie and CSRF token. Login rotates both, so fetch a token using the new cookie before sending a write.
api=http://127.0.0.1:${GETRIEBE_DEMO_PORT:-3000}/api/v1session_dir=$(mktemp -d)
sign_in() { jar=$1 account=$2 initial=$(curl -fsS -c "$jar" "$api/session/csrf" | jq -er '.csrfToken') curl -fsS -b "$jar" -c "$jar" -H "X-CSRF-Token: $initial" \ -H 'Content-Type: application/json' \ -d "$(jq -nc --arg u "$account" '{username: $u, password: $u}')" \ "$api/login" >/dev/null curl -fsS -b "$jar" "$api/session/csrf" | jq -er '.csrfToken'}
requester="$session_dir/requester.cookies"reviewer="$session_dir/reviewer.cookies"requester_token=$(sign_in "$requester" requester)reviewer_token=$(sign_in "$reviewer" reviewer)In a same-origin browser, the user agent manages the session cookie. Send
the CSRF token in X-CSRF-Token on writes, and discard it whenever the session
changes. For a Node.js client, use a separate cookie jar per session as
above. See the HTTP session contract for
expiry, revocation and cookie details.
Start the order approval
Section titled “Start the order approval”Find the deployed model by its BPMN process ID and pick its default startable version. This example binds the new instance to that version explicitly.
account_id=$(curl -fsS -b "$requester" "$api/profile" | jq -er '.user.id')order_model=$(curl -fsS -b "$requester" "$api/models" | jq -ce '.items[] | select(.bpmnIdentity.processId == "orderApproval")')model_id=$(printf '%s' "$order_model" | jq -er '.id')version_id=$(printf '%s' "$order_model" | jq -er '.defaultVersionId')
instance_id=$(curl -fsS -b "$requester" -H "X-CSRF-Token: $requester_token" \ -H 'Content-Type: application/json' \ -d "$(jq -nc --arg v "$version_id" --arg id "$account_id" \ '{versionId: $v, data: {amount: "125.50", requesterId: $id}}')" \ "$api/models/$model_id/instances" | jq -er '.id')The server returns 201 and the instance ID. Use a string for the exact decimal amount. An instance keeps the model version selected at start.
If the response is lost or the server returns 503 commit-unknown, the start may
already have succeeded. Reconcile it against the application’s business
records before starting again. Each successful start request creates a new
instance. For a Task completion, keep the attemptId and read that exact
attempt to determine whether the result was accepted.
Claim and complete the review
Section titled “Claim and complete the review”Filter the reviewer’s worklist by the new instance. Claim the offered task and read its current attempt before submitting the result.
task_id=$(curl -fsS -b "$reviewer" "$api/worklist?instanceId=$instance_id" | jq -er '.items[] | select(.bpmnElementId == "reviewOrder") | .id')curl -fsS -b "$reviewer" -H "X-CSRF-Token: $reviewer_token" \ -X POST "$api/tasks/$task_id/claim" >/dev/nullattempt_id=$(curl -fsS -b "$reviewer" "$api/tasks/$task_id" | jq -er '.currentAttempt.id')curl -fsS -b "$reviewer" -H "X-CSRF-Token: $reviewer_token" \ -H 'Content-Type: application/json' \ -d "$(jq -nc --arg id "$attempt_id" '{attemptId: $id, result: {approved: true}}')" \ "$api/tasks/$task_id/complete" >/dev/null
curl -fsS -b "$requester" "$api/instances/$instance_id" | jq -e '{status, approved: .data.approved} | select(.status == "completed" and .approved == true)'The output shows completed and true. A claim and a completion are separate
requests. If the task reports a data conflict, retain the original attempt ID
for history, open a fresh attempt and show its current inputs before asking
for a new decision. The worklist contract
describes role-based offers, personal assignment and authorization.
Sign out
Section titled “Sign out”curl -fsS -b "$requester" -H "X-CSRF-Token: $requester_token" -X POST "$api/logout"curl -fsS -b "$reviewer" -H "X-CSRF-Token: $reviewer_token" -X POST "$api/logout"rm -f "$requester" "$reviewer"rmdir "$session_dir"For the next step, see how to validate a model and manage its versions.
Look up requests and schemas in the Server HTTP API reference.
Read a Sub-Process execution path
Section titled “Read a Sub-Process execution path”For an internal task, the server can return a scopePath in the worklist,
task history and instance details. Entries are ordered from outermost to
innermost with an execution id and bpmnElementId for the scope.
Use the process instance ID for instance requests and the scope execution
ID when grouping records from the same review round. Starting a new round
changes its scope ID while the process instance ID stays the same.
A server restart preserves active execution IDs, locals and unfinished
work. The instance data response exposes process-level fields. Authorized
task attempts may retain inputs and results recorded before a scope closed.
The Workflow reference describes the
embedded library’s scopeExecutions, writeScopeData and snapshots.
Handle task deadlines in a client
Section titled “Handle task deadlines in a client”Show dueAt in the user’s local timezone when the field is present.
The worklist server returns active offers. Authorized historical reads
can return a withdrawn task without a current attempt or actions.
Read its history to see the timer event and the time it was processed.
On 409 task-withdrawn, refresh the task or list and discard the stale
completion form. The server checks current visibility before returning
that outcome. See the HTTP deadline binding.
To see the deadline display locally, run pnpm install --frozen-lockfile
in the TypeScript source distribution, then run pnpm dev:worklist and open the
URL printed by Vite. Set GETRIEBE_API_ORIGIN if the Effect server listens
elsewhere. The lab uses the same browser client and supports
claim and release. Submit task results with the tutorial helper.
Submit parallel review votes
Section titled “Submit parallel review votes”Deploy the combined order example.
Start it with data: { "amount": "125.50", "reviewKinds": ["budget", "einkauf"] }
or include "compliance". Do not supply reviewVotes at start. Each
reviewer finds their role’s open task by multiInstance.item and claims
its own task ID. Read the current attempt, which includes reviewKind and
the shared order amount. Post the attempt ID with
"result": { "reviewVote": true } or false to the completion endpoint.
After the final vote, instance detail includes the complete reviewVotes
array in input order. A fresh round has different task IDs and a new
multiInstance.roundId. Use that identifier when displaying or correlating
task histories. While a resubmitted round is open, reviewVotes still
contains the last completed round’s list. When completion returns
503 commit-unknown, read the exact attempt to confirm whether its vote
committed, and then read the instance for the process state. See the
parallel review binding.