Skip to content

Jobs and events

Writes that change a server return 202 with a Job. Follow it over server-sent events, poll it, or group it.

Every change to a server runs as a job: creating a site, clearing a cache, restarting PHP, deploying a commit, changing a setting. The API does not block while the server works. It records the job and returns it to you at once.

The 202 response

A write that changes a server returns 202 Accepted with a Job object in the body and a Location header that points at GET /v1/jobs/{id}.

curl -s -i -X POST https://api.wpwaterfall.com/v1/environments/ENV_ID/tools/cache/clear \
  -H "Authorization: Bearer wpw_live_YOUR_SECRET" \
  -H "Idempotency-Key: 3b1e-cache-1"

Some routes return the Job object plus something else, such as the login link from POST /v1/environments/{id}/wp-admin-login or the session from POST /v1/environments/{id}/database/phpmyadmin-session. Read the job first, then use the extra value after the job succeeds.

A job has one of these status values: queued, dispatched, running, succeeded, failed, or cancelled. A failed job carries a plain-words reason. You cannot cancel a job through the API or the dashboard: a job that stops half way could leave a site broken, so wait for it to finish and act on the result. The dashboard view of the same jobs is in Jobs and progress.

Follow a job

Open the event stream.

curl -s -N https://api.wpwaterfall.com/v1/jobs/JOB_ID/events \
  -H "Authorization: Bearer wpw_live_YOUR_SECRET" \
  -H "Accept: text/event-stream"

GET /v1/jobs/{id}/events sends server-sent events. Each data field is a JobEvent. The stream replays the events so far, then follows new ones until the job ends. Open it late and you still get the full story.

If you cannot hold a connection open, poll GET /v1/jobs/{id} and read the job's state. Back off between polls; see Rate limits.

List recent jobs with GET /v1/jobs.

Job groups and bulk actions

A bulk action runs one change across many environments. POST /v1/bulk clears caches, changes PHP settings, or applies labels across environments. It returns a job group: one parent and one child job per environment.

Read GET /v1/job-groups/{id} for the per-site results. Each child has its own outcome, so one failure does not stop the others.

Removing several domains with DELETE /v1/environments/{id}/domains also runs as one group with one removal job per domain.

Rules for job-creating routes

  • Send an Idempotency-Key on every POST. A retry with the same key and body returns the same job instead of starting a second one. See Idempotency.
  • Job-creating routes have their own, lower limit. See Rate limits.
  • Destructive routes need confirmation. A DELETE takes ?confirm=true in the query, as in DELETE /v1/sites/{id}?confirm=true, DELETE /v1/environments/{id}?confirm=true, and DELETE /v1/backups/{id}?confirm=true. A real run of POST /v1/environments/{id}/tools/search-replace needs dry_run: false in the body.
  • POST /v1/sites/{id}/reset takes confirm: true and confirm_name, the exact site name, in the body.

Endpoints

  • GET /v1/jobs
  • GET /v1/jobs/{id}
  • GET /v1/jobs/{id}/events
  • GET /v1/job-groups/{id}
  • POST /v1/bulk

Still stuck?

Email support at wpwaterfall dot com with your site name and what you tried, or send us a message.