Skip to main content
GET
/
api
/
v1
/
tasks
/
{id}
Get Task
curl --request GET \
  --url https://api.example.com/api/v1/tasks/{id}

Documentation Index

Fetch the complete documentation index at: https://docs.sigmic.ai/llms.txt

Use this file to discover all available pages before exploring further.

Get Task

Retrieve the details and current status of a specific task, including accumulated output and any pending tool approvals.

Request

GET /api/v1/tasks/{id}
Authorization: Bearer {api_key}

Path Parameters

ParameterTypeDescription
idstringThe unique task identifier

Response

Running Task with Pending Approvals

When a task requires tool approval, the response includes a pendingApprovals array:
{
  "success": true,
  "data": {
    "id": "c37c1d78-4d23-4e53-949a-ddd775f25e01",
    "apiKeyId": "82344182-b81e-4f9a-8e7f-c14d8324caac",
    "username": "testuser",
    "sessionId": "80513b3f-9030-4776-a209-f2d96b1abce1",
    "conversationId": "1769442659997-70avfyadp",
    "status": "awaiting_approval",
    "message": "List all files in the project",
    "systemPrompt": null,
    "showInHistory": true,
    "autoExecute": false,
    "env": null,
    "error": null,
    "createdAt": "2026-01-26T15:50:54.870Z",
    "startedAt": "2026-01-26T15:50:59.998Z",
    "completedAt": null,
    "output": {
      "content": "I'll list the files for you...",
      "updatedAt": "2026-01-26T15:51:02.123Z",
      "thoughts": [
        { "subject": "Analyzing", "description": "Looking at the project structure..." }
      ],
      "toolCalls": [
        {
          "callId": "call_123",
          "toolName": "list_files",
          "status": "awaiting_approval",
          "args": { "path": "/uploads" }
        }
      ]
    },
    "pendingApprovals": [
      {
        "callId": "call_123",
        "toolName": "list_files",
        "args": { "path": "/uploads" }
      }
    ]
  }
}

Completed Task

When a task is completed, output contains the final response:
{
  "success": true,
  "data": {
    "id": "c37c1d78-4d23-4e53-949a-ddd775f25e01",
    "apiKeyId": "82344182-b81e-4f9a-8e7f-c14d8324caac",
    "username": "testuser",
    "sessionId": "80513b3f-9030-4776-a209-f2d96b1abce1",
    "conversationId": "1769442659997-70avfyadp",
    "status": "completed",
    "message": "What is 2+2?",
    "systemPrompt": null,
    "showInHistory": true,
    "autoExecute": true,
    "env": null,
    "error": null,
    "createdAt": "2026-01-26T15:50:54.870Z",
    "startedAt": "2026-01-26T15:50:59.998Z",
    "completedAt": "2026-01-26T15:56:03.070Z",
    "output": {
      "content": "The answer to 2+2 is 4.",
      "updatedAt": "2026-01-26T15:56:03.070Z",
      "thoughts": [
        { "subject": "Calculating", "description": "Performing basic arithmetic" }
      ],
      "toolCalls": []
    }
  }
}

Response Fields

FieldTypeDescription
idstringUnique task identifier
apiKeyIdstringID of the API key used to create the task
usernamestringUsername associated with the API key
sessionIdstringID of the agent session
conversationIdstringID of the conversation for history
statusstringCurrent task status
messagestringOriginal task message
systemPromptstring | nullCustom system prompt if provided
showInHistorybooleanWhether task appears in conversation history
autoExecutebooleanWhether tools auto-execute
envobject | nullNon-sensitive env vars provided at creation
errorstring | nullError message if task failed
createdAtstringISO timestamp when task was created
startedAtstring | nullISO timestamp when execution started
completedAtstring | nullISO timestamp when task completed
outputobject | undefinedAccumulated output (present for running and completed tasks)
pendingApprovalsarray | undefinedTool calls awaiting approval (present when non-empty)

Output Object

The output field provides a unified view of the task’s response, whether the task is still running or has completed. Use the status field to determine if the content is partial (running) or final (completed/failed/cancelled).
FieldTypeDescription
contentstringAccumulated text response (partial while running, final when completed)
updatedAtstringISO timestamp when the output was last updated
thoughtsarray | undefinedAgent’s thinking process entries
toolCallsarray | undefinedTool executions with their current status

Tool Call Structure

