The admin screen reads and writes everything through routes under consepo-csp-scanner/v1/admin/. They exist for that screen; they are hidden from the REST index and are not a public API.
Authentication and caching
- Every route requires the
manage_optionscapability. Anyone else getsconsepo_csp_scanner_forbiddenwith status 401 or 403. - Authenticate as a logged-in administrator with the
X-WP-Nonceheader carrying awp_restnonce, as@wordpress/api-fetchdoes. - Responses in this namespace carry
Cache-Control: no-store, no-cache, must-revalidate, max-age=0,Pragma: no-cacheandX-Robots-Tag: noindex, nofollow. - Errors are WordPress REST errors (
code,message,data.status). Errors from Consepo are translated, so Consepo rejecting a token is a 400 here, not a 401 that would read as an expired WordPress session.
Routes
| Method | Route | Does |
|---|---|---|
| GET | /admin/status | Everything the Overview shows: connection, scan, policy and integrity counts |
| GET | /admin/connection | The connection without the token: connected, method, token (set or missing), connectedAt, expiresAt, oauthAvailable, redirectUri |
| POST | /admin/connection | Connect with api_key, after Consepo accepts it |
| DELETE | /admin/connection | Disconnect, revoking OAuth tokens when Consepo offers revocation |
| POST | /admin/connection/oauth | Begin signing in with Consepo; returns authorizeUrl |
| POST | /admin/connection/oauth/callback | Finish signing in with the code and state Consepo returned |
| GET | /admin/scan | The site's scan, its directives and sources, crawl findings, last policy and report address |
| POST | /admin/scan | Start the site's scan, or re-run it in place |
| POST | /admin/scan/refresh | Ask Consepo for the scan's current state |
| GET | /admin/settings | The settings, the header they produce (preview), the last Consepo policy and the report address |
| POST | /admin/settings | Save changed settings; returns the same shape as GET |
| GET | /admin/integrity | The asset inventory, counts by status, and the pinning settings |
| DELETE | /admin/integrity | Forget the inventory; pinning stops until assets are seen again |
| POST | /admin/integrity/discover | Load the home page once and record its assets; returns the inventory plus discovered |
| POST | /admin/integrity/rehash | Hash entries again: local files now, remote ones on the next background run |
| POST | /admin/hashes | Hash content, or the file at url |
Parameters
Reference
9 fields
Request parameters
JSON body fields. Every other route takes none.
-
api_keystring required -
POST /admin/connection. A Consepo token: csp_ followed by 48 lowercase hex characters.
-
codestring required -
POST /admin/connection/oauth/callback. The authorization code Consepo returned.
-
statestring required -
POST /admin/connection/oauth/callback. Must match the attempt this user started in the last ten minutes.
-
limitnumber -
POST /admin/scan. Most pages to crawl, 1 to 100.
-
depthnumber -
POST /admin/scan. Most links to follow, 1 to 10.
-
settingsobject required -
POST /admin/settings. Any subset of the keys in Settings; others are ignored.
-
idsarray -
POST /admin/integrity/rehash. Entry ids from GET /admin/integrity. Empty means every entry.
-
contentstring -
POST /admin/hashes. Up to 2 MB, hashed exactly as sent.
-
urlurl -
POST /admin/hashes. A public http or https URL; takes precedence over content.
No fields match this filter.
Example: hash an inline script
Request
POST
/wp-json/consepo-csp-scanner/v1/admin/hashes
HeadersKey: value
Content-Type application/jsonX-WP-Nonce <wp_rest nonce>Request bodyJSON
{
"content": "alert('Hello, world.');"
}
Response
200 OK
Response headers
Key: value
BodyJSON
{
"source": "content",
"bytes": 23,
"hashes": [
{
"algorithm": "sha256",
"base64": "qznLcsROx4GACP2dm0UCKCzCG+HiZ1guq6ZZDob/Tng=",
"sri": "sha256-qznLcsROx4GACP2dm0UCKCzCG+HiZ1guq6ZZDob/Tng=",
"csp": "'sha256-qznLcsROx4GACP2dm0UCKCzCG+HiZ1guq6ZZDob/Tng='"
},
{
"algorithm": "sha384",
"base64": "H8BRh8j48O9oYatfu5AZzq6A9RINhZO5H16dQZngK7T62em8MUt1FLm52t+eX6xO",
"sri": "sha384-H8BRh8j48O9oYatfu5AZzq6A9RINhZO5H16dQZngK7T62em8MUt1FLm52t+eX6xO",
"csp": "'sha384-H8BRh8j48O9oYatfu5AZzq6A9RINhZO5H16dQZngK7T62em8MUt1FLm52t+eX6xO'"
},
{
"algorithm": "sha512",
"base64": "Q2bFTOhEALkN8hOms2FKTDLy7eugP2zFZ1T8LCvX42Fp3WoNr3bjZSAHeOsHrbV1Fu9/A0EzCinRE7Af1ofPrw==",
"sri": "sha512-Q2bFTOhEALkN8hOms2FKTDLy7eugP2zFZ1T8LCvX42Fp3WoNr3bjZSAHeOsHrbV1Fu9/A0EzCinRE7Af1ofPrw==",
"csp": "'sha512-Q2bFTOhEALkN8hOms2FKTDLy7eugP2zFZ1T8LCvX42Fp3WoNr3bjZSAHeOsHrbV1Fu9/A0EzCinRE7Af1ofPrw=='"
}
]
}Replace <wp_rest nonce> with a nonce from wp_create_nonce( 'wp_rest' ) for a logged-in administrator. The same request with url instead of content also returns url, contentType, cors and volatile.