Skip to content

Jobs API

The Jobs API allows you to monitor and manage background jobs for indexing, syncing, and find-and-replace operations.

Get all background jobs with optional filtering and pagination.

GET /api/v1/jobs
ParameterTypeDescription
typestringFilter by job type (index, sync, replace)
statusstringFilter by status
exclude_statusstringExclude jobs with this status (e.g., completed)
repostringFilter by repository name (partial match)
limitintegerResults per page (default: 50, max: 500)
offsetintegerPagination offset
{
"jobs": [
{
"id": "job_abc123",
"type": "index",
"status": "running",
"payload": {
"repository_id": 1,
"connection_id": 1,
"repo_name": "myorg/api",
"clone_url": "https://github.com/myorg/api.git",
"branch": "main"
},
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:05Z",
"started_at": "2024-01-15T10:30:05Z",
"progress": {
"current": 823,
"total": 1234,
"message": "Indexing files..."
}
},
{
"id": "job_def456",
"type": "sync",
"status": "completed",
"payload": {
"connection_id": 1
},
"created_at": "2024-01-15T10:28:00Z",
"updated_at": "2024-01-15T10:29:45Z",
"started_at": "2024-01-15T10:28:02Z",
"completed_at": "2024-01-15T10:29:45Z"
}
],
"total_count": 156,
"limit": 50,
"offset": 0,
"has_more": true
}

Get a specific job by ID.

GET /api/v1/jobs/{id}
{
"id": "job_abc123",
"type": "index",
"status": "running",
"payload": {
"repository_id": 1,
"connection_id": 1,
"repo_name": "myorg/api",
"clone_url": "https://github.com/myorg/api.git",
"branch": "main"
},
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:32:00Z",
"started_at": "2024-01-15T10:30:05Z",
"progress": {
"current": 823,
"total": 1234,
"message": "Indexing files..."
}
}
{
"id": "job_xyz789",
"type": "index",
"status": "failed",
"payload": {
"repository_id": 2,
"connection_id": 1,
"repo_name": "myorg/broken-repo",
"clone_url": "https://github.com/myorg/broken-repo.git",
"branch": "main"
},
"error": "Failed to clone repository: authentication required",
"created_at": "2024-01-15T10:25:00Z",
"updated_at": "2024-01-15T10:26:00Z",
"started_at": "2024-01-15T10:25:05Z",
"completed_at": "2024-01-15T10:26:00Z"
}

Cancel a pending job. Only jobs with status pending can be cancelled.

POST /api/v1/jobs/{id}/cancel
{
"status": "cancelled",
"message": "Job cancelled"
}

Remove old completed and failed jobs. This helps prevent Redis from growing indefinitely.

POST /api/v1/jobs/cleanup
ParameterTypeDescription
max_age_hoursintegerMaximum age in hours for jobs to keep (default: 1)
{
"status": "ok",
"deleted_count": 42,
"scanned_count": 150,
"max_age_hours": 1,
"message": "Cleanup completed"
}

Cancel all pending and/or running jobs matching the given filters. Only pending and running jobs can be cancelled.

POST /api/v1/jobs/cancel-all
ParameterTypeDescription
typestringFilter by job type (index, sync, replace)
statusstringFilter by status (pending, running)
{
"status": "ok",
"processed": 25,
"succeeded": 24,
"failed": 1,
"message": "Bulk operation completed"
}

Delete all completed and/or failed jobs matching the given filters. Only completed and failed jobs can be deleted.

POST /api/v1/jobs/delete-all
ParameterTypeDescription
typestringFilter by job type (index, sync, replace)
statusstringFilter by status (completed, failed)
{
"status": "ok",
"processed": 150,
"succeeded": 150,
"failed": 0,
"message": "Bulk operation completed"
}
DELETE /api/v1/jobs?confirm=true
ParameterTypeRequiredDescription
confirmstringYesMust be "true" to confirm deletion
{
"status": "ok",
"processed": 500,
"succeeded": 500,
"failed": 0,
"message": "Bulk operation completed"
}
Terminal window
# List all jobs
curl "http://localhost:8080/api/v1/jobs"
# Filter by status
curl "http://localhost:8080/api/v1/jobs?status=running"
# Hide completed jobs
curl "http://localhost:8080/api/v1/jobs?exclude_status=completed"
# Filter by type
curl "http://localhost:8080/api/v1/jobs?type=index"
# Filter by repo name (partial match)
curl "http://localhost:8080/api/v1/jobs?repo=myorg"
# Pagination
curl "http://localhost:8080/api/v1/jobs?limit=20&offset=0"
# Get specific job
curl "http://localhost:8080/api/v1/jobs/job_abc123"
# Cancel job
curl -X POST "http://localhost:8080/api/v1/jobs/job_abc123/cancel"
# Cleanup old jobs (default 1 hour)
curl -X POST "http://localhost:8080/api/v1/jobs/cleanup"
# Cleanup jobs older than 2 hours
curl -X POST "http://localhost:8080/api/v1/jobs/cleanup?max_age_hours=2"
# Bulk cancel all pending index jobs
curl -X POST "http://localhost:8080/api/v1/jobs/cancel-all?type=index&status=pending"
# Bulk cancel all pending jobs (any type)
curl -X POST "http://localhost:8080/api/v1/jobs/cancel-all?status=pending"
# Bulk delete all completed jobs
curl -X POST "http://localhost:8080/api/v1/jobs/delete-all?status=completed"
# Bulk delete all failed sync jobs
curl -X POST "http://localhost:8080/api/v1/jobs/delete-all?type=sync&status=failed"
# Delete ALL jobs (dangerous!)
curl -X DELETE "http://localhost:8080/api/v1/jobs?confirm=true"
TypeDescription
indexIndex a repository for searching
syncSync repositories from a code host connection
replaceFind-and-replace operation across repositories

Each job type has a specific payload structure:

{
"repository_id": 1,
"connection_id": 1,
"repo_name": "myorg/api",
"clone_url": "https://github.com/myorg/api.git",
"branch": "main"
}
{
"connection_id": 1
}
{
"search_pattern": "oldFunction",
"replace_with": "newFunction",
"is_regex": false,
"case_sensitive": true,
"file_patterns": ["*.go", "*.ts"],
"matches": [
{"repository_id": 1, "repository_name": "myorg/api", "file_path": "internal/service.go"},
{"repository_id": 1, "repository_name": "myorg/api", "file_path": "internal/handler.go"}
],
"branch_name": "refactor/rename-function",
"mr_title": "Rename oldFunction to newFunction",
"mr_description": "Automated refactoring"
}
StatusDescription
pendingWaiting in queue
runningCurrently executing
completedFinished successfully
failedError occurred (check error)