Background Jobs
Some tasks take time, like processing a 100-page PDF or analyzing a video. Background jobs let you start these tasks and check back later.
Supported Job Types
Hebbrix creates jobs for long-running work; the type field on a job is one of:
rl_training- Start a reinforcement-learning training run on your memory store.bulk_import- Bulk-ingest documents or memories from an external source URL into a collection.data_export- Export memories / documents / collections into a downloadable archive.backup- Snapshot your account's data to durable storage.consolidation- Compress older memories while preserving important signal. Runs periodically.cleanup- Purge soft-deleted memories and orphaned index entries.
Job Statuses
Every job goes through these stages:
| Field | Type | Description |
|---|---|---|
| queued | status | Job is queued, waiting for a worker to pick it up |
| running | status | Job is currently being processed |
| completed | status | Job finished successfully. Results are available in result. |
| failed | status | Something went wrong. Check error_message and error_details. |
| cancelled | status | Job was cancelled via POST /v1/jobs/{job_id}/cancel before it finished. |
Endpoints
List your jobs with cursor-based pagination. Filter by type or status via query parameters.
Request body
| Field | Type | Description |
|---|---|---|
type | string | Filter by job type (query param) |
status | string | Filter by job status (query param) |
cursor | string | Pagination cursor from the previous page's next_cursor |
limit | integer | Items per page (default 50, max 100) |
Cancel a queued or running job. Returns the updated JobResponse with status = cancelled. Fails with 400 if the job is already completed, failed, or cancelled.
Delete a job record. Only jobs in a terminal state (completed, failed, or cancelled) can be deleted; cancel running jobs via POST /v1/jobs/{job_id}/cancel first. Returns 204 No Content on success.
Code Examples
List Your Jobs
import os
import requests
BASE = "https://api.hebbrix.com/v1"
H = {"Authorization": f"Bearer {os.environ['HEBBRIX_API_KEY']}"}
# GET /v1/jobs: jobs Hebbrix started for your account, newest first.
r = requests.get(f"{BASE}/jobs", headers=H, params={"status": "running", "limit": 20})
page = r.json()
for job in page["items"]:
print(job["id"], job["type"], job["status"])
job_id = page["items"][0]["id"] if page["items"] else NoneCheck Job Status
# GET /v1/jobs/{job_id}
r = requests.get(f"{BASE}/jobs/{job_id}", headers=H)
job = r.json()
# progress is a float (0.0 .. 100.0)
print(f"Status: {job['status']} progress: {job['progress']:.1f}%")
if job["status"] == "completed":
print("Done!", job["result"])
elif job["status"] == "failed":
print("Failed:", job["error_message"], job.get("error_details"))
elif job["status"] == "cancelled":
print("Cancelled before completion")Wait for Completion (Polling)
import time
TERMINAL = {"completed", "failed", "cancelled"}
def wait_for_job(job_id: str, max_wait: int = 300):
"""Poll GET /v1/jobs/{job_id} until terminal state, or timeout."""
start = time.time()
while True:
r = requests.get(f"{BASE}/jobs/{job_id}", headers=H)
job = r.json()
if job["status"] == "completed":
return job["result"]
if job["status"] == "failed":
raise RuntimeError(job["error_message"])
if job["status"] == "cancelled":
raise RuntimeError("Job was cancelled")
if time.time() - start > max_wait:
raise TimeoutError("Job did not finish in time")
print(f"Status: {job['status']} ({job['progress']:.1f}%)")
time.sleep(5)
result = wait_for_job(job_id)
print(f"Imported {result.get('memories_created', 0)} memories!")Cancel a Job
# POST /v1/jobs/{job_id}/cancel: cancel a queued or running job.
# Returns the updated JobResponse with status = "cancelled".
r = requests.post(f"{BASE}/jobs/{job_id}/cancel", headers=H)
r.raise_for_status()
print("Job cancelled:", r.json()["status"])
# Once terminal, DELETE /v1/jobs/{job_id} removes the record:
requests.delete(f"{BASE}/jobs/{job_id}", headers=H)- Save job IDs! You need them to check status later
- Don't poll too frequently; every 5-10 seconds is enough
- Job records are kept until you delete them with
DELETE /v1/jobs/{job_id}(completed, failed or cancelled jobs only). Smart-ingestion jobs polled at/v1/memory-jobs/{job_id}are a separate record that expires one hour after it finishes - You can have multiple jobs running at once