WooCommerce Power BI ConnectorWooCommerce Power BI Connector
Buy Now
View Demo
  • Getting Started

    • Introduction
    • Quick Start (5 min)
    • Features
    • Installation
    • Azure AD Setup
    • Power BI Account Setup
    • Setup Wizard
  • Configuration

    • Settings
    • Access Control
  • Reports & Alerts

    • Dashboard
    • Reports & Dashboards
    • Alerts
  • Data & Sync

    • Workspaces, Datasets & Tables
    • Sync & Scheduler
    • Data Load Profiles
    • Query Builder
    • Export Center
  • Advanced

    • Logs & Audit Trail
    • REST API & WP-CLI
    • Troubleshooting
    • FAQ
    • Glossary
Support
Buy Now
View Demo
  • Getting Started

    • Introduction
    • Quick Start (5 min)
    • Features
    • Installation
    • Azure AD Setup
    • Power BI Account Setup
    • Setup Wizard
  • Configuration

    • Settings
    • Access Control
  • Reports & Alerts

    • Dashboard
    • Reports & Dashboards
    • Alerts
  • Data & Sync

    • Workspaces, Datasets & Tables
    • Sync & Scheduler
    • Data Load Profiles
    • Query Builder
    • Export Center
  • Advanced

    • Logs & Audit Trail
    • REST API & WP-CLI
    • Troubleshooting
    • FAQ
    • Glossary
Support
  • Getting Started

    • Introduction
    • Quick Start — 5 Minutes
    • Features
    • Installation — Full Setup Guide
    • Azure AD Setup
    • Power BI Account Setup
    • Setup Wizard
  • Configuration

    • Plugin Settings
    • Access Control
  • Reports & Alerts

    • Dashboard
    • Reports & Dashboards (Embedding)
    • Smart Alerts
  • Data & Sync

    • Workspaces, Datasets & Tables
    • Sync & Scheduler
    • Data Load Profiles
    • Query Builder
    • Export Center
  • Advanced

    • Logs & Audit Trail
    • REST API & WP-CLI
    • Troubleshooting
    • FAQ
    • Glossary

REST API & WP-CLI

The plugin exposes a full REST API (24 endpoints) and WP-CLI command set (7 commands) so you can automate sync, testing, and monitoring from CI/CD pipelines, external services, or the server command line.


REST API

Authentication

All endpoints require:

  • A logged-in WordPress user with the correct capability.
  • A valid WordPress REST nonce:
    X-WP-Nonce: <nonce>
    
  • OR an Application Password (WP 5.6+) via HTTP Basic Auth.

Base URL:

https://your-domain.com/wp-json/wkpbic/v1

Endpoint Summary

ResourceMethodEndpointPurpose
EntitiesGET/entitiesList all registered entities
GET/entities/{slug}/schemaColumn definitions for an entity
GET/entities/{slug}/previewPreview rows (default 25)
GET/entities/{slug}/countTotal row count
SyncPOST/sync/manualTrigger manual sync (requires entity and dataset_id)
GET/sync/statusCurrent sync status and last sync results
GET/sync/logsRecent sync logs (supports page, per_page, entity_type, status params)
POST/sync/scheduleCreate or update sync schedule (enabled, frequency, time)
GET/POST/sync/profilesList or create sync profiles
WorkspacesGET/workspacesList Power BI workspaces
POST/workspacesCreate a new workspace
POST/workspaces/activateSet the active workspace (requires workspace_id)
DatasetsGET/datasetsList datasets in active workspace
POST/datasetsCreate a dataset (requires name, optional entity_types)
POST/datasets/{id}/publishPublish dataset to Power BI
DELETE/datasets/{id}Delete a dataset
TablesGET/tables/{dataset_id}List tables in a dataset
POST/tablesCreate a table (requires dataset_id, table_name, entity_type)
DELETE/tables/{dataset_id}/{table_name}/rowsClear all rows from a table
ReportsGET/reportsList imported reports
GET/reports/{id}/embed-tokenGet embed token for a report
DashboardsGET/dashboardsList imported dashboards
GET/dashboards/{id}/embed-tokenGet embed token for a dashboard
AlertsGET/alertsList all alerts
POST/alertsCreate alert (requires name, metric, notify_email)
PUT/alerts/{id}Update an alert
DELETE/alerts/{id}Delete an alert
POST/alerts/{id}/testTest fire an alert

Example — Trigger sync

Triggers a manual sync for the orders entity to a specific dataset.

curl -X POST "https://your-domain.com/wp-json/wkpbic/v1/sync/manual" \
  -H "X-WP-Nonce: <nonce>" \
  -H "Content-Type: application/json" \
  -b cookies.txt \
  -d '{"entity":"orders","dataset_id":"07a30802-ade3-4349-..."}'

Example — Check sync status

Returns current sync state and the most recent sync results per entity.

curl "https://your-domain.com/wp-json/wkpbic/v1/sync/status" \
  -H "X-WP-Nonce: <nonce>" \
  -b cookies.txt

Response:

{
  "is_syncing": false,
  "last_syncs": [
    {
      "id": "264",
      "entity_type": "orders",
      "status": "completed",
      "rows_pushed": "342",
      "duration_seconds": "5",
      "completed_at": "2026-04-10 13:00:00"
    }
  ]
}

Example — List entities

Returns all registered data types with slug, label, and description.

curl "https://your-domain.com/wp-json/wkpbic/v1/entities" \
  -H "X-WP-Nonce: <nonce>" \
  -b cookies.txt

Response:

[
  {
    "slug": "orders",
    "label": "Orders",
    "description": "WooCommerce orders with all order data.",
    "icon": "dashicons-cart"
  },
  {
    "slug": "customers",
    "label": "Customers",
    "description": "Customer profiles and user data.",
    "icon": "dashicons-groups"
  }
]

WP-CLI Commands

All commands live under the wp wkpbic namespace.

wp wkpbic status

Shows connection status, token expiry, active workspace, last sync timestamp, and counts per entity.

wp wkpbic status

Expected output:

Connection:   Connected
Token expiry: 2026-04-10 14:32 UTC (52 min remaining)
Workspace:    WooCommerce Store (a1b2c3d4-...)
Last sync:    2026-04-10 13:00 UTC — orders — 342 rows — 4.8s
Entities:     orders (12,450) | products (890) | customers (3,210)

wp wkpbic test-connection

Runs a 3-step validation: (1) decrypt credentials, (2) request an OAuth token, (3) call the Power BI API. Output is a clear pass/fail per step with remediation hints.

wp wkpbic test-connection

Expected output:

Step 1 — Decrypt credentials ............ PASS
Step 2 — Request OAuth token ............ PASS
Step 3 — Call Power BI API .............. PASS
All checks passed.

wp wkpbic sync

Trigger a sync from the command line.

# Sync one entity (incremental)
wp wkpbic sync --entity=orders

# Sync everything
wp wkpbic sync --full

# Run a saved profile
wp wkpbic sync --profile="Daily Orders"

# Specify batch size
wp wkpbic sync --entity=products --batch=1000

wp wkpbic list-entities

Lists every registered entity with status and row count.

wp wkpbic list-entities
wp wkpbic list-entities --format=json

wp wkpbic list-datasets

Lists datasets in the active workspace.

wp wkpbic list-datasets

wp wkpbic logs

View recent logs with filters.

wp wkpbic logs --limit=20
wp wkpbic logs --entity=orders --status=failed
wp wkpbic logs --since="2026-04-01"

wp wkpbic flush-cache

Clear all plugin caches and transients.

wp wkpbic flush-cache

Automating Common Tasks

Nightly sync via system cron

Run a full sync at 2 AM every night and log the output. Use system cron (not WP-Cron) for reliability.

0 2 * * * cd /var/www/html && wp wkpbic sync --profile="Nightly Full" >> /var/log/wkpbic.log 2>&1

CI/CD health check

Add this to your deployment pipeline to verify Power BI connectivity after each deploy. Exits with code 1 if any check fails.

#!/bin/bash
set -e
wp wkpbic test-connection || exit 1
wp wkpbic status

Slack notification on failure

Run an hourly sync and post to Slack if it fails. Set $SLACK_WEBHOOK in your environment variables.

wp wkpbic sync --profile="Hourly" || \
  curl -X POST -H 'Content-type: application/json' \
    --data '{"text":"WC Power BI sync failed on prod!"}' \
    "$SLACK_WEBHOOK"

Response Format

All REST endpoints return JSON with a consistent envelope:

{
  "success": true,
  "data": { ... },
  "meta": {
    "request_id": "abc123",
    "timestamp": "2026-04-09T09:15:00Z"
  }
}

Errors use standard WordPress REST error shapes:

{
  "code": "wkpbic_auth_failed",
  "message": "Azure AD token refresh failed",
  "data": { "status": 401 }
}
Prev
Logs & Audit Trail
Next
Troubleshooting