Skip to main content

Check Execution Status

Get the status and results of an agent execution.

Endpoint

GET /api/v1/agents/{agentId}/executions/{executionId}

Authentication

Requires API key in Authorization header:

Authorization: Bearer pk_live_YOUR_API_KEY

Path Parameters

ParameterTypeDescription
agentIdstringThe agent ID
executionIdstringThe executionId returned from the execute call

Response

All responses return 200 OK. The shape depends on the current status.

Processing (in progress)

{
"executionId": "550e8400-e29b-41d4-a716-446655440000",
"agentId": "agent_123",
"status": "processing",
"percentage": 45,
"currentStep": "Calling model"
}

Completed

{
"executionId": "550e8400-e29b-41d4-a716-446655440000",
"agentId": "agent_123",
"status": "completed",
"percentage": 100,
"currentStep": "Processing",
"output": "Generated content here...",
"tokensUsed": 450,
"costUSD": 0.000045,
"latencyMs": 1250,
"executedAt": "2025-01-15T10:30:06Z"
}

Failed

{
"executionId": "550e8400-e29b-41d4-a716-446655440000",
"agentId": "agent_123",
"status": "failed",
"percentage": 30,
"currentStep": "Calling model",
"error": "Model timeout"
}

Response Fields

FieldTypePresent whenDescription
executionIdstringAlwaysExecution identifier
agentIdstringAlwaysAgent that was executed
statusstringAlwaysprocessing, completed, or failed
percentagenumberAlwaysProgress from 0 to 100
currentStepstringAlwaysHuman-readable current step
outputstringstatus = completedThe generated agent output
tokensUsednumberstatus = completedTotal tokens consumed
costUSDnumberstatus = completedExecution cost in USD
latencyMsnumberstatus = completedEnd-to-end latency in milliseconds
executedAtstringstatus = completedISO 8601 timestamp of completion
errorstringstatus = failedError message describing the failure

Polling Example

async function pollForResult(agentId, executionId) {
const maxAttempts = 30;
const pollInterval = 2000; // 2 seconds

for (let i = 0; i < maxAttempts; i++) {
const response = await fetch(
`https://api.promptick.ai/api/v1/agents/${agentId}/executions/${executionId}`,
{
headers: {
Authorization: `Bearer ${process.env.PROMPTICK_API_KEY}`,
},
}
);

const data = await response.json();

if (data.status === 'completed') {
return data.output;
}

if (data.status === 'failed') {
throw new Error(data.error);
}

await new Promise(resolve => setTimeout(resolve, pollInterval));
}

throw new Error('Execution timeout');
}