Link Two Sites Programmatically
InstaWP enables easy setup and linking of your production and staging sites via API, providing hosting companies the two-way sync capability to push changes from staging to live, and vice versa.
Let’s get started 🚀
To obtain an API key for your sites, make a POST request to InstaWP's API:
Repeat this process for each site (production and staging). Store the API keys for each site as they will be needed later.
Install and configure the InstaWP plugin on your production site:
Replace <prod_api_key> with the API key obtained for the production site.
Install and configure the InstaWP plugin on your staging site:
Replace <staging_api_key> with the API key obtained for the staging site.
To link the staging site to the production site, make a POST request to the InstaWP API:
Success Response
You can use the sample PHP program provided by InstaWP to automate this process. Download the sample program from the following link:
https://instawp.com/wp-content/uploads/2024/07/sync-link.php_.zip
Let’s get started 🚀
Step 1: Obtain API Keys from InstaWP
To obtain an API key for your sites, make a POST request to InstaWP's API:
POST https://app.instawp.io/api/v2/connects/create-token
API-Key: Account API Key
{
"url": "https://prodsite.com"
}
Repeat this process for each site (production and staging). Store the API keys for each site as they will be needed later.
Step 2: Add InstaWP Plugin to the Production Site
Install and configure the InstaWP plugin on your production site:
wp plugin install instawp-connect --activate
wp instawp config-set api-key '<prod_api_key>'
Replace <prod_api_key> with the API key obtained for the production site.
Step 3: Add InstaWP Plugin to the Staging Site
Install and configure the InstaWP plugin on your staging site:
wp plugin install instawp-connect --activate
wp instawp config-set api-key '<staging_api_key>'
Replace <staging_api_key> with the API key obtained for the staging site.
Step 4: Link Staging Site to the Parent (Production) Site
To link the staging site to the production site, make a POST request to the InstaWP API:
POST https://app.instawp.io/api/v2/connects/link
API-Key: Account API Key
{
"parent_url": "https://parent.com",
"child_url": "https://stage.com"
}
Success Response
{
"message": "Parent Child Url successfully connected",
"status": true,
"data": []
}
Sample PHP Program
You can use the sample PHP program provided by InstaWP to automate this process. Download the sample program from the following link:
https://instawp.com/wp-content/uploads/2024/07/sync-link.php_.zip
Updated on: 26/07/2024
Thank you!