Copy an install
package main
import ( "fmt" "strings" "net/http" "io")
func main() {
url := "https://api.wpengineapi.com/v1/install_copy"
payload := strings.NewReader("{ \"source_environment_id\": \"8f14e45f-ceea-4b5b-9f6d-8f14e45fceea\", \"destination_environment_id\": \"c9f0f895-fb98-4f3c-9f0f-c9f0f895fb98\", \"notification_emails\": [ \"example\" ], \"custom_options\": { \"include_files\": true, \"include_db\": true, \"db_tables\": [ \"wp_posts\", \"wp_comments\" ] } }")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <credentials>") req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close() body, _ := io.ReadAll(res.Body)
fmt.Println(res) fmt.Println(string(body))
}const url = 'https://api.wpengineapi.com/v1/install_copy';const options = { method: 'POST', headers: {Authorization: 'Basic <credentials>', 'Content-Type': 'application/json'}, body: '{"source_environment_id":"8f14e45f-ceea-4b5b-9f6d-8f14e45fceea","destination_environment_id":"c9f0f895-fb98-4f3c-9f0f-c9f0f895fb98","notification_emails":["example"],"custom_options":{"include_files":true,"include_db":true,"db_tables":["wp_posts","wp_comments"]}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.wpengineapi.com/v1/install_copy \ --header 'Authorization: Basic <credentials>' \ --header 'Content-Type: application/json' \ --data '{ "source_environment_id": "8f14e45f-ceea-4b5b-9f6d-8f14e45fceea", "destination_environment_id": "c9f0f895-fb98-4f3c-9f0f-c9f0f895fb98", "notification_emails": [ "example" ], "custom_options": { "include_files": true, "include_db": true, "db_tables": [ "wp_posts", "wp_comments" ] } }'Copies the file system and database from one environment to another. Use
custom_options to limit what is copied.
Limitations & Warnings
- The contents of the destination environment are overwritten.
- The source and destination environments must be on the same account.
- Asynchronous: the addresses in
notification_emailsare notified when the copy is complete. db_tablescannot be specified ifinclude_dbisfalse.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”Properties
- source_environment_id - required - The ID of the environment to copy from. Must be on the same account as destination_environment_id
- destination_environment_id - required - The ID of the environment to copy to. The contents of this environment will be overwritten. Must be on the same account as source_environment_id
- notification_emails - optional - An array of email addresses to notify when the copy is complete
- custom_options - optional - Optional fields to customize how the install should be copied
- include_files - optional - Should files be copied? Boolean where true means include files in the copy. Default is true.
- include_db - optional - Should the database be copied? Boolean where true means include the database in the copy. Default is true.
- db_tables - optional - A list of tables to include in the copy. If unspecified, the full database will be copied. Cannot specifiy tables if
include_dbisfalse.
object
The ID of the environment to copy from
Example
8f14e45f-ceea-4b5b-9f6d-8f14e45fceeaThe ID of the environment to copy to
Example
c9f0f895-fb98-4f3c-9f0f-c9f0f895fb98An array of email addresses to notify when the copy is complete
Optional fields to customize how the install should be copied
object
Should files be included in the copy. True means include files. Default is true.
Should the database be included in the copy. True means include the database. Default is true.
A list of tables to include in the copy. If unspecified, the full database will be copied. Cannot specifiy tables if include_db is false.
Example
[ "wp_posts", "wp_comments"]Responses
Section titled “Responses”Accepted. The copy has been accepted; the addresses in notification_emails are notified when it is complete.
Bad Request
object
A message regarding the error that occurred on the server
(Optional) A URL where documentation regarding this specific error can be found
An array of error objects describing specific errors that arose when servicing the request
object
The name of the resource that was being processed when the error occurred
(Optional) The specific field associated with the error
(Optional) A type associated with the error. invalid_value, access_error, value_unavailable
(Optional) A machine code relating to the error that occurred with the field and resource
(Optional) A human-readable message relating to the error that occurred with the field and resource
Example
{ "message": "Invalid request.", "errors": [ { "resource": "Resource", "field": "field_name", "type": "invalid_value", "code": "invalid", "message": "The value is invalid." } ]}Authentication Error
object
A message regarding the error that occurred on the server
(Optional) A URL where documentation regarding this specific error can be found
Example
{ "message": "Bad Credentials"}Not authorized
object
A message regarding the error that occurred on the server
(Optional) A URL where documentation regarding this specific error can be found
Example
{ "message": "You don't have permission to perform that action"}Not found
object
A message regarding the error that occurred on the server
(Optional) A URL where documentation regarding this specific error can be found
Example
{ "message": "Not Found"}Too many requests
Internal Server Error
object
A message regarding the error that occurred on the server
Example
{ "message": "An unexpected error occurred, please try again in a few minutes"}An invalid response was received from an upstream server
Service unavailable