Processing Tasks
Track document processing status
When you upload files or URLs, processing happens asynchronously. Use these endpoints to track progress.
List Tasks
curl -X GET "https://platform.protobox.ai/api/v1/knowledge/tasks" \
-H "Authorization: Bearer <access_token>"# Filter by status
curl -X GET "https://platform.protobox.ai/api/v1/knowledge/tasks?status=processing" \
-H "Authorization: Bearer <access_token>"Response
{
"success": true,
"data": {
"tasks": [
{
"id": "task_abc123",
"status": "completed",
"progress": 100,
"documentId": "695c71705a8b2ca8d9016050",
"result": {
"chunkCount": 12,
"wordCount": 3500,
"characterCount": 21000,
"processingTimeMs": 4500
},
"createdAt": "2024-01-15T10:30:00Z",
"completedAt": "2024-01-15T10:30:05Z"
},
{
"id": "task_def456",
"status": "processing",
"progress": 65,
"currentStep": "Generating embeddings...",
"createdAt": "2024-01-15T10:35:00Z"
}
],
"total": 2
}
}Query Parameters
statusstringFilter by status: pending, processing, completed, failed.
limitnumberdefault: 20Items per page.
Get Task Status
Request
curl -X GET "https://platform.protobox.ai/api/v1/knowledge/tasks/task_abc123" \
-H "Authorization: Bearer <access_token>"async function waitForTask(taskId) {
while (true) {
const response = await fetch(
`https://platform.protobox.ai/api/v1/knowledge/tasks/${taskId}`,
{ headers: { 'Authorization': 'Bearer ' + accessToken } }
);
const { data } = await response.json();
console.log(`Status: ${data.status} (${data.progress}%)`);
if (data.status === 'completed') {
return data;
}
if (data.status === 'failed') {
throw new Error(data.error);
}
await new Promise(r => setTimeout(r, 2000));
}
}
const result = await waitForTask('task_abc123');
console.log('Document ID:', result.documentId);
console.log('Chunks:', result.result.chunkCount);import time
import requests
def wait_for_task(task_id):
while True:
response = requests.get(
f'https://platform.protobox.ai/api/v1/knowledge/tasks/{task_id}',
headers={'Authorization': f'Bearer {access_token}'}
)
data = response.json()['data']
print(f"Status: {data['status']} ({data['progress']}%)")
if data['status'] == 'completed':
return data
if data['status'] == 'failed':
raise Exception(data.get('error', 'Processing failed'))
time.sleep(2)
result = wait_for_task('task_abc123')
print(f"Document ID: {result['documentId']}")Response
{
"success": true,
"data": {
"id": "task_abc123",
"status": "processing",
"progress": 65,
"currentStep": "Generating embeddings...",
"createdAt": "2024-01-15T10:30:00Z",
"startedAt": "2024-01-15T10:30:01Z"
}
}{
"success": true,
"data": {
"id": "task_abc123",
"status": "completed",
"progress": 100,
"documentId": "695c71705a8b2ca8d9016050",
"result": {
"chunkCount": 12,
"wordCount": 3500,
"characterCount": 21000,
"processingTimeMs": 4500
},
"createdAt": "2024-01-15T10:30:00Z",
"startedAt": "2024-01-15T10:30:01Z",
"completedAt": "2024-01-15T10:30:05Z"
}
}{
"success": true,
"data": {
"id": "task_abc123",
"status": "failed",
"progress": 25,
"error": "Failed to parse PDF: corrupted file",
"createdAt": "2024-01-15T10:30:00Z",
"startedAt": "2024-01-15T10:30:01Z",
"completedAt": "2024-01-15T10:30:02Z"
}
}Task Status Values
| Status | Description |
|---|---|
pending | Queued, waiting to start |
processing | Currently being processed |
completed | Successfully finished |
failed | Processing failed |
Processing Steps
When processing a document, you'll see these steps:
- Downloading - Fetching file from S3 or URL
- Parsing - Extracting text content
- Chunking - Splitting into overlapping chunks
- Generating embeddings - Creating vector embeddings
- Storing - Saving chunks to database
Result Fields
When status is completed:
| Field | Type | Description |
|---|---|---|
documentId | string | Created document ID |
chunkCount | number | Number of chunks created |
wordCount | number | Total word count |
characterCount | number | Total character count |
processingTimeMs | number | Processing duration |