When to use
- Test a deployed workflow
- Execute a workflow via the CLI instead of the platform UI
- Automate workflow execution in scripts or CI
Prerequisites
- Use case deployed (
project.jsoncontainsdevProcessInstanceId) - Authenticated via
codika loginorCODIKA_API_KEYenv var - API key with
workflows:triggerscope
Resolving the workflow ID
TheworkflowId is the workflowTemplateId from config.ts. If the user provides a use case folder path, read config.ts to find the available workflow IDs and their trigger types.
Supported trigger types:
- HTTP triggers (
trigger.type === 'http'): Triggered with optional payload - Schedule triggers (
trigger.type === 'schedule'): Triggered via themanualTriggerUrlconfigured inconfig.ts. The CLI creates an execution document upfront and passes it to the workflow, so--pollworks exactly like HTTP triggers. No payload is needed.
Command
Arguments
| Argument | Description |
|---|---|
<workflowId> | The workflowTemplateId from config.ts |
Options
| Option | Description | Default |
|---|---|---|
--process-instance-id <id> | Explicit process instance ID | Auto-resolved from project.json |
--project-file <path> | Path to custom project file (e.g., project-client-a.json) | project.json |
--path <path> | Path to use case folder with project.json | Current directory |
--payload-file <path> | Read payload from a JSON file, or - for stdin | — |
--poll | Wait for execution to complete | Fire-and-forget |
--timeout <seconds> | Max poll time | 120 |
-o, --output <path> | Save result to file (with --poll) | stdout |
--api-url <url> | Override API URL | — |
--api-key <key> | Override API key | — |
--profile <name> | Use a specific profile instead of the active one | — |
--json | JSON output | — |
Process instance ID resolution
--process-instance-idflag (highest priority)devProcessInstanceIdin--project-file(if provided)devProcessInstanceIdinproject.jsonat--pathdevProcessInstanceIdinproject.jsonin current directory
Behavior
Fire-and-forget (default)
Returns immediately with the execution ID:Poll for results (--poll)
Waits for the execution to complete, polling every 3-5 seconds:
Payload via stdin (recommended)
Use--payload-file - with a heredoc to pass JSON without shell escaping issues:
Payload from file
Save result to file
Result statuses
| Status | Meaning | Data field |
|---|---|---|
success | Workflow completed successfully | resultData contains output |
failed | Workflow encountered an error | errorDetails.message describes failure |
pending | Still running (only seen during polling) | — |
Examples
Error reference
| HTTP | Error | Cause | Fix |
|---|---|---|---|
| 401 | Invalid API key | Wrong or expired key | codika whoami, then codika login |
| 403 | Missing scope | Key lacks workflows:trigger | Create new key with scope |
| 403 | No access | Process in different org | codika use <profile> |
| 404 | Workflow not found | Wrong workflowId | Check config.ts workflowTemplateId |
| 412 | Instance inactive | Process paused or failed | Re-deploy or check platform |
Important notes
- Both HTTP and schedule triggers are supported
- Schedule triggers require a
manualTriggerUrlin config.ts (with a matching Webhook node in the workflow JSON) - The
workflowIdis theworkflowTemplateIdfrom config.ts, not the n8n workflow ID - For HTTP triggers: the request wraps your payload in
{"payload": {...}} - For schedule triggers: no payload needed (the workflow runs its own logic)
- Execution is asynchronous — the trigger returns immediately unless
--pollis used --pollworks for both trigger types- File uploads are not supported via CLI — use the platform UI