Quick Start Guide
This guide will help you make your first API request to the WP Engine Customer API. We’ll walk through the process of authenticating and retrieving a list of your sites.
Prerequisites
Before you begin, make sure you have:
- A WP Engine account
- API credentials (see the Authentication guide)
- Basic knowledge of making HTTP requests (using cURL, Postman, or your preferred programming language)
Step 1: Authenticate
For this quick start, we’ll use basic authentication with your API credentials. If you’re building a user-facing application, you should use OAuth 2.0 instead.
First, generate API credentials if you don’t already have them. You’ll need both an API user ID and password.
Step 2: Make Your First API Request
Let’s retrieve a list of your WP Engine sites. This is a simple GET request to the /sites endpoint:
curl -X GET https://api.wpengineapi.com/v1/sites \ -u "API_USER_ID:API_USER_PASSWORD"Replace API_USER_ID and API_USER_PASSWORD with your actual API credentials.
Example Response
{ "previous": "https://api.wpengineapi.com/v1/sites?limit=100&offset=0", "next": "https://api.wpengineapi.com/v1/sites?limit=100&offset=200", "count": 225, "results": [ { "id": "28c78b6d-c2da-4f09-85f5-1ad588089b2d", "name": "Torque Magazine", "account": { "id": "eeda3227-9a39-46ae-9e14-20958bb4e6c9" }, "tags": [ "production" ], "installs": [] } ]}Step 3: Get Site Details
Now, let’s get more details about a specific site. Use the site ID from the previous response:
curl -X GET https://api.wpengineapi.com/v1/sites/28c78b6d-c2da-4f09-85f5-1ad588089b2d \ -u "API_USER_ID:API_USER_PASSWORD"Example Response
{ "id": "28c78b6d-c2da-4f09-85f5-1ad588089b2d", "name": "Torque Magazine", "account": { "id": "eeda3227-9a39-46ae-9e14-20958bb4e6c9" }, "tags": [ "production" ], "installs": []}Step 4: List Your WordPress Installations
To work with backups and other install-specific operations, you’ll need to get your WordPress installations:
curl -X GET https://api.wpengineapi.com/v1/installs \ -u "API_USER_ID:API_USER_PASSWORD"Example Response
{ "previous": "https://api.wpengineapi.com/v1/installs?limit=100&offset=0", "next": "https://api.wpengineapi.com/v1/installs?limit=100&offset=200", "count": 225, "results": [ { "id": "294deacc-d8b8-4005-82c4-0727ba8ddde0", "name": "torquemag", "account": { "id": "eeda3227-9a39-46ae-9e14-20958bb4e6c9" }, "php_version": "7.0", "status": "active", "cname": "mywebsite.wpengine.com" } ]}Step 5: Create a Backup
Let’s create a backup of your WordPress installation:
curl -X POST https://api.wpengineapi.com/v1/installs/294deacc-d8b8-4005-82c4-0727ba8ddde0/backups \ -u "API_USER_ID:API_USER_PASSWORD" \ -H "Content-Type: application/json" \ -d '{ "description": "Quick start backup example", "notification_emails": ["your-email@example.com"] }'Example Response
{ "id": "28c78b6d-c2da-4f09-85f5-1ad588089b2d", "status": "requested"}Step 6: Create an Account User
Let’s create a new user for your account. You’ll need your account ID from the previous responses:
curl -X POST https://api.wpengineapi.com/v1/accounts/eeda3227-9a39-46ae-9e14-20958bb4e6c9/account_users \ -u "API_USER_ID:API_USER_PASSWORD" \ -H "Content-Type: application/json" \ -d '{ "user": { "account_id": "eeda3227-9a39-46ae-9e14-20958bb4e6c9", "first_name": "John", "last_name": "Doe", "email": "john.doe@example.com", "roles": "partial" } }'Example Response
{ "message": "Your change was successful.", "account_user": { "user_id": "28c78b6d-c2da-4f09-85f5-1ad588089b2d", "account_id": "eeda3227-9a39-46ae-9e14-20958bb4e6c9", "first_name": "John", "last_name": "Doe", "email": "john.doe@example.com", "phone": null, "invite_accepted": false, "mfa_enabled": false, "roles": "partial" }}Step 7: Check Backup Status
You can check the status of your backup:
curl -X GET https://api.wpengineapi.com/v1/installs/294deacc-d8b8-4005-82c4-0727ba8ddde0/backups/28c78b6d-c2da-4f09-85f5-1ad588089b2d \ -u "API_USER_ID:API_USER_PASSWORD"Example Response
{ "id": "28c78b6d-c2da-4f09-85f5-1ad588089b2d", "status": "requested"}Next Steps
Congratulations! You’ve made your first API requests to the WP Engine Customer API. Here are some next steps:
- Explore the API Reference to learn about all available endpoints
- Check out the Examples for more complex use cases
- Learn about Pagination for handling large result sets
- Implement proper Error Handling in your application
Code Examples
Python
import requestsimport base64
API_USER_ID = "YOUR_API_USER_ID"API_PASSWORD = "YOUR_API_PASSWORD"BASE_URL = "https://api.wpengineapi.com/v1"
# Create basic auth headerauth_string = base64.b64encode(f'{API_USER_ID}:{API_PASSWORD}'.encode()).decode()headers = { "Authorization": f"Basic {auth_string}"}
# Get all sitesresponse = requests.get(f"{BASE_URL}/sites", headers=headers)response.raise_for_status()sites = response.json()print(sites)
# Get specific siteif sites["results"]: site_id = sites["results"][0]["id"] response = requests.get(f"{BASE_URL}/sites/{site_id}", headers=headers) response.raise_for_status() site_details = response.json() print(site_details)JavaScript (Node.js)
const axios = require('axios');
const API_USER_ID = 'YOUR_API_USER_ID';const API_PASSWORD = 'YOUR_API_PASSWORD';const BASE_URL = 'https://api.wpengineapi.com/v1';
const headers = { 'Authorization': 'Basic ' + Buffer.from(`${API_USER_ID}:${API_PASSWORD}`).toString('base64')};
async function makeRequests() { try { // Get all sites const sitesResponse = await axios.get(`${BASE_URL}/sites`, { headers }); console.log(sitesResponse.data);
// Get specific site if (sitesResponse.data.results.length > 0) { const siteId = sitesResponse.data.results[0].id; const siteResponse = await axios.get(`${BASE_URL}/sites/${siteId}`, { headers }); console.log(siteResponse.data); } } catch (error) { console.error('Error:', error.response ? error.response.data : error.message); }}
makeRequests();PHP
<?php$apiUserId = 'YOUR_API_USER_ID';$apiPassword = 'YOUR_API_PASSWORD';$baseUrl = 'https://api.wpengineapi.com/v1';
$auth = base64_encode($apiUserId . ':' . $apiPassword);$headers = [ 'Authorization: Basic ' . $auth];
// Get all sites$ch = curl_init($baseUrl . '/sites');curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);$sites = json_decode($response, true);print_r($sites);
// Get specific siteif (!empty($sites['results'])) { $siteId = $sites['results'][0]['id']; $ch = curl_init($baseUrl . '/sites/' . $siteId); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch); $siteDetails = json_decode($response, true); print_r($siteDetails);}
curl_close($ch);?>Common Error Responses
When working with the API, you may encounter these common error responses:
401 Authentication Required
{ "message": "Authentication required"}This means your API credentials are missing or invalid. Double-check your API_USER_ID and API_PASSWORD.
403 Insufficient Permissions
{ "message": "Insufficient permissions to access this resource"}Your API credentials don’t have permission to access the requested resource.
404 Resource Not Found
{ "message": "Resource not found"}The requested resource (site, install, backup, etc.) doesn’t exist or you don’t have access to it.
429 Rate Limit Exceeded
{ "message": "Rate limit exceeded - too many requests"}You’ve made too many requests in a short period. Wait a moment before making additional requests.
Tips for Success
- Use UUIDs: All resource IDs in the WP Engine API are UUIDs (like
28c78b6d-c2da-4f09-85f5-1ad588089b2d) - Handle Pagination: Most list endpoints return paginated results with
previous,next, andcountfields - Check Status Codes: Always check HTTP status codes and handle errors appropriately
- Store Credentials Securely: Never hardcode API credentials in your source code
- Use HTTPS: All API requests must use HTTPS
Ready to dive deeper? Check out the complete API reference for detailed documentation on all available endpoints.