Docs Advanced REST API Reference

REST API Reference

Complete endpoint documentation for the AdminLocks REST API with authentication, request/response examples for every resource.

Advanced reference

Authentication

All AdminLocks REST API endpoints live under the adminlocks/v1 namespace and require authentication. Every endpoint requires the manage_options capability, which means only WordPress administrators can access the API.

Two authentication methods are supported:

Application Password Example

# Using application passwords (recommended for external tools)
curl -X GET "https://yoursite.com/wp-json/adminlocks/v1/audit-log" \
  -u "admin:XXXX XXXX XXXX XXXX XXXX XXXX"

To generate an application password, go to Users > Your Profile in WordPress admin and scroll to the Application Passwords section. Give the password a descriptive name like "AdminLocks API" and click Add New.

Cookie Nonce Example

// JavaScript within the WordPress admin
fetch('/wp-json/adminlocks/v1/audit-log', {
  headers: {
    'X-WP-Nonce': wpApiSettings.nonce
  }
})

Never expose application passwords in client-side code or public repositories. Use environment variables or a secrets manager for production integrations.

Complete Endpoint Table

MethodEndpointPurpose
GET/adminlocks/v1/audit-logList audit log entries with filtering and pagination
DELETE/adminlocks/v1/audit-logPurge all audit log entries
GET/adminlocks/v1/audit-log/exportExport audit log as CSV
GET/adminlocks/v1/policiesList all policies
POST/adminlocks/v1/policiesCreate a new policy
GET/adminlocks/v1/policies/{id}Get a single policy by ID
PUT/adminlocks/v1/policies/{id}Update an existing policy
DELETE/adminlocks/v1/policies/{id}Delete a policy
GET/adminlocks/v1/approvalsList approval requests
POST/adminlocks/v1/approvalsCreate a new approval request
PUT/adminlocks/v1/approvals/{id}Review (approve/deny) a request
GET/adminlocks/v1/snapshotsList snapshots
POST/adminlocks/v1/snapshotsCreate a new snapshot
DELETE/adminlocks/v1/snapshots/{id}Delete a snapshot
GET/adminlocks/v1/portal-requestsList client portal requests
PUT/adminlocks/v1/portal-requests/{id}Update a portal request status
GET/adminlocks/v1/settingsGet plugin settings
PUT/adminlocks/v1/settingsUpdate plugin settings
GET/adminlocks/v1/dashboardGet dashboard summary data
POST/adminlocks/v1/cloud-webhookReceive inbound Cloud webhooks (HMAC auth)

Audit Log

List Entries

GET /adminlocks/v1/audit-log

Returns a paginated list of audit log entries. Supports extensive filtering via query parameters.

ParameterTypeDefaultDescription
per_pageinteger20Number of entries per page (max 100)
pageinteger1Page number for pagination
event_typestringFilter by event type (e.g., login, plugin_activated, option_updated)
severitystringFilter by severity: info, warning, critical
searchstringFull-text search across event descriptions and metadata
date_fromstringISO 8601 date string for start of date range
date_tostringISO 8601 date string for end of date range
orderbystringcreated_atColumn to sort by (created_at, severity, event_type)
orderstringDESCSort direction: ASC or DESC
# Get critical events from the last 7 days
curl -X GET "https://yoursite.com/wp-json/adminlocks/v1/audit-log?\
severity=critical&date_from=2026-02-26T00:00:00Z&per_page=50" \
  -u "admin:XXXX XXXX XXXX XXXX XXXX XXXX"

Response:

{
  "items": [
    {
      "id": 1042,
      "event_type": "plugin_deleted",
      "severity": "critical",
      "description": "Plugin \"hello-dolly\" was deleted",
      "actor_id": 3,
      "actor_name": "clientuser",
      "actor_role": "editor",
      "object_type": "plugin",
      "object_id": "hello-dolly/hello.php",
      "ip_address": "192.168.1.100",
      "metadata": {},
      "created_at": "2026-03-01T14:23:11Z"
    }
  ],
  "total": 1,
  "pages": 1
}

Export CSV

GET /adminlocks/v1/audit-log/export

Returns all audit log entries as a CSV file download. Accepts the same filtering parameters as the list endpoint. The response has Content-Type: text/csv and includes a Content-Disposition header for download.

Purge Log

DELETE /adminlocks/v1/audit-log

Permanently deletes all audit log entries. This action is irreversible and is itself recorded as a new audit event.

Policies

List Policies

GET /adminlocks/v1/policies

curl -X GET "https://yoursite.com/wp-json/adminlocks/v1/policies" \
  -u "admin:XXXX XXXX XXXX XXXX XXXX XXXX"

Response:

[
  {
    "id": 1,
    "name": "Agency Client Lockdown",
    "slug": "agency-client-lockdown",
    "description": "Standard restrictions for editor-role clients",
    "roles": "editor",
    "is_active": true,
    "priority": 10,
    "rules": {
      "deny_menus": ["plugins.php", "themes.php"],
      "deny_capabilities": ["install_plugins", "switch_themes"]
    },
    "created_at": "2026-01-15T09:00:00Z",
    "updated_at": "2026-02-20T11:30:00Z"
  }
]

Create Policy

POST /adminlocks/v1/policies

