Track background jobs
AI Assist
Some integrations hand work off to snapAddy and receive a job ID immediately. Use Job Management to show progress, handle failures, or request cancellation. Start with exporting VisitReport participants to download an Excel workbook, or triggering a DataAgents workflow to process a lead.
For an entire event, create and download an event export. For DataAgents, inspect run results and node logs.
Poll a job
Section titled “Poll a job”Keep the job’s id from the creation response. To discover recent jobs submitted by your account in the current organization, call GET /jobs. It defaults to the last 30 days. Use a personal API token for an account that can read the job.
JOBS=https://backend.snapaddy.com/job-management/jobs
curl --fail-with-body "$JOBS/$JOB_ID" \ -H "x-api-key: $SNAPADDY_API_KEY"const apiKey = process.env.SNAPADDY_API_KEY;if (!apiKey) throw new Error("Set SNAPADDY_API_KEY");const jobId = process.env.JOB_ID;if (!jobId) throw new Error("Set JOB_ID");
const response = await fetch(`https://backend.snapaddy.com/job-management/jobs/${encodeURIComponent(jobId)}`, { headers: { "x-api-key": apiKey },});if (!response.ok) throw new Error(`Request failed (${response.status})`);console.log(await response.json());import jsonimport osfrom urllib.parse import quotefrom urllib.request import Request, urlopen
request = Request( f"https://backend.snapaddy.com/job-management/jobs/{quote(os.environ['JOB_ID'], safe='')}", headers={"x-api-key": os.environ["SNAPADDY_API_KEY"]},)with urlopen(request, timeout=20) as response: print(json.load(response))state |
What to do |
|---|---|
waiting or active |
Poll again after a delay. Read progress when present. |
completed |
Stop polling. Use the result contract for the job type. |
failed |
Stop polling and check failedReason. |
canceled |
Stop polling and show that the job was canceled. |
Increase the polling interval when a job takes longer and set an overall timeout. Some job types expose a separate result endpoint. The job’s status, progress, and return value depend on its type.
Cancel a job or track a group
Section titled “Cancel a job or track a group”DELETE /jobs/{id} requests cancellation and returns 204. Poll the job again to see its final state. A worker may finish before it can act on the cancellation request.
A batch of workflow jobs can have a separate groupId. Use GET /jobs/groups to find groups in your organization and GET /jobs/groups/{groupId}/status for a group’s aggregate progress. If your account can cancel jobs in the group, DELETE /jobs/groups/{groupId} requests cancellation of waiting and active members. Jobs that have already finished retain their results.