Site Health

These routes allow you to obtain data about the site's health. Added in WP 5.6.

Possible routes (endpoints are described below):

/wp-site-health/v1/tests/background-updates
/wp-site-health/v1/tests/loopback-requests
/wp-site-health/v1/tests/https-status
/wp-site-health/v1/tests/dotorg-communication
/wp-site-health/v1/tests/authorization-header
/wp-site-health/v1/directory-sizes
/wp-site-health/v1/tests/page-cache

Controller class: WP_REST_Site_Health_Controller{}

Resource schema

The schema shows all fields that exist for the object: the fields of the object that will be returned by the request.

Parameter Context Description
test
string readonly
any The name of the test being run.
label
string readonly
any The label describing the test.
status
string readonly
any The status of the test.
One of: good, recommended, critical
badge
object readonly
any The category of the test.
description
string readonly
any A more detailed description of the test actions and why it matters to the user.
actions
string readonly
any HTML code with action to direct the user where they can resolve the issue.

Route Description

A GET request to the route will return a complete description of the nested routes: endpoints, their parameters, schema.

$ curl -i http://example.com/wp-json/wp-site-health/v1/
GitHub
{
	"namespace": "wp-site-health/v1",
	"routes": {
		"/wp-site-health/v1": {
			"namespace": "wp-site-health/v1",
			"methods": [
				"GET"
			],
			"endpoints": [
				{
					"methods": [
						"GET"
					],
					"args": {
						"namespace": {
							"default": "wp-site-health/v1",
							"required": false
						},
						"context": {
							"default": "view",
							"required": false
						}
					}
				}
			],
			"_links": {
				"self": [
					{
						"href": "https://wptest.loc/wp-json/wp-site-health/v1"
					}
				]
			}
		},
		"/wp-site-health/v1/tests/background-updates": {
			"namespace": "wp-site-health/v1",
			"methods": [
				"GET"
			],
			"endpoints": [
				{
					"methods": [
						"GET"
					],
					"args": []
				}
			],
			"_links": {
				"self": [
					{
						"href": "https://wptest.loc/wp-json/wp-site-health/v1/tests/background-updates"
					}
				]
			}
		},
		"/wp-site-health/v1/tests/loopback-requests": {
			"namespace": "wp-site-health/v1",
			"methods": [
				"GET"
			],
			"endpoints": [
				{
					"methods": [
						"GET"
					],
					"args": []
				}
			],
			"_links": {
				"self": [
					{
						"href": "https://wptest.loc/wp-json/wp-site-health/v1/tests/loopback-requests"
					}
				]
			}
		},
		"/wp-site-health/v1/tests/https-status": {
			"namespace": "wp-site-health/v1",
			"methods": [
				"GET"
			],
			"endpoints": [
				{
					"methods": [
						"GET"
					],
					"args": []
				}
			],
			"_links": {
				"self": [
					{
						"href": "https://wptest.loc/wp-json/wp-site-health/v1/tests/https-status"
					}
				]
			}
		},
		"/wp-site-health/v1/tests/dotorg-communication": {
			"namespace": "wp-site-health/v1",
			"methods": [
				"GET"
			],
			"endpoints": [
				{
					"methods": [
						"GET"
					],
					"args": []
				}
			],
			"_links": {
				"self": [
					{
						"href": "https://wptest.loc/wp-json/wp-site-health/v1/tests/dotorg-communication"
					}
				]
			}
		},
		"/wp-site-health/v1/tests/authorization-header": {
			"namespace": "wp-site-health/v1",
			"methods": [
				"GET"
			],
			"endpoints": [
				{
					"methods": [
						"GET"
					],
					"args": []
				}
			],
			"_links": {
				"self": [
					{
						"href": "https://wptest.loc/wp-json/wp-site-health/v1/tests/authorization-header"
					}
				]
			}
		},
		"/wp-site-health/v1/directory-sizes": {
			"namespace": "wp-site-health/v1",
			"methods": [
				"GET"
			],
			"endpoints": [
				{
					"methods": [
						"GET"
					],
					"args": []
				}
			],
			"_links": {
				"self": [
					{
						"href": "https://wptest.loc/wp-json/wp-site-health/v1/directory-sizes"
					}
				]
			}
		},
		"/wp-site-health/v1/tests/page-cache": {
			"namespace": "wp-site-health/v1",
			"methods": [
				"GET"
			],
			"endpoints": [
				{
					"methods": [
						"GET"
					],
					"args": []
				}
			],
			"_links": {
				"self": [
					{
						"href": "https://wptest.loc/wp-json/wp-site-health/v1/tests/page-cache"
					}
				]
			}
		}
	},
	"_links": {
		"up": [
			{
				"href": "https://wptest.loc/wp-json/"
			}
		]
	}
}

Tests/background-updates

Checks whether background updates are working properly and returns the result of the check.

An OPTIONS request to the route will return a complete description of this route: endpoints, their parameters, schema.

