1. Web Client SDK

Commands client

The SDK provides a Commands client to execute commands that are publicly registered in Sitecore Content Hub.

Note

The client variable in the following code examples refers to the IMClient instance. When using the Web SDK, the variable name can be chosen freely, but it is also called client at instantiation in the documentation.

Executing commands

The following information is needed to execute a command:

  • Command name

  • Command namespace

  • Command arguments (depending on the command)

To execute a command through the SDK:

JToken result = await MClient.Commands.ExecuteCommandAsync(namespace, name, args);

The result contains the output of the command.

Supported commands

Here is a list of available commands by namespace:

external.action

Command name

Arguments

external.action

new JObject(
    new JProperty("entity_id", <long>),
    new JProperty("action_id", <long>),
    new JProperty("properties", <collection>),
    new JProperty("relations", <long>),
    new JProperty("action_execution_source", <string>)),
    new JProperty("extra_data", <collection>))

base

Command name

Arguments

delete.entities

new JObject(
    new JProperty("ids", <collection>),
    new JProperty("identifiers", <collection>))

m.asset

Command name

Arguments

checkin

new JObject(new JProperty("asset_id", <long>))

checkout

new JObject(new JProperty("entity_ids", <collection>))

create.draft

new JObject(new JProperty("entity_id", <long>))

discard

new JObject(new JProperty("asset_id", <long>))

download.onedrive

new JObject(new JArray("entity_ids", <collection>))

import

new JObject(
    new JProperty("entityId", <long>),
    new JProperty("type", <ImportSchemaType>),
    new JProperty("remove_schema", <boolean>),
    new JProperty("url", <string>))

publish.draft

new JObject(new JProperty("entity_id", <long>))

setmaster

new JObject(
    new JProperty("new_master_id", <long>),
    new JProperty("entity_id", <long>),
    new JProperty("master_relation", <string>))

unlock

new JObject(new JProperty("entity_id", <long>))

m.chili

Command name

Arguments

createpublication

new JObject(new JProperty("id", <long>))

deletechilipublication

new JObject(new JProperty("publicationId", <long>))

duplicatepublication

new JObject(new JProperty("id", <long>))

getgenerationconfiguration

new JObject(
    new JProperty("qualities", <collection>),
    new JProperty("endpoint", <string>),
    new JProperty("load_endpoint", <string>),
    new JProperty("editor_token", <string>))

m.collection

Command name

Arguments

enable.collection

new JObject(
    new JProperty("definition_id", <long>),
    new JProperty("enable", <boolean>),
    new JProperty("page_name", <string>))

m.drm

Command name

Arguments

ask.usagerights

new JObject(new JProperty("requestId", <long>))

order

new JObject(
    new JProperty("requestId", <long>),
    new JProperty("order_request", <OrderRequestResource>),
    new JProperty("item_name_resolver_id", <string>),
    new JProperty("culture", <string>),
    new JProperty("order_id", <long>),
    new JProperty("custom_name", <string>),
    new JProperty("setting_category", <string>),
    new JProperty("setting_name", <string>))

order.restricted.authorized

new JObject(
    new JProperty("requestId", <long>),
    new JProperty("order_request", <OrderRequestResource>),
    new JProperty("item_name_resolver_id", <string>),
    new JProperty("culture", <string>),
    new JProperty("authorized", <boolean>),
    new JProperty("custom_name", <string>),
    new JProperty("setting_category", <string>),
    new JProperty("setting_name", <string>),
    new JProperty("order_id", <long>))

order.restricted.nonauthorized

new JObject(
    new JProperty("requestId", <long>),
    new JProperty("order_request", <OrderRequestResource>),
    new JProperty("item_name_resolver_id", <string>),
    new JProperty("culture", <string>),
    new JProperty("authorized", <boolean>),
    new JProperty("custom_name", <string>),
    new JProperty("setting_category", <string>),
    new JProperty("setting_name", <string>))

validate.usagerights

new JObject(
    new JProperty("requestId", <long>),
    new JProperty("restricted", <boolean>),
    new JProperty("authorized", <boolean>),
    new JProperty("explicitApprovalRequired", <boolean>),
    new JProperty("renditions", <JToken>),
    new JProperty("targetId", <long>))

validate.usagerights.request

new JObject(
    new JProperty("targetId", <long>),
    new JProperty("relations", <collection>),
    new JProperty("start_date", <DateTimeOffset>),
    new JProperty("end_date", <DateTimeOffset>))

m.entity

Command name

Arguments

removefromrelation

new JObject(
    new JProperty("entityId", <long>),
    new JProperty("relationName", <string>),
    new JProperty("relationRole", <RelationRole>),
    new JProperty("ids", <collection>))

updaterelation

new JObject(
    new JProperty("entityId", <long>),
    new JProperty("relation", <string>),
    new JProperty("role", <RelationRole>),
    new JProperty("action", <RelationAction>),
    new JProperty("ids", <collection>))

m.file

Command name

Arguments

create.video.alternative

new JObject(
    new JProperty("entityId", <long>),
    new JProperty("seekPosition", <double>))

m.job

Command name

Arguments

canceljob

new JObject(new JProperty("entity_Id", <long>))
Note

The canceljob command stops processes for Import and MassEdit table jobs only. It does not affect Processing jobs.

m.portal.senddummyemail

Command name

Arguments

send.email

new JObject(
    new JProperty("template_Id", <long>),
    new JProperty("user_email", <string>),
    new JProperty("variables", <JToken>),
    new JProperty("templateType", <string>))

m.portal.theme

Command name

Arguments

duplicate.theme

new JObject(new JProperty("themeId", <long>))

generate.theme

new JObject(new JProperty("entity_id", <long>))

enabledisable.theme

new JObject(
    new JProperty("theme_Id", <long>),
    new JProperty("enable", <boolean>))

set.default

new JObject(
    new JProperty("entity_Id", <long>))

m.portal.version

Command name

Arguments

publish.version

new JObject(
    new JProperty("version_Id", <long>))

m.print

Command name

Arguments

copy.publication

new JObject(
    new JProperty("template_id", <long>),
    new JProperty("culture", <CultureInfo>))

create.annotation

new JObject(
    new JProperty("annotation", <JToken>),
    new JProperty("publicationId", <long>))

delete.annotation

new JObject(
    new JProperty("annotationId", <long>))

delete.publication

new JObject(
    new JProperty("publicationId", <long>))

m.security

Command name

Arguments

applyusergrouprole

new JObject(
    new JProperty("usergroup_id", <long>),
    new JProperty("role", <string>),
    new JProperty("target_id", <long>))

applyuserrole

new JObject(
    new JProperty("user_id", <long>),
    new JProperty("role", <string>),
    new JProperty("target_id", <long>))

getpermissions

new JObject(new JProperty("definitions", <collection>))

removeusergrouprole

new JObject(
    new JProperty("usergroup_id", <long>),
    new JProperty("role", <string>),
    new JProperty("target_id", <long>))

removeuserrole

new JObject(
    new JProperty("user_id", <long>),
    new JProperty("role", <string>),
    new JProperty("target_id", <long>))

setroles

new JObject(
    new JProperty("user_roles", <collection>),
    new JProperty("usergroup_roles", <collection>),
    new JProperty("target_id", <long>))

m.taxonomy

Command name

Arguments

move.taxonomy

new JObject(
    new JProperty("relation", <string>),
    new JProperty("id_to_move", <long>),
    new JProperty("parentId", <long>))

update.sortorder

new JObject(new JProperty("sortOrder", <collection>))

portal

Command name

Arguments

change.layout

new JObject(
    new JProperty("pageId", <long>),
    new JProperty("layoutName", <string>))

clone.page

new JObject(
    new JProperty("TemplatePageId", <long>),
    new JProperty("ParentPageId", <long>),
    new JProperty("PageName", <string>),
    new JProperty("CalculatedIdentifier", <boolean>))

create.pagecomponent

new JObject(
    new JProperty("pageId", <long>),
    new JProperty("zoneId", <long>),
    new JProperty("componentType", <string>),
    new JProperty("componentData", <string>),
    new JProperty("componentSettings", <string>),
    new JProperty("componentName", <string>),
    new JProperty("componentTitle", <string>),
    new JProperty("componentIsVisible", <boolean>),
    new JProperty("componentUIVisibility", <string>),
    new JProperty("componentIsNested", <boolean>),
    new JProperty("zoneName", <string>))

delete.page

new JObject(new JProperty("pageId", <long>))

delete.tabspagecomponenttab

new JObject(
    new JProperty("id", <long>),
    new JProperty("tab_name", <string>))

deleteormarkasdeleted.discussion

new JObject(new JProperty("id", <long>))

download.excel

new JObject(
    new JProperty("entityIds", <collection>),
    new JProperty("cultures", <collection>),
    new JProperty("query", <string>),
    new JProperty("type", <string>),
    new JProperty("request_uri", <string>),
    new JProperty("userFriendlyColumnHeaders", <boolean>),
    new JProperty("userFriendlyCellValues", <boolean>),
    new JProperty("filename", <string>),
    new JProperty("selectionComponentId", <long>))

duplicate.pagecomponent

new JObject(
    new JProperty("componentContainerId", <long>),
    new JProperty("originalPageComponentId", <long>),
    new JProperty("componentType", <string>),
    new JProperty("calculatedIdentifier", <boolean>))

log.speedtest

new JObject(
    new JProperty("testStatus", <string>),
    new JProperty("portalPing", <string>),
    new JProperty("portalDownload", <string>),
    new JProperty("portalUpload", <string>),
    new JProperty("deliveryPing", <string>),
    new JProperty("deliveryDownload", <string>),
    new JProperty("deliveryUpload", <string>))

migrate.layout

new JObject(new JProperty("pageId", <long>))

paste.pagecomponent

new JObject(
    new JProperty("action", <string>),
    new JProperty("page_component_identifier", <string>),
    new JProperty("source_identifier", <string>),
    new JProperty("destination_identifier", <string>))

save.translation

new JObject(
    new JProperty("values", <collection>),
    new JProperty("entry_name", <string>),
    new JProperty("context_name", <string>))

setbackground

new JObject(
    new JProperty("pageId", <long>),
    new JProperty("assetId", <long>),
    new JProperty("position", <string>),
    new JProperty("renditionName", <string>))

whatsNewVisualized

new JObject()

project

Command name

Arguments

accept.task

new JObject(new JProperty("taskId", <long>))

add.predecessor

new JObject(
        new JProperty("predecessorid", <long>),
        new JProperty("dependentid", <long>))

block.review

new JObject(
        new JProperty("entityId", <long>),
        new JProperty("pageEntityId", <long>),
        new JProperty("reviewStatusRelation", <string>),
        new JProperty("reviewRelation", <string>),
        new JProperty("status", <string>),
        new JProperty("reason", <string>))

cancel.task

new JObject(new JProperty("taskId", <long>))

complete.task

new JObject(
        new JProperty("taskid", <long>),
        new JProperty("feedback", <string>))

copy.block

new JObject(
        new JProperty("parentId", <long>),
        new JProperty("templateId", <long>),
        new JProperty("overwritePropertyNames", <collection>),
        new JProperty("overwriteRelationNames", <collection>),
        new JProperty("overwritePropertyValues", <JToken>),
        new JProperty("overwriteRelationValues", <collection>),
        new JProperty("overwriteTemplateChildren", <boolean>))

create.asset.localization

new JObject(
        new JProperty("parentassetid", <long>),
        new JProperty("localizationids", <collection>))

decline.task

new JObject(
        new JProperty("taskId", <long>),
        new JProperty("feedback", <string>))

enable.mproject

new JObject(
        new JProperty("definition_id", <long>),
        new JProperty("enable", <boolean>),
        new JProperty("force", <boolean>))

invoke.task

new JObject(new JProperty("id", <long>))

like

new JObject(
        new JProperty("entity_id", <long>),
        new JProperty("value", <string>),
        new JProperty("relation", <string>))

parallel.approve

new JObject(
        new JProperty("entityId", <long>),
        new JProperty("pageEntityId", <long>),
        new JProperty("relation", <string>),
        new JProperty("status", <string>),
        new JProperty("reason", <string>))

remove.predecessor

new JObject(
        new JProperty("predecessorid", <long>),
        new JProperty("dependentid", <long>))

send.to.dam

new JObject(
        new JProperty("entityIds", <collection>),
        new JProperty("statusIdentifier", <string>))

set.block.lifecyclestatus

new JObject(
        new JProperty("id", <long>),
        new JProperty("status", <string>))

set.deliverables.lifecyclestatus

new JObject(
        new JProperty("entityId", <long>),
        new JProperty("status", <string>),
        new JProperty("statusRelation", <string>),
        new JProperty("reason", <string>),
        new JProperty("reasonProperty", <string>))

set.inherits.security

new JObject(
        new JProperty("id", <long>),
        new JProperty("value", <boolean>))

status.deliverable

new JObject(
        new JProperty("id", <long>),
        new JProperty("block_id", <long>),
        new JProperty("content_repository_relation", <string>),
        new JProperty("block_deliverables_relation", <string>),
        new JProperty("block_brief_relation", <string>),
        new JProperty("task_relation", <string>),
        new JProperty("exists_in_dam", <boolean>),
        new JProperty("count_deliverable_blocks", <int>),
        new JProperty("count_brief_blocks", <int>),
        new JProperty("count_tasks", <int>))

take.task

new JObject(new JProperty("taskid", <long>))

task.remind

new JObject(new JProperty("id", <long>))

update.timeline

new JObject(new JProperty("items", <collection>))

derivatives

Command name

Arguments

create.variant

new JObject(
                new JProperty("properties_overrides", new JObject()),
                new JProperty("relations_overrides", new JObject()))

create.draft

new JObject(
                new JProperty("state_flow_id", <long>))

detach.draft

new JObject(
                new JProperty("target_entities", <collection>))

stateflow

Command name

Arguments

assign.stateflow

  • target_id - the ID of the entity to add the state flow to. Required.

  • state_flow_id - the ID of the state flow to assign to the entity. Required.

  • initial_state_id - the ID of the initial state to apply within the state flow. Optional.

Example:

await MClient.Commands.ExecuteCommandAsync("automation","assign.stateflow", new JObject
{
    new JProperty("state_flow_id", 222),
    new JProperty("target_id", 111),
    new JProperty("initial_state_id", 555)
});

apply.state

  • target_id - the ID of the entity to apply the state to. Required.

  • route_id - the ID of the route to apply for state transition. Required.

Example:

await MClient.Commands.ExecuteCommandAsync("automation", "apply.state", new JObject
{
    new JProperty("target_id", 111),
    new JProperty("route_id", 999)
});
If you have suggestions for improving this article, let us know!