Skip to content

Execution Mode 2: Background Task (Recommended)

Background task mode provides asynchronous execution with two separate endpoints: one to start the flow and another to check its status. This is the recommended approach for most autonomous flows.

Benefits:

  • Maximum execution time: 2700 seconds (45 minutes)
  • Suitable for complex, multi-step workflows
  • Real-time progress tracking through logs
  • Non-blocking API calls
POST https://app.phinite.ai/api/v1/ai/trigger/start/{workspace_id}/{trigger_id}/{environment}
{
"message": "start the task",
"user_variables": {
"key1": "value1",
"key2": "value2"
}
}
{
"workflow_id": "workflowid-uuid",
"response": {},
"status": "pending",
"logs": [],
"requires_input": false,
"error": null
}

The workflow_id returned in this response is used to track the status of the flow execution.

GET https://ai-core.phinite.ai/trigger/status/{workspace_id}/{workflow_id}

The status endpoint can return one of three statuses with HTTP 200:

  • pending - Agent Graph is still executing
  • completed - Agent Graph finished successfully
  • failed - Agent Graph encountered an error

While the flow is executing, the status endpoint returns real-time logs:

{
"workflow_id": "workflowid-uuid",
"response": {},
"status": "pending",
"logs": [
{
"time": "2026-02-09 23:24:39",
"level": "tool_call",
"node_id": "Agent 1",
"message": "Tool Invoked with parameters",
"status": "running",
"user_logs_type": ""
}
],
"requires_input": false,
"error": null
}

When the flow finishes successfully:

{
"workflow_id": "workflowid-uuid",
"response": {
"workflow_id": "workflowid-uuid",
"key1": "value1",
"key2": "value2"
// ... all session variables
},
"status": "completed",
"logs": [
...,
{
"time": "2026-02-09 23:25:01",
"level": "info",
"node_id": "flow",
"message": "Graph execution completed successfully",
"status": "success",
"user_logs_type": ""
}
],
"requires_input": false,
"error": null
}

The response object contains the workflow_id and all session variables that were set during flow execution.

If the flow encounters an error:

{
"workflow_id": "workflowid-uuid",
"response": {},
"status": "failed",
"logs": [...],
"requires_input": false,
"error": "Detailed error message"
}