$ curl -X OPTIONS -i https://example.com/wp-site-health/v1/tests/background-updates
GitHub
{
    "namespace": "wp-site-health/v1",
    "methods": [
        "GET"
    ],
    "endpoints": [
        {
            "methods": [
                "GET"
            ],
            "args": []
        }
    ],
    "schema": {
        "$schema": "http://json-schema.org/draft-04/schema#",
        "title": "wp-site-health-test",
        "type": "object",
        "properties": {
            "test": {
                "type": "string",
                "description": "The name of the test being run.",
                "readonly": true
            },
            "label": {
                "type": "string",
                "description": "A label describing the test.",
                "readonly": true
            },
            "status": {
                "type": "string",
                "description": "The status of the test.",
                "enum": [
                    "good",
                    "recommended",
                    "critical"
                ],
                "readonly": true
            },
            "badge": {
                "type": "object",
                "description": "The category this test is grouped in.",
                "properties": {
                    "label": {
                        "type": "string",
                        "readonly": true
                    },
                    "color": {
                        "type": "string",
                        "enum": [
                            "blue",
                            "orange",
                            "red",
                            "green",
                            "purple",
                            "gray"
                        ],
                        "readonly": true
                    }
                },
                "readonly": true
            },
            "description": {
                "type": "string",
                "description": "A more descriptive explanation of what the test looks for, and why it is important for the user.",
                "readonly": true
            },
            "actions": {
                "type": "string",
                "description": "HTML containing an action to direct the user to where they can resolve the issue.",
                "readonly": true
            }
        }
    },
    "_links": {
        "self": [
            {
                "href": "https://wptest.loc/wp-json/wp-site-health/v1/tests/background-updates"
            }
        ]
    }
}

Request Type

Access: private (cap: view_site_health_checks)

GET /wp-site-health/v1/tests/background-updates

Request Parameters

No parameters.

Example Request

$ curl http://example.com/wp-json/wp-site-health/v1/tests/background-updates
{
	"label": "Background updates may not be working properly",
	"status": "recommended",
	"badge": {
		"label": "Security",
		"color": "blue"
	},
	"description": "<p>Background updates ensure that WordPress can auto-update if a security update is released for the version you are currently using.</p><ul><li><span class=\"dashicons warning\"><span class=\"screen-reader-text\">Warning</span></span> The folder <code>/var/app/wptest.loc/www/WordPress/</code> was detected as being under version control (<code>.git</code>).</li><li><span class=\"dashicons pass\"><span class=\"screen-reader-text\">Passed</span></span> Your installation of WordPress does not require FTP credentials to perform updates.</li><li><span class=\"dashicons pass\"><span class=\"screen-reader-text\">Passed</span></span> All of your WordPress files are writable.</li></ul>",
	"actions": "",
	"test": "background_updates"
}

Tests/loopback-requests

Checks whether the site can make requests to itself and returns the result of the check.

Request Type

Access: private (cap: view_site_health_checks)

GET /wp-site-health/v1/tests/loopback-requests

Request Parameters

No parameters.

Example Request

$ curl http://example.com/wp-json/wp-site-health/v1/tests/loopback-requests
{
	"label": "Your site can perform loopback requests",
	"status": "good",
	"badge": {
		"label": "Performance",
		"color": "blue"
	},
	"description": "<p>Loopback requests are used to run scheduled tasks and are also used by the built-in code editor of plugins and themes to check code correctness.</p>",
	"actions": "",
	"test": "loopback_requests"
}

Tests/https-status

Checks whether the SSL (HTTPS) security protocol is being used.

Request Type

Access: private (cap: view_site_health_checks)

GET /wp-site-health/v1/tests/https-status

Request Parameters

No parameters.

Example Request

$ curl http://example.com/wp-json/wp-site-health/v1/tests/https-status
{
	"label": "Your site is not using HTTPS",
	"status": "recommended",
	"badge": {
		"label": "Security",
		"color": "blue"
	},
	"description": "<p>You accessed the site via HTTPS, but <a href=\"https://wptest.loc/WordPress/wp-admin/options-general.php#siteurl\">the WordPress address</a> and <a href=\"https://wptest.loc/WordPress/wp-admin/options-general.php#home\">the site address</a> are not set to use HTTPS by default.</p><p>Contact your hosting support to ensure HTTPS is supported on your site.</p>",
	"actions": "<p><a href=\"https://developer.wordpress.org/advanced-administration/security/https/\" target=\"_blank\" rel=\"noopener\">Learn more about why you should use HTTPS<span class=\"screen-reader-text\"> (opens in a new tab)</span><span aria-hidden=\"true\" class=\"dashicons dashicons-external\"></span></a></p>",
	"test": "https_status"
}

Tests/dotorg-communication

Checks whether your site can make requests to WordPress.org. The connection to WordPress.org servers is used to check for new versions, installation, and updates of WordPress, plugins, and themes.

Request Type

