Sume cancel returns 409 job_generation_already_started: what now?

POST /v1/jobs/{id}/cancel works only before generation starts. After that, 409 with details.cancelable false and the job runs to completion.

5 min readSume
All posts

POST /v1/jobs/{id}/cancel succeeds only before generation work starts. After that, Sume returns 409 job_generation_already_started with details.cancelable: false, and the job runs to completion. Cancel early, or accept the result. Canceling a job that is already canceled is idempotent and returns the same canceled job.

What each answer means

Three outcomes are possible, and each one has a distinct handler.

ResponseMeaningYour move
200 canceled jobCancel landed before generationDone
409 job_generation_already_startedProvider work beganKeep polling; use the result
409 job_not_cancelableJob is in a state that cannot be canceledRead the job record

Cancel as soon as you know

The window is early, while a job is queued. Because paid jobs can sit as queued when workspace concurrency is busy, a queued job is the best candidate to cancel. Only the member whose key created a job can cancel it.

Do not rely on client timeouts

A client-side timeout does not cancel anything. The job continues to run and bill. If you stop waiting, store the id and either read it later or cancel explicitly.

curl -X POST https://api.sume.com/v1/jobs/job_123/cancel \
  -H "Authorization: Bearer $SUME_API_KEY"
# 409 + details.cancelable=false -> let it finish, then read /result

Fail-safe pattern

On a 409, switch from canceling to waiting. Poll status, fetch the result, and discard it in your own code if you no longer need it. Treat the spend as incurred, and fix the upstream decision that produced a job you wanted to cancel late.

Related posts

More in Developers

All Developers posts

Written by Sume