Each entry in toolCalls has the following structure:
FieldTypeDescription
callIdstringUnique identifier for the tool call
toolNamestringName of the tool being executed
statusstringTool execution status
argsobjectArguments passed to the tool
outputstringTool output (when completed)
descriptionstringHuman-readable description of the tool call
Tool Call Status Values:
StatusDescription
pendingTool call queued, not yet started
awaiting_approvalWaiting for user approval
executingCurrently running
successCompleted successfully
errorFailed with an error
cancelledUser cancelled the call

Task Status Values

StatusDescription
pendingTask created, not yet started
runningTask is currently executing
awaiting_approvalWaiting for tool call approval
completedTask finished successfully
failedTask failed with an error
cancelledTask was cancelled
Use output.updatedAt to track when content was last accumulated. This is useful for detecting changes when polling.

Examples

curl -s https://api.sigmic.ai/api/v1/tasks/c37c1d78-4d23-4e53-949a-ddd775f25e01 \
  -H "Authorization: Bearer sigmic_your_key_here"

Use Cases

Polling for Progress

Use the output field to show real-time progress without maintaining an SSE connection:
async function pollTaskProgress(taskId, onProgress, maxAttempts = 120) {
  let lastUpdatedAt = null;

  for (let i = 0; i < maxAttempts; i++) {
    const response = await fetch(
      `https://api.sigmic.ai/api/v1/tasks/${taskId}`,
      { headers: { 'Authorization': 'Bearer sigmic_your_key_here' } }
    );

    const { data: task } = await response.json();

    // Check if output has been updated since last poll
    if (task.output && task.output.updatedAt !== lastUpdatedAt) {
      lastUpdatedAt = task.output.updatedAt;
      onProgress({
        content: task.output.content,
        thoughts: task.output.thoughts || [],
        toolCalls: task.output.toolCalls || [],
        updatedAt: task.output.updatedAt,
        isComplete: ['completed', 'failed', 'cancelled'].includes(task.status)
      });
    }

    // Check if task ended
    if (['completed', 'failed', 'cancelled'].includes(task.status)) {
      if (task.status === 'completed') {
        return task;
      }
      throw new Error(`Task ${task.status}: ${task.error}`);
    }

    // Poll every 500ms for responsive updates
    await new Promise(resolve => setTimeout(resolve, 500));
  }

  throw new Error('Task did not complete in time');
}

// Usage
pollTaskProgress('task-123', (progress) => {
  console.log('Content:', progress.content);
  console.log('Last updated:', progress.updatedAt);
  if (progress.isComplete) {
    console.log('Final result received!');
  }
});

Polling for Completion (Simple)

If you only need to check final task status:
async function waitForCompletion(taskId, maxAttempts = 60) {
  for (let i = 0; i < maxAttempts; i++) {
    const response = await fetch(
      `https://api.sigmic.ai/api/v1/tasks/${taskId}`,
      { headers: { 'Authorization': 'Bearer sigmic_your_key_here' } }
    );

    const { data: task } = await response.json();

    if (task.status === 'completed') {
      console.log('Final response:', task.output?.content);
      return task;
    }

    if (task.status === 'failed' || task.status === 'cancelled') {
      throw new Error(`Task ${task.status}: ${task.error}`);
    }

    // Wait 1 second before polling again
    await new Promise(resolve => setTimeout(resolve, 1000));
  }

  throw new Error('Task did not complete in time');
}

Checking for Pending Approvals

The pendingApprovals array provides a convenient way to discover tool calls awaiting approval without an active SSE connection:
const { data: task } = await response.json();

if (task.pendingApprovals?.length > 0) {
  for (const approval of task.pendingApprovals) {
    console.log(`Tool "${approval.toolName}" requires approval`);
    console.log('Args:', approval.args);
    console.log('Call ID:', approval.callId);

    // Approve the tool call
    await fetch(
      `${BASE_URL}/api/v1/tasks/${task.id}/tools/${approval.callId}/approve`,
      {
        method: 'POST',
        headers: {
          'Authorization': 'Bearer sigmic_your_key_here',
          'Content-Type': 'application/json'
        },
        body: JSON.stringify({ outcome: 'proceed_once' })
      }
    );
  }
}

Pending Approval Object

FieldTypeDescription
callIdstringTool call ID (use with the approve endpoint)
toolNamestringName of the tool awaiting approval
argsobjectArguments that will be passed to the tool

Errors

CodeDescription
AUTH_REQUIREDNo authentication provided
INVALID_API_KEYInvalid or expired API key
NOT_FOUNDTask with the specified ID was not found