Skip to content

Powered by Grav CMS + Helios Theme

Jobs

The background job queue: what is pending, what failed, and running or cancelling one by hand.

KahunaCart does slow work in a queue: emails, exports, index rebuilds, provider syncs. These routes read the queue and act on one job. Queue health also rides along on GET /kahunacart/config. See Hardening.

List queued jobs

GET /api/v1/kahunacart/jobs Permission kahunacart.settings

A page of the job queue, newest first: every job with its state — pending, running, complete, failed or cancelled — its arguments, when it was queued and started, how long it took, how many attempts of how many, the worker that held it and the last error, plus the counts per state. This is where a missing confirmation email is found.

Parameters

Name Type Description
state optional string
One of: pending, running, complete, failed, cancelled
type optional string One job type, e.g. order.confirmation_email
sort optional string A column to sort the whole list by before it is paged; leave out for the usual order
One of: id, type, state, attempts, queued, started, took, error
dir optional string
One of: asc, desc
Default: asc
page optional integer
per_page optional integer

Run a job now

POST /api/v1/kahunacart/jobs/{id}/run Permission kahunacart.settings

Release a job for the next worker tick, whatever it was waiting for; a failed job is granted one more attempt. Nothing runs inside the request. 409 when the job is running or already complete.

Parameters

Name Type Description
id required integer Job id

Cancel a job

POST /api/v1/kahunacart/jobs/{id}/cancel Permission kahunacart.settings

Cancel a pending job outright, or ask a running one to stop: the flag is read at a transaction boundary, so a bulk change stops between orders and nothing half-written is left. The answer's outcome is cancelled or requested. 409 when the job has already finished.

Parameters

Name Type Description
id required integer Job id