curl -X POST "https://yoursite.com/wp-json/adminlocks/v1/policies" \
  -H "Content-Type: application/json" \
  -u "admin:XXXX XXXX XXXX XXXX XXXX XXXX" \
  -d '{
    "name": "Content Editor Policy",
    "slug": "content-editor",
    "description": "Restricts editors to content management only",
    "roles": "editor,author",
    "is_active": true,
    "priority": 20,
    "rules": {
      "deny_menus": ["plugins.php", "themes.php", "tools.php"],
      "deny_pages": ["plugin-install.php", "theme-install.php"],
      "deny_capabilities": ["install_plugins", "switch_themes"]
    }
  }'

Update Policy

PUT /adminlocks/v1/policies/{id}

Accepts the same fields as create. Only include the fields you want to update — omitted fields retain their current values.

Delete Policy

DELETE /adminlocks/v1/policies/{id}

Permanently removes the policy. Any restrictions it was enforcing are lifted immediately.

Approvals

List Approvals

GET /adminlocks/v1/approvals

Returns all approval requests. Supports status filter with values: pending, approved, denied, expired.

curl -X GET "https://yoursite.com/wp-json/adminlocks/v1/approvals?status=pending" \
  -u "admin:XXXX XXXX XXXX XXXX XXXX XXXX"

Create Approval Request

POST /adminlocks/v1/approvals

curl -X POST "https://yoursite.com/wp-json/adminlocks/v1/approvals" \
  -H "Content-Type: application/json" \
  -u "admin:XXXX XXXX XXXX XXXX XXXX XXXX" \
  -d '{
    "action_type": "plugin_install",
    "action_label": "Install WooCommerce",
    "description": "Client needs e-commerce functionality",
    "requested_by": 3
  }'

Review Approval

PUT /adminlocks/v1/approvals/{id}

curl -X PUT "https://yoursite.com/wp-json/adminlocks/v1/approvals/5" \
  -H "Content-Type: application/json" \
  -u "admin:XXXX XXXX XXXX XXXX XXXX XXXX" \
  -d '{
    "status": "approved",
    "note": "Approved — WooCommerce is safe to install"
  }'

Snapshots

List Snapshots

GET /adminlocks/v1/snapshots

Returns all site snapshots with metadata including label, file size, and creation date.

Create Snapshot

POST /adminlocks/v1/snapshots

curl -X POST "https://yoursite.com/wp-json/adminlocks/v1/snapshots" \
  -H "Content-Type: application/json" \
  -u "admin:XXXX XXXX XXXX XXXX XXXX XXXX" \
  -d '{
    "label": "Pre-update snapshot March 2026"
  }'

Delete Snapshot

DELETE /adminlocks/v1/snapshots/{id}

Deletes the snapshot record and its associated file from disk.

Portal Requests

GET /adminlocks/v1/portal-requests — list all requests submitted through the client portal.

PUT /adminlocks/v1/portal-requests/{id} — update a request's status (e.g., mark as completed or rejected).

curl -X PUT "https://yoursite.com/wp-json/adminlocks/v1/portal-requests/12" \
  -H "Content-Type: application/json" \
  -u "admin:XXXX XXXX XXXX XXXX XXXX XXXX" \
  -d '{
    "status": "completed",
    "response_note": "Logo has been updated as requested"
  }'

Settings

GET /adminlocks/v1/settings — retrieve current plugin settings.

PUT /adminlocks/v1/settings — update plugin settings.

curl -X PUT "https://yoursite.com/wp-json/adminlocks/v1/settings" \
  -H "Content-Type: application/json" \
  -u "admin:XXXX XXXX XXXX XXXX XXXX XXXX" \
  -d '{
    "audit_enabled": true,
    "audit_retention_days": 14,
    "cloud_api_key": "ak_live_xxxxxxxxxxxx",
    "snapshot_retention_days": 30,
    "portal_enabled": true
  }'

Dashboard

GET /adminlocks/v1/dashboard

Returns aggregated dashboard data including active policy count, recent audit events, pending approvals, and snapshot count. Used internally by the AdminLocks dashboard widget.

{
  "active_policies": 3,
  "total_audit_events": 1247,
  "pending_approvals": 2,
  "snapshots": 5,
  "recent_events": [...]
}

Cloud Webhook

POST /adminlocks/v1/cloud-webhook

This endpoint receives inbound webhooks from AdminLocks Cloud. Unlike other endpoints, it does not use WordPress authentication. Instead, it validates an HMAC-SHA256 signature sent in the X-AdminLocks-Signature header.

The request body is signed using your site's Cloud API key. AdminLocks computes hash_hmac('sha256', $body, $api_key) and compares it to the signature header value.

# Example cloud webhook call (sent by AdminLocks Cloud)
curl -X POST "https://yoursite.com/wp-json/adminlocks/v1/cloud-webhook" \
  -H "Content-Type: application/json" \
  -H "X-AdminLocks-Signature: a1b2c3d4e5f6..." \
  -d '{
    "action": "approval_reviewed",
    "data": {
      "approval_id": 5,
      "status": "approved",
      "note": "Approved from Cloud dashboard"
    }
  }'

For complete webhook documentation including all supported actions and payload formats, see the Webhook Configuration guide.