Async Jobs
Three endpoints for managing async solve jobs created by POST /optimize/async.
List jobs
GET
/api/v1/jobsReturns every tracked async job (all statuses) as a list of AsyncJobStatus.
curl https://api.fieldgenius.be/api/v1/jobs \
-H "X-API-Key: your-adapter-key" \
-H "X-Client-Key: your-client-key"import httpx
headers = {"X-API-Key": "your-adapter-key", "X-Client-Key": "your-client-key"}
resp = httpx.get("https://api.fieldgenius.be/api/v1/jobs", headers=headers)
for job in resp.json():
print(job["job_id"], job["status"])Get job status/result
GET
/api/v1/jobs/{job_id}Returns the AsyncJobStatus for one job, including the full result (an OptimizationResponse) once completed.
curl https://api.fieldgenius.be/api/v1/jobs/3fa6c1e2-9f0a-4b8d-8e35-1a2b3c4d5e6f \
-H "X-API-Key: your-adapter-key" \
-H "X-Client-Key: your-client-key"import httpx
job_id = "3fa6c1e2-9f0a-4b8d-8e35-1a2b3c4d5e6f"
headers = {"X-API-Key": "your-adapter-key", "X-Client-Key": "your-client-key"}
resp = httpx.get(f"https://api.fieldgenius.be/api/v1/jobs/{job_id}", headers=headers)
status = resp.json()
if status["status"] == "completed":
print(status["result"]["score"])Errors
| Status | Code | Resolution |
|---|---|---|
| 404 | JOB_ID_NOT_FOUND | The job ID does not exist. If the deployment does not have the durable job queue enabled (JOB_PERSISTENCE_ENABLED=false, the default), jobs are kept in memory only and this also happens after any process restart. With persistence enabled, job records survive a restart and are recovered automatically at startup, so a restart alone no longer causes this. |
Cancel a running job
POST
/api/v1/jobs/{job_id}/cancelAttempts to cancel a queued or running job. Returns the updated AsyncJobStatus on success.
curl -X POST https://api.fieldgenius.be/api/v1/jobs/3fa6c1e2-9f0a-4b8d-8e35-1a2b3c4d5e6f/cancel \
-H "X-API-Key: your-adapter-key" \
-H "X-Client-Key: your-client-key"import httpx
job_id = "3fa6c1e2-9f0a-4b8d-8e35-1a2b3c4d5e6f"
headers = {"X-API-Key": "your-adapter-key", "X-Client-Key": "your-client-key"}
resp = httpx.post(f"https://api.fieldgenius.be/api/v1/jobs/{job_id}/cancel", headers=headers)
print(resp.json()["status"]) # "cancelled"Errors
| Status | Code | Resolution |
|---|---|---|
| 404 | JOB_ID_NOT_FOUND | The job ID does not exist. |
| 409 | JOB_ALREADY_TERMINAL | The job already completed, failed, or was previously cancelled; check the current status field in the error context. |