Long-running operations
Work that takes minutes: what the first answer says and how to follow it.
3 min read Updated
Setting up a server takes minutes; installing a site, a minute or two. Operations like these answer at once, before the work is done, with the resource in an in-between status. You then follow the work until it's finished: by reading the resource now and then, or by letting a webhook tell you.
Which operations
They're marked Asynchronous in the reference, and answer 202 Accepted (201 Created for a create)
with the resource as it is at that moment. How long each usually takes, in its own reference's words:
| Operation | What happens next |
|---|---|
| Create a server | It's usually ready in about 5 minutes: poll GET /servers/{serverId} every 10 seconds until status is active. |
| Destroy a server | Answers 202 with status: "deleting" while the server is removed (usually a minute or two; GET /servers/{serverId} then answers 404), or 200 with status: "deleted" when the server was never paid for and is removed at once. |
| Power on a server | Answers with pendingAction: "power_on"; the server is usually active again within a minute or two. |
| Power off a server | Answers with pendingAction: "power_off"; status is off within a minute or two. |
| Reboot a server | Its sites are offline for the minute or two it takes. |
| Resize a server | Its sites are offline for a few minutes while it's resized; pendingAction is resize until it's done, and planId and priceMonthlyCents change then. |
| Retry a failed server setup | Usually ready in about 5 minutes. |
| Take a snapshot | It takes a few minutes: pendingAction is snapshot until it's done, and the snapshot is then in the server's list. |
| Restore a server from a snapshot | Everything on the server since then is lost, every site included, and the sites are offline while it's restored (usually a few minutes; pendingAction is restore until it's done). |
| Check the connection to your own server again | Follow its status or pendingAction until the change is done. |
| Create a site | On a running server the install starts at once and usually takes 1 to 2 minutes (installing, with stage wordpress, then ssl); on a server that's still being set up it starts as soon as the server is ready. |
| Delete a site | Answers 202 with status: "deleting" while it's removed from its server (usually under a minute; GET /sites/{siteId} then answers 404), or 200 with status: "deleted" when it was never installed and is removed at once. |
| Retry a failed site install | The site goes back to queued and installs as soon as its server is running, usually in 1 to 2 minutes. |
| Ask for the site's SSL certificate again | It's queued at once (sslStatus: "pending") and usually done within a few minutes: follow it on GET /sites/{siteId}. |
| Connect a domain to a site | If it already points at the server, the answer has status: "provisioning": the domain is set up on the server and its SSL certificate issued, usually within a few minutes. |
| Check a domain's DNS now | Checks now that the domain points at the site's server. When it does, the answer is 202 with status: "provisioning": the domain is set up on the server and its SSL certificate issued, usually within a few minutes. |
| Make a domain the site's primary domain | For a verified domain the change is put in place on the server at once (202; the site's pendingAction is domain for a moment). |
| Turn on a site's CDN | Setting it up usually takes 3 to 10 minutes (stage: creating, deploying, verifying, then installing); poll GET /sites/{siteId}/cdn every 30 seconds until status is active, when the site's files are served from domain. |
| Clear files from a site's CDN | The answer is 202 with purging: true; clearing takes a minute or two, then purging is false again and purgedAt is set. |
| Add a custom hostname to a site's CDN | The answer is 202 with customHostname.status: "validating" and the DNS records to add, in customHostname.records: one proves the hostname is yours (for its SSL certificate; it appears a few seconds after this call), one sends its visitors to the CDN. |
| Change a site's firewall settings | The answer is the firewall with status: "applying" (or installing while the firewall is first set up on the server, a few minutes): the change reaches the server within seconds, then status is active. |
| Apply a site's firewall settings again | Follow its status until the change is done. |
| Turn a site's Cloudflare protection on or off | Turning off takes up to 15 minutes; domains still pointed at edge keep working (stillPointed). |
| Turn on a server's security | A few minutes later it's on (server.security_enabled), or failed (server.security_failed; turn it on again to retry). |
| Turn off a server's security | Follow its status until the change is done. |
| Scan a server's sites for malware | Follow its status until the change is done. |
| Install KernelCare on a server | Follow its status until the change is done. |
| Check a server's domains against blacklists | Follow its status until the change is done. |
| Turn on Imunify360's WordPress plugin | Turns Imunify360's WordPress plugin (Imunify Security) on for the server: it goes onto every site with malware protection on, one after another (about a minute each), and onto each site that gets malware protection later. |
| Turn off Imunify360's WordPress plugin | Follow its status until the change is done. |
| Scan a site for malware | Follow its status until the change is done. |
| Change Imunify360's WordPress plugin in a site | Changes Imunify360's WordPress plugin in the site: adds it (about a minute) or takes it off, and turns its firewall and AI bot protection on or off. |
| Set a site's resources | Follow its status until the change is done. |
| Run a cron job now | Follow its status until the change is done. |
| Back a site up now | A backup takes from a minute to an hour or more, by the site's size, and waits its turn while another backup or a staging operation runs on the server. |
| Restore a site from a backup | While it runs the site's pendingAction is restore; afterwards the site's domains are applied to it again. |
| Create a staging copy | It usually takes a few minutes, depending on the site's size. |
| Refresh the staging copy from the live site | It usually takes a few minutes. |
| Push the staging copy to the live site | Follow its status until the change is done. |
| Undo a push to the live site | Follow its status until the change is done. |
| Delete the staging copy | Answers 202 with the copy deleting while it's removed from the server (usually under a minute; copy is then null). |
| Clone a site | The new site is installed first, then the copy is made into it, usually in a few minutes. |
| Try a failed clone again | Follow its status until the change is done. |
| Install or update RabbitPress Cache on a site | The answer is 202 with busy: true: the plugin is installed on the site's server, usually within a minute or two. |
| Remove RabbitPress Cache from a site | The answer is 202 with busy: true: the plugin is removed on the site's server, usually within a minute. |
| Turn on Media Offload for a site | Follow its status until the change is done. |
| Set Media Offload's settings for a site | The answer is 202 with settingsStatus: "applying": the site's server gets them within a minute, and files they newly include are copied. |
| Start a Media Offload operation on a site | Starts an operation on the site's offloaded media: sync copies files that aren't in storage yet (new uploads are copied within a minute or two by themselves), free removes the server's copies of files storage holds (free up disk only), verify checks every file in storage and repairs what it can, restore brings every file back to the server, and export prepares one download of the whole media library (from the panel's Offload tab). |
| Try setting up Media Offload again | Follow its status until the change is done. |
| Cancel a Media Offload setup that failed | Follow its status until the change is done. |
| Turn off Media Offload for a site | Follow its status until the change is done. |
| Turn on Rabbitflare SMTP for a site | The answer is 202 with status: "setting_up": the site's server is set up, usually within a minute. |
| Turn off Rabbitflare SMTP for a site | Follow its status until the change is done. |
A server's statuses
-
pending_payment - Waiting for its first payment.
-
provisioning - Being set up (see
stage). -
active - Running.
-
off - Powered off.
-
suspended - Switched off for an unpaid bill.
-
failed - Setup failed (see
lastError). -
deleting - Being destroyed.
-
deleted - Destroyed.
Smaller changes to a running server (power, reboot, resize, a snapshot, a restore) keep its status while they run: pendingAction names the
change until it's done, then it's null again.
A site's statuses
-
queued - Waiting for its server.
-
installing - WordPress is being installed (see
stage). -
active - Live.
-
failed - The install failed (see
lastError). -
deleting - Being deleted.
-
deleted - Deleted.
Following the work
Read the resource every 10 seconds until its status is where you want it (or its pendingAction is
null again), and give up after a time limit of your own, like 10 minutes (the quick start has the loop in JavaScript, PHP and Python, and with the SDK's rf.waitFor).
Reading more often doesn't make the work quicker, and counts against your rate limits. When pendingAction is null again, check
lastError: a change that failed says why there (and for a snapshot, check that it's in the server's list of snapshots).
A restore can end without its pendingAction going back to null: one from Rabbitflare's own copies
that stopped partway keeps pendingAction: "restore" until our team has checked the server. Its lastError is
null while a restore runs, so stop following a restore once lastError is set.
Or let webhooks tell you when it's done: server.ready, server.provisioning_failed, site.ready and site.install_failed, among others.
Nothing to read in a loop, and you hear at once.
Failures are statuses
Work that fails after the first answer doesn't turn into an error answer. A server whose setup failed, or a site whose install failed, gets the
status failed, and lastError says why in a sentence (it's null otherwise): the server can be
set up again, and the site installed again. A change that fails, like a resize or a snapshot,
leaves the status as it was: its pendingAction goes back to null (except for a restore that stopped partway, as
above), and lastError says why.
One change at a time
A server or a site makes one change at a time. While one is in progress (its pendingAction isn't null), another change to it
answers 409 busy. Wait until the first one is done, then send yours again.
Still have a question?
Our team answers support tickets about the API, and other developers answer in the community.