Access: private (cap: view_site_health_checks)

GET /wp-site-health/v1/tests/dotorg-communication

Request Parameters

No parameters.

Example Request

$ curl http://example.com/wp-json/wp-site-health/v1/tests/dotorg-communication
{
	"label": "WordPress.org is accessible",
	"status": "good",
	"badge": {
		"label": "Security",
		"color": "blue"
	},
	"description": "<p>The connection to WordPress.org servers is used to check for new versions, installation, and updates of WordPress, plugins, and themes.</p>",
	"actions": "",
	"test": "dotorg_communication"
}

Tests/authorization-header

Checks the authorization HTTP header for correctness. See WP_Site_Health::get_test_authorization_header(). See https://developer.wordpress.org/rest-api/frequently-asked-questions/#why-is-authentication-not-working

Request Type

Access: private (cap: view_site_health_checks)

GET /wp-site-health/v1/tests/authorization-header

Request Parameters

No parameters.

Example Request

$ curl http://example.com/wp-json/wp-site-health/v1/tests/authorization-header
{
	"label": "Invalid authorization header",
	"status": "recommended",
	"badge": {
		"label": "Security",
		"color": "blue"
	},
	"description": "<p>The authorization header is provided by authorized third-party applications. Without this header, such applications will not be able to connect to your site.</p><p>If you still see this warning after taking the actions described below, you may need to contact hosting support for further assistance.</p>",
	"actions": "<p><a href=\"https://developer.wordpress.org/rest-api/frequently-asked-questions/#why-is-authentication-not-working\" target=\"_blank\" rel=\"noopener\">Learn how to set up the authorization header.<span class=\"screen-reader-text\"> (opens in a new tab)</span><span aria-hidden=\"true\" class=\"dashicons dashicons-external\"></span></a></p>",
	"test": "authorization_header"
}

Directory-sizes

Gets information about the sizes of the site's folders.

Request Type

Access: private (cap: view_site_health_checks)

GET /wp-site-health/v1/directory-sizes

Request Parameters

No parameters.

Example Request

$ curl http://example.com/wp-json/wp-site-health/v1/directory-sizes
{
	"raw": 0,
	"wordpress_size": {
		"size": "54.65 MB",
		"debug": "54.65 MB (57305511 bytes)",
		"raw": 57305511
	},
	"themes_size": {
		"size": "3.30 MB",
		"debug": "3.30 MB (3460331 bytes)",
		"raw": 3460331
	},
	"plugins_size": {
		"size": "158.26 MB",
		"debug": "158.26 MB (165947579 bytes)",
		"raw": 165947579
	},
	"uploads_size": {
		"size": "210.93 MB",
		"debug": "210.93 MB (221175270 bytes)",
		"raw": 221175270
	},
	"database_size": {
		"size": "1.01 GB",
		"debug": "1.01 GB (1088950272 bytes)",
		"raw": 1088950272
	},
	"total_size": {
		"size": "1.43 GB",
		"debug": "1.43 GB (1536838963 bytes)",
		"raw": 1536838963
	}
}

Or:

{
	"code": "not_available",
	"message": "Cannot display folder sizes.",
	"data": {
		"status": 500
	}
}

Tests/page-cache

Checks whether page caching is enabled for the site.

Request Type

Access: private (cap: view_site_health_checks)

GET /wp-site-health/v1/tests/page-cache

Request Parameters

No parameters.

Example Request

$ curl http://example.com/wp-json/wp-site-health/v1/tests/page-cache
{
	"badge": {
		"label": "Performance",
		"color": "blue"
	},
	"description": "<p>Page caching increases the speed and performance of the site by saving and serving static pages instead of creating the page every time it is visited.</p><p>Page caching is detected by searching for an active page cache plugin, as well as performing three requests to the homepage and looking for one or more of the following caching headers for the HTTP client:</p><code>cache-control</code>, <code>expires</code>, <code>age</code>, <code>last-modified</code>, <code>etag</code>, <code>x-cache-enabled</code>, <code>x-cache-disabled</code>, <code>x-srcache-store-status</code>, <code>x-srcache-fetch-status.</code><ul><li><span class=\"dashicons dashicons-yes-alt\"></span> The average server response time was 174 ms. This is less than the recommended threshold of 600 ms.</li><li><span class=\"dashicons dashicons-warning\"></span> No caching headers found in the response headers on the client side.</li><li><span class=\"dashicons dashicons-warning\"></span> No page caching plugin detected.</li></ul>",
	"test": "page_cache",
	"status": "recommended",
	"label": "Page caching not detected, but server response time is good",
	"actions": "<p><a href=\"https://developer.wordpress.org/advanced-administration/performance/optimization/#caching\" target=\"_blank\" rel=\"noopener noreferrer\">Learn more about page caching<span class=\"screen-reader-text\"> (opens in a new tab)</span><span aria-hidden=\"true\" class=\"dashicons dashicons-external\"></span></a></p>"
}