Jetic
Guides

Workflows

Author stateful, multi-step API journeys with dynamic data, capture, injection, conditions and retries.

A Workflow answers what happens. It is an ordered list of HTTP steps saved as JSON in .jetic/workflows/, executed against a live server with automatic state capture and header injection.

This is the biggest difference between Jetic and a collection of isolated API requests: a workflow models real application behavior — register → log in → capture token → create resource → assert.

File architecture

model.json — the API model
user-onboarding.json
checkout-flow.json
2fa-transfer.json
memory.json — runtime state

Each step is an HTTP call to an endpoint defined in model.json. Steps run in order and share a runtime memory so later steps can reuse what earlier steps produced.

Step fields

Prop

Type

The workflow root also accepts name, description, version, environment, and a global retry default that every step inherits.

Template syntax

Jetic evaluates placeholders inside string values across body, inject, and other string fields.

Generate realistic fake data at execution time:

PlaceholderExample output
{{faker.internet.email}}user_8f9a@example.com
{{faker.internet.password}}kX9#mL2$vP1
{{faker.person.fullName}}Sarah Connor
{{faker.company.name}}Acme Dynamics Inc
{{faker.string.uuid}}a1b2c3d4-e5f6-7890-abcd-1234567890ab
{{faker.phone.number}}+1-555-019-2834
{{faker.word.noun}}workspace
{{faker.commerce.productName}}Ergonomic Aluminum Keyboard

Reserve {{human:*}} for the truly unknowable

Never use {{human:key}} for values faker can generate (emails, names, UUIDs, passwords). It pauses the run and blocks automation.

Injection (inject)

The inject block places captured memory into request headers or body fields before the call executes.

"inject": {
  "header:Authorization": "Bearer {{workflow:accessToken}}",
  "header:X-Workspace-ID": "{{workflow:workspaceId}}",
  "body:tenantId": "{{workflow:tenantId}}"
}

A bare key without a prefix is treated as a header:

"inject": { "Authorization": "Bearer {{workflow:accessToken}}" }

Auth rule

Every step against an authenticated endpoint must carry an inject entry for header:Authorization (or a security binding in the model).

Capture

Jetic has two capture mechanisms. Together they make multi-step journeys possible.

Saves resolved request body fields to memory before the request is sent. Use it to remember generated credentials so later steps can reuse the exact same values.

"body": {
  "email": "{{faker.internet.email}}",
  "password": "{{faker.internet.password}}"
},
"captureInput": {
  "workflow:userEmail": "email",
  "workflow:userPassword": "password"
}

Conditions

A condition is evaluated before the step runs. If it evaluates to false, the step is skipped (counted as passed) and the workflow continues.

"condition": {
  "if": "{{workflow:userRole}}",
  "equals": "admin"
}
OperatorMeaning
equals / notEqualsExact string equality / inequality
containsSubstring inclusion
existsValue is non-empty (true) or empty (false)
greaterThan / lessThanNumeric comparison
inMembership in a string array

Failure handling & retries

onFailure controls what happens when a step fails:

  • abort (default) — stop the workflow immediately.
  • continue — log the failure, skip that step's captures, and proceed. Useful for optional cleanup and negative tests.

continueOnStatus treats specified non-2xx codes as passes:

"expectStatus": 200,
"continueOnStatus": [404, 409]

retry re-attempts a step on network error or a failed status assertion. Set a global default and override per step:

"retry": { "times": 3, "delayMs": 1000 }

Full example

A production-style journey: workspace setup, login token capture, an interactive 2FA prompt, a conditional admin action, a failure-tolerant audit read, and logout.

{
  "name": "Enterprise Workspace Setup & 2FA Verification Flow",
  "description": "Workspace setup, login, 2FA, conditional team creation, and teardown.",
  "version": "0.3",
  "environment": "local",
  "retry": { "times": 2, "delayMs": 500 },
  "steps": [
    {
      "name": "1. Admin Workspace Registration",
      "method": "POST",
      "path": "/api/v1/workspaces/setup",
      "expectStatus": 201,
      "body": {
        "workspaceName": "{{faker.company.name}} Workspace",
        "adminEmail": "{{faker.internet.email}}",
        "adminPassword": "{{faker.internet.password}}",
        "adminName": "{{faker.person.fullName}}"
      },
      "captureInput": {
        "workflow:adminEmail": "adminEmail",
        "workflow:adminPassword": "adminPassword"
      },
      "capture": { "workflow:workspaceId": "data.workspace.id" }
    },
    {
      "name": "2. Admin Login & JWT Issuance",
      "method": "POST",
      "path": "/api/v1/auth/login",
      "expectStatus": 200,
      "body": {
        "email": "{{workflow:adminEmail}}",
        "password": "{{workflow:adminPassword}}"
      },
      "capture": {
        "workflow:accessToken": "data.tokens.access",
        "workflow:userRole": "data.user.role"
      }
    },
    {
      "name": "3. Interactive 2FA Verification",
      "method": "POST",
      "path": "/api/v1/auth/verify-2fa",
      "expectStatus": 200,
      "condition": { "if": "{{workflow:requires2FA}}", "equals": "true" },
      "inject": { "header:Authorization": "Bearer {{workflow:accessToken}}" },
      "body": { "otpCode": "{{human:admin_otp_code}}" },
      "capture": { "workflow:verifiedToken": "data.sessionToken" },
      "retry": { "times": 3, "delayMs": 1000 }
    },
    {
      "name": "4. Provision Team (Admin Only)",
      "method": "POST",
      "path": "/api/v1/teams",
      "expectStatus": 201,
      "condition": { "if": "{{workflow:userRole}}", "equals": "admin" },
      "inject": { "header:Authorization": "Bearer {{workflow:verifiedToken}}" },
      "body": {
        "workspaceId": "{{workflow:workspaceId}}",
        "teamName": "Engineering Division"
      },
      "capture": { "workflow:teamId": "data.id" }
    },
    {
      "name": "5. Optional Audit Check",
      "method": "GET",
      "path": "/api/v1/audit/logs",
      "expectStatus": 200,
      "continueOnStatus": [404],
      "onFailure": "continue",
      "inject": { "header:Authorization": "Bearer {{workflow:verifiedToken}}" }
    },
    {
      "name": "6. Session Logout",
      "method": "POST",
      "path": "/api/v1/auth/logout",
      "expectStatus": 200,
      "inject": { "header:Authorization": "Bearer {{workflow:verifiedToken}}" }
    }
  ]
}

Running workflows

# Run against the default environment
jetic simulate workflow --workflow .jetic/workflows/user-onboarding.json

# Clear memory first
jetic simulate workflow --workflow .jetic/workflows/user-onboarding.json --clear-memory

# List saved workflows
jetic simulate workflow --list

Author with validate → create → simulate

When building workflows through an AI IDE, always validate before saving. jetic_create_workflow refuses to save while validation errors remain, and jetic_validate_workflow checks that every {{scope:key}} is captured by an earlier step.

On this page