API: site cloning and templates
Copy a website, save and delete site templates and make new websites from them through the token API.
These endpoints do what the Copy a website and Site templates screens do, with the same checks, plan limits and activity log lines.
A=https://api.yourdomain.com:2087/v1
H="Authorization: Bearer hf_xxx"
The paths name the account (/v1/accounts/{username}/…); the rules are those of every
per-account endpoint.
Copy a website
curl -s -H "$H" -X POST $A/accounts/sarahbakes/clone \
-d '{"domain":"yourdomain.com","name":"copy.yourdomain.com"}'
| Field | Meaning |
|---|---|
domain |
the website to copy (required) |
name |
the new address |
to, confirm |
instead of name: an existing website of the account to copy over, with confirm: true |
to_account |
staff tokens only: the username of another account they manage to copy into |
database |
one of the account's databases to copy when the site's config names none |
replace_urls |
replace the address in the database of an app that isn't WordPress |
ssl |
try a free certificate at once (default true) |
The answer (201) has domain, domain_id, kind (wp, env, none), database, config (wp-config.php,
.env, manual or empty) and ssl (issued, later or empty). With config: manual it also has db_user and
db_password to put into the app's settings. It raises site.cloned.
Templates
curl -s -H "$H" $A/accounts/sarahbakes/templates
curl -s -H "$H" -X POST $A/accounts/sarahbakes/templates -d '{"domain":"yourdomain.com","title":"Bakery shop"}'
curl -s -H "$H" -X POST $A/accounts/sarahbakes/templates/4/site \
-d '{"name":"cakes.yourdomain.com","title":"Cakes","admin_email":"me@yourdomain.com"}'
curl -s -H "$H" -X DELETE $A/accounts/sarahbakes/templates/4
GET …/templates lists the account's own templates and the shared ones offered to it: id, title, scope (own,
host), domain, kind, has_db, uploads, size (bytes) and created_at.
POST …/templates saves a website (domain, title, uploads, default true); the package's template size limit
applies. With shared: true a staff token saves it as a shared template instead. It raises template.created.
POST …/templates/{id}/site makes a new website name from the template, with title and admin_email filled into
the placeholders; it answers like the copy above and raises site.from_template.
DELETE …/templates/{id} deletes one of the account's templates, or a shared one the staff token manages.