Skip to main content

Server-Side Commands

Every entity type in Nexudus can have server-side commands — special operations that go beyond standard CRUD. The SDK lets you discover available commands and execute them with or without parameters.

Discover available commands

Use GetCommandsAsync to list all commands available for an entity type:
var endpoint = new CoworkerEndpoint(client);
List<CommandInfo> commands = await endpoint.GetCommandsAsync();

foreach (var cmd in commands)
{
    Console.WriteLine($"{cmd.Key}: {cmd.Name}");
    Console.WriteLine($"  Needs entities: {cmd.NeedsEntitiesToRun}");
    Console.WriteLine($"  Single only:    {cmd.AppliesOnlyToOneEntity}");
    Console.WriteLine($"  Parameters:     {cmd.RequiresParameters.Count}");
}

CommandInfo properties

PropertyTypeDescription
KeystringThe unique identifier used when running the command.
NamestringHuman-readable command name.
NeedsEntitiesToRunboolWhether the command requires entity IDs.
AppliesOnlyToOneEntityboolWhether the command can only target a single entity.
RequiresParametersList<CommandParameter>Parameters the command accepts.

Run a command on one entity

await endpoint.RunCommandAsync("commandKey", ids: coworkerId);

Run a command on multiple entities

await endpoint.RunCommandAsync("commandKey", ids: new long[] { 100, 200, 300 });

Run a command with parameters

Some commands require additional parameters. Build a list of CommandParameter objects:
var parameters = new List<CommandParameter>
{
    new() { Name = "Date", Type = "datetime", Value = "2026-04-03T00:00:00Z" },
    new() { Name = "Amount", Type = "int", Value = "100" }
};

await endpoint.RunCommandAsync("commandKey", parameters, entityId);

CommandParameter properties

PropertyTypeDescription
NamestringThe parameter name as defined by the command.
TypestringThe parameter type (string, int, datetime, etc).
ValuestringThe parameter value, serialised as a string.
Use GetCommandsAsync first to inspect the RequiresParameters list for each command. This tells you exactly which parameters are needed and their expected types.