Admin Endpoints

Admin-only endpoints for the dashboard, reports, revenue analytics, settings, the setup wizard, migrations, and recommended plugins. All endpoints require the manage_options capability, except POST /install, which requires install_plugins and activate_plugins.


Dashboard

Source: includes/api/class-slswc-dashboard-unified-api.php

GET /dashboard/summary

Get a unified dashboard summary combining overview stats, revenue analytics, chart data, and top-selling products.

Authentication: manage_options

Parameters:

NameTypeRequiredDescription
date_rangestringNoOne of: today, this_week, this_month, last_month, this_year, all_time, last_7_days (default: last_7_days)

Example Request:

curl "https://your-site.com/wp-json/slswc/v1/dashboard/summary?date_range=this_month" \
  -H "X-WP-Nonce: YOUR_NONCE" \
  --cookie "wordpress_logged_in_xxx=..."

Success Response (200):

{
    "date_range": "this_month",
    "start_date": "2025-04-01 00:00:00",
    "end_date": "2025-04-09 23:59:59",
    "overview": {
        "total_licenses": 150,
        "active": 120,
        "inactive": 15,
        "expired": 10,
        "expiring": 5,
        "total_activations": 300
    },
    "revenue": {
        "total_revenue": 4500.00,
        "revenue_this_month": 1200.00,
        "revenue_last_month": 1100.00,
        "month_delta_pct": 9.1,
        "mrr": 3200.00,
        "active_subscriptions": 80,
        "currency": "USD",
        "currency_symbol": "$"
    },
    "chart_data": [
        {
            "date": "2025-04-01",
            "revenue": 150.00,
            "new_licenses": 3
        }
    ],
    "top_products": [
        {
            "product_id": 123,
            "name": "My Plugin Pro",
            "total_revenue": 2500.00,
            "license_count": 50
        }
    ]
}

Reports

Source: includes/api/class-slswc-reports-api.php

GET /reports/summary

Get granular reporting data including ARPU, churn, activation rates, refund rates, VIP customers, and revenue trends.

Authentication: manage_options

Parameters:

NameTypeRequiredDescription
date_rangestringNoSame ranges as dashboard (default: last_7_days)

Example Request:

curl "https://your-site.com/wp-json/slswc/v1/reports/summary?date_range=this_year" \
  -H "X-WP-Nonce: YOUR_NONCE" \
  --cookie "wordpress_logged_in_xxx=..."

Success Response (200):

{
    "date_range": "this_year",
    "start_date": "2025-01-01 00:00:00",
    "end_date": "2025-04-09 23:59:59",
    "stats": {
        "arpu": 85.50,
        "churn_rate": 3.2,
        "activation_rate": 78.5,
        "refund_rate": 1.1,
        "resubscribe_rate": 12.0,
        "revenue_split": {
            "new": 5000.00,
            "renewal": 8000.00,
            "subscription": 12000.00
        },
        "currency_symbol": "$"
    },
    "vip_customers": [
        {
            "customer_id": 5,
            "display_name": "John Doe",
            "total_spent": 1250.00,
            "license_count": 8
        }
    ],
    "revenue_chart": [],
    "activation_chart": [],
    "currency_symbol": "$"
}

Revenue

Source: includes/api/class-slswc-revenue-api.php

GET /revenue

Get monthly revenue trend data and subscription MRR.

Authentication: manage_options

Parameters:

NameTypeRequiredDescription
monthsintNoNumber of months to look back (default: 12, max: 24)

Example Request:

curl "https://your-site.com/wp-json/slswc/v1/revenue?months=6" \
  -H "X-WP-Nonce: YOUR_NONCE" \
  --cookie "wordpress_logged_in_xxx=..."

Success Response (200):

{
    "summary": {
        "total_revenue": 25000.00,
        "revenue_this_month": 4200.00,
        "revenue_last_month": 3800.00,
        "month_delta_pct": 10.5,
        "mrr": 3200.00,
        "active_subscriptions": 80,
        "currency": "USD",
        "currency_symbol": "$"
    },
    "monthly_trend": [
        {
            "month": "2024-11",
            "revenue": 3500.00,
            "new_subscriptions": 8
        },
        {
            "month": "2024-12",
            "revenue": 4100.00,
            "new_subscriptions": 12
        }
    ]
}

Settings

Source: includes/api/class-slswc-settings-api.php

GET /settings

Retrieve the full settings schema with current values for all tabs.

Authentication: manage_options

Example Request:

curl https://your-site.com/wp-json/slswc/v1/settings \
  -H "X-WP-Nonce: YOUR_NONCE" \
  --cookie "wordpress_logged_in_xxx=..."

POST /settings

Save settings values for a given tab.

Authentication: manage_options

Parameters:

NameTypeRequiredDescription
tabstringYesThe settings tab identifier
valuesobjectYesKey/value pairs of option IDs and new values

Example Request:

curl -X POST https://your-site.com/wp-json/slswc/v1/settings \
  -H "X-WP-Nonce: YOUR_NONCE" \
  --cookie "wordpress_logged_in_xxx=..." \
  -H "Content-Type: application/json" \
  -d '{
    "tab": "general",
    "values": {
        "slswc_enable_composer_repository": "yes",
        "slswc_composer_vendor_name": "my-company"
    }
  }'

Success Response (200):

{
    "success": true,
    "values": {
        "slswc_enable_composer_repository": "yes",
        "slswc_composer_vendor_name": "my-company"
    }
}

POST /settings/tools/{tool_id}

Execute a named tool (e.g., clear cache, regenerate licenses).

Authentication: manage_options

Parameters:

NameTypeRequiredDescription
tool_idstringYesThe tool identifier (URL path param)

Example Request:

curl -X POST https://your-site.com/wp-json/slswc/v1/settings/tools/clear_cache \
  -H "X-WP-Nonce: YOUR_NONCE" \
  --cookie "wordpress_logged_in_xxx=..."

Available tools are registered via the slswc_server_tools filter.


GET /settings/renewal-periods

Get all configured renewal periods.

Authentication: manage_options

Example Request:

curl https://your-site.com/wp-json/slswc/v1/settings/renewal-periods \
  -H "X-WP-Nonce: YOUR_NONCE" \
  --cookie "wordpress_logged_in_xxx=..."

POST /settings/renewal-periods

Add or remove a renewal period.

Authentication: manage_options

Parameters:

NameTypeRequiredDescription
actionstringYesadd or remove
keystringYesRenewal period key (e.g., annual)
labelstringConditionalHuman-readable label (required for add)
durationstringConditionalDuration string (required for add)

Example Request (add):

curl -X POST https://your-site.com/wp-json/slswc/v1/settings/renewal-periods \
  -H "X-WP-Nonce: YOUR_NONCE" \
  --cookie "wordpress_logged_in_xxx=..." \
  -H "Content-Type: application/json" \
  -d '{
    "action": "add",
    "key": "semi_annual",
    "label": "Semi-Annual",
    "duration": "+6 months"
  }'

Success Response (200):

{
    "success": true,
    "periods": {
        "monthly": { "label": "Monthly", "duration": "+1 month" },
        "annual": { "label": "Annual", "duration": "+1 year" },
        "semi_annual": { "label": "Semi-Annual", "duration": "+6 months" }
    }
}

POST /settings/license/activate

Activate the SLSWC plugin's own license.

Authentication: manage_options

Parameters:

NameTypeRequiredDescription
license_keystringYesLicense key for SLSWC

POST /settings/license/deactivate

Deactivate the SLSWC plugin's own license.

Authentication: manage_options


Setup Wizard

Source: includes/api/class-slswc-settings-api.php

Used by the Setup Wizard.

POST /wizard/complete

Mark the setup wizard as completed (sets the slswc_wizard_completed option). After this, activating the plugin again no longer redirects to the wizard.

Authentication: manage_options

Parameters: None.

Success Response (200):

{
    "success": true
}

GET /wizard/migrations

List the migration sources that have data on this site. Only sources whose available flag is true are returned. The result is cached for one hour.

Authentication: manage_options

Success Response (200):

{
    "migrations": [
        {
            "id": "woocommerce-software-license",
            "name": "WooCommerce Software License",
            "description": "Migrate from WooCommerce Software License plugin",
            "icon": "...",
            "available": true,
            "settings_fields": [],
            "progress": {}
        }
    ]
}

settings_fields lists the migrator's configurable options and progress holds its last run state.


Migrations

Source: includes/api/class-slswc-migrations-api.php

GET /migrations

List all available migrators with their current status.

Authentication: manage_options

Example Request:

curl https://your-site.com/wp-json/slswc/v1/migrations \
  -H "X-WP-Nonce: YOUR_NONCE" \
  --cookie "wordpress_logged_in_xxx=..."

Success Response (200):

[
    {
        "id": "woocommerce-software-license",
        "name": "WooCommerce Software License",
        "description": "Migrate from WooCommerce Software License plugin",
        "status": "idle",
        "progress": 0,
        "total": 0,
        "settings": {}
    }
]

POST /migrations/{id}/start

Start a migration.

Authentication: manage_options

Example Request:

curl -X POST https://your-site.com/wp-json/slswc/v1/migrations/woocommerce-software-license/start \
  -H "X-WP-Nonce: YOUR_NONCE" \
  --cookie "wordpress_logged_in_xxx=..."

POST /migrations/{id}/cancel

Cancel a running migration.

Authentication: manage_options

GET /migrations/{id}/progress

Poll migration progress.

Authentication: manage_options

Success Response (200):

{
    "id": "woocommerce-software-license",
    "status": "running",
    "progress": 45,
    "total": 100,
    "message": "Migrating license 45 of 100..."
}

POST /migrations/{id}/settings

Save migrator-specific settings.

Authentication: manage_options

Parameters:

NameTypeRequiredDescription
settingsobjectYesMigrator-specific configuration

POST /migrations/{id}/reset

Reset a completed or cancelled migration to allow re-running.

Authentication: manage_options


Source: includes/api/class-slswc-plugins-api.php, includes/class-slswc-plugin-installer.php

POST /install

Install (if needed) and activate a recommended plugin. Used by the Recommended plugins section of the Setup Wizard. The call is idempotent: an already-active plugin returns success straight away, and a plugin that is installed but inactive is just activated.

Authentication: install_plugins and activate_plugins

Parameters:

NameTypeRequiredDescription
slugstringYesWordPress.org slug of the plugin. Must be one of the plugins registered with the slswc_recommended_plugins filter.

Example Request:

curl -X POST https://your-site.com/wp-json/slswc/v1/install \
  -H "X-WP-Nonce: YOUR_NONCE" \
  -H "Content-Type: application/json" \
  --cookie "wordpress_logged_in_xxx=..." \
  -d '{"slug": "licensio-knowledge-base"}'

Success Response (200):

{
    "status": "active"
}

Error Responses:

Errors use the standard WordPress REST error format. data.status is the HTTP status and data.fallbackUrl links to the plugin's page on the Plugins > Add New screen so the user can install it manually. Errors that happen after the plugin was installed (activation errors) also include data.pluginStatus: "inactive".

CodeStatusMeaning
slswc_plugin_not_allowed400The slug is not in the recommended plugins list.
slswc_fs_credentials_required409The site needs FTP or SSH details to install plugins.
slswc_plugin_info_failed502The plugin information could not be fetched from WordPress.org.
slswc_plugin_incompatible409The site's PHP or WordPress version is too old for the plugin.
slswc_plugin_install_failed500The download or install failed.
slswc_plugin_activation_forbidden403The current user may not activate this plugin.
slswc_plugin_activation_failed500The plugin installed but could not be activated.
{
    "code": "slswc_fs_credentials_required",
    "message": "This site needs FTP or SSH details to install plugins. Install it from the Plugins screen instead.",
    "data": {
        "status": 409,
        "fallbackUrl": "https://your-site.com/wp-admin/plugin-install.php?tab=plugin-information&plugin=licensio-knowledge-base"
    }
}

Was this article helpful?