Instant downloads • Annual updates
DocsDeveloper APICommand System API Reference

Command System API Reference

2026-03-018 min read

Command System API Reference

The Sera Command System allows spoke plugins to register, execute, and schedule commands through the hub.

Registering Commands

php
add_filter('sera_commands', function($commands) {
    $commands['my_command'] = [
        'name'        => 'My Command',
        'description' => 'Does something useful',
        'callback'    => 'my_command_handler',
        'spoke'       => 'my-plugin-slug',
        'args'        => [
            'target' => [
                'type'        => 'string',
                'description' => 'The target to process',
                'required'    => true,
            ],
            'force' => [
                'type'        => 'boolean',
                'description' => 'Force execution',
                'default'     => false,
            ],
        ],
    ];
    return $commands;
});

function my_command_handler($args) {
    $target = $args['target'];
    $force = $args['force'] ?? false;
    
    // Do work...
    
    return [
        'status'  => 'success',
        'message' => "Processed {$target}",
        'data'    => $results,
    ];
}

Executing Commands

From PHP

php
if (function_exists('sera_execute_command')) {
    $result = sera_execute_command('my_command', [
        'target' => 'homepage',
        'force'  => true,
    ]);
}

From REST API

POST /wp-json/sera/v1/commands/execute
Content-Type: application/json

{
    "command": "my_command",
    "args": {
        "target": "homepage",
        "force": true
    }
}

Scheduling Commands

One-Time Schedule

php
sera_schedule_command('my_command', [
    'target' => 'all-pages',
], strtotime('+1 hour'));

Recurring Schedule

php
sera_schedule_recurring_command('my_command', [
    'target' => 'all-pages',
], 'daily', '02:00');

Chained Commands

Execute multiple commands in sequence:

php
sera_chain_commands([
    ['command' => 'sentinel_scan', 'args' => ['scope' => 'full']],
    ['command' => 'pulse_health_check', 'args' => []],
    ['command' => 'sitemap_rebuild', 'args' => ['force' => true]],
]);

Each command in the chain receives the previous command's result as an additional previous_result argument.

Built-In Commands

CommandSpokeDescription
sentinel_scanSentinelRun malware scan
sentinel_firewall_refreshSentinelReload firewall rules
pulse_health_checkPulseRun health check
pulse_db_optimizePulseOptimize database
pulse_cron_cleanupPulseClean stuck cron jobs
writer_ai_generateAI WriterGenerate content
sitemap_rebuildAI SitemapRebuild sitemap
sitemap_indexnow_submitAI SitemapSubmit URLs via IndexNow
cls_pro_scanCLS Guard ProRun CLS scan
cls_pro_apply_fixesCLS Guard ProApply auto-generated fixes