Video generation API cancel request: understand local cancellation and refunds
·
A video generation API cancel request is different from closing a progress dialog. Genace implements POST /api/v1/jobs/{id}/cancel for an owned job. For an eligible active job with both upstream handles and no uncertain-outcome marker, the service invokes its credit refund path and records canceled with zero actual credits. The implementation does not call the upstream provider’s cancellation API, so it does not promise that the provider physically stops rendering.
That distinction matters for product wording. A canceled Genace job is a terminal gateway outcome. A disconnected browser is only a disconnected observer. A client-side AbortController does not invoke the cancellation route or establish that any credits were refunded.
Choose the intended operation
| User intent | Application action | Credit implication |
|---|---|---|
| Hide progress | Stop or hide the observer | No refund established |
| Leave and return later | Save the job ID and resume collection | Existing job remains in progress |
| Cancel an eligible known-handle active job | Call the cancel endpoint and inspect its response | Service invokes refund and records zero actual credits |
| Cancel an unknown or missing-handle job | Reconcile the original attempt | HTTP 409; state and reservation remain unchanged |
| Cancel an already successful job | Endpoint returns the existing terminal state | Do not infer a refund |
The current service returns terminal jobs unchanged. Cancellation is therefore not a way to retroactively turn a succeeded render into a refunded cancellation. Preserve the actual returned state rather than showing canceled unconditionally when the HTTP request succeeds.
Call the implemented endpoint
This command changes the selected job’s state only when it remains active and eligible. Run it only for a job you deliberately intend to cancel. It does not create a generation, and it must use credentials belonging to the owner.
curl --fail-with-body --request POST \
"https://genace.ai/api/v1/jobs/$GENACE_JOB_ID/cancel" \
-H "Authorization: Bearer $GENACE_API_KEY"
The route returns id, state, and canceled_at. For a job that was already terminal, the state remains its existing value. The timestamp field is populated from finishedAt, so do not use the field name alone as proof that a cancellation transition occurred.
Reconcile the result
After a successful cancellation response, save the returned state and read the job snapshot if you need credits_actual or the complete terminal record. Stop future collection messages once the terminal outcome is saved, and release the application’s active-render permit according to its normal terminal reconciliation rules.
If the cancellation request loses its connection, read the existing job before deciding what to show. The outcome may already have been recorded. Do not submit a replacement simply because cancellation confirmation was delayed; a replacement is another authorized generation decision.
Common mistakes include labeling a local stop button as a guaranteed upstream abort, assuming every successful cancel HTTP response means state canceled, and promising a refund from an aborted GET. Another is deleting the original record, which loses the evidence needed for credit reconciliation.
Verification checklist
Use fixtures for canceling an active job, canceling an already succeeded job, a 403 ownership rejection, and a lost cancellation response. Confirm that the UI follows the returned state, preserves the identifier, and never equates hidden progress with refunded work.
Related guides cover job states, 402 errors, and resuming jobs.
Unknown submission outcomes need reconciliation
Transport failures and malformed acceptance responses use
UPSTREAM_SUBMISSION_UNCERTAIN, preserve the queued reservation, and do not
trigger another creation request. Nonterminal jobs with an uncertain marker
or either missing upstream handle cannot be canceled into a refund: the route
returns HTTP 409 SUBMISSION_RECONCILIATION_REQUIRED, including when saving
the uncertainty marker failed. Legacy failure codes without rejection evidence
need manual investigation, not bulk balance changes. Read
the unknown-submission reference.
Continue with production operations
Where these facts come from
- codebase: src/ai/providers/fal-client.ts
- codebase: src/app/api/v1/jobs/[id]/cancel/route.ts
- codebase: src/ai/jobs/service.ts
- codebase: src/ai/api/credits.ts
- Editorial keyword hypothesis; search volume not measured