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 job ID returned from execute

Response

Queued

{
"executionId": "550e8400-e29b-41d4-a716-446655440000",
"status": "queued",
"agentId": "agent_123",
"createdAt": "2024-01-15T10:30:00Z"
}

Processing

{
"executionId": "550e8400-e29b-41d4-a716-446655440000",
"status": "processing",
"agentId": "agent_123",
"startedAt": "2024-01-15T10:30:05Z"
}

Completed

{
"executionId": "550e8400-e29b-41d4-a716-446655440000",
"status": "completed",
"agentId": "agent_123",
"result": {
"response": "Generated content here..."
},
"metadata": {
"tokensUsed": 450,
"latencyMs": 1250,
"costUSD": 0.000045,
"modelUsed": "gemini-1.5-flash"
},
"completedAt": "2024-01-15T10:30:06Z"
}

Failed

{
"executionId": "550e8400-e29b-41d4-a716-446655440000",
"status": "failed",
"error": "Model timeout",
"failedAt": "2024-01-15T10:30:30Z"
}

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.result;
}

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

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

throw new Error('Execution timeout');
}