Protobox

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

statusstring

Filter by status: pending, processing, completed, failed.

limitnumberdefault: 20

Items 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

StatusDescription
pendingQueued, waiting to start
processingCurrently being processed
completedSuccessfully finished
failedProcessing failed

Processing Steps

When processing a document, you'll see these steps:

  1. Downloading - Fetching file from S3 or URL
  2. Parsing - Extracting text content
  3. Chunking - Splitting into overlapping chunks
  4. Generating embeddings - Creating vector embeddings
  5. Storing - Saving chunks to database

Result Fields

When status is completed:

FieldTypeDescription
documentIdstringCreated document ID
chunkCountnumberNumber of chunks created
wordCountnumberTotal word count
characterCountnumberTotal character count
processingTimeMsnumberProcessing duration

On this page