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:

RequestResponse
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

RequestResponse
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

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

m.asset

Command name

Arguments

checkin

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

checkout

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

create.draft

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

discard

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

download.onedrive

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

import

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

publish.draft

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

setmaster

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

unlock

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

m.chili

Command name

Arguments

createpublication

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

deletechilipublication

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

duplicatepublication

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

getgenerationconfiguration

RequestResponse
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

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

m.drm

Command name

Arguments

ask.usagerights

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

order

RequestResponse
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

RequestResponse
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

RequestResponse
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

RequestResponse
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

RequestResponse
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

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

updaterelation

RequestResponse
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

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

m.job

Command name

Arguments

canceljob

RequestResponse
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

RequestResponse
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

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

generate.theme

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

enabledisable.theme

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

set.default

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

m.portal.version

Command name

Arguments

publish.version

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

m.print

Command name

Arguments

copy.publication

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

create.annotation

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

delete.annotation

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

delete.publication

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

m.security

Command name

Arguments

applyusergrouprole

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

applyuserrole

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

getpermissions

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

removeusergrouprole

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

removeuserrole

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

setroles

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

m.taxonomy

Command name

Arguments

move.taxonomy

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

update.sortorder

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

portal

Command name

Arguments

change.layout

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

clone.page

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

create.pagecomponent

RequestResponse
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

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

delete.tabspagecomponenttab

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

deleteormarkasdeleted.discussion

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

download.excel

RequestResponse
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

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

log.speedtest

RequestResponse
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

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

paste.pagecomponent

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

save.translation

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

setbackground

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

whatsNewVisualized

RequestResponse
new JObject()

project

Command name

Arguments

accept.task

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

add.predecessor

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

block.review

RequestResponse
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

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

complete.task

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

copy.block

RequestResponse
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

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

decline.task

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

enable.mproject

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

invoke.task

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

like

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

parallel.approve

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

remove.predecessor

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

send.to.dam

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

set.block.lifecyclestatus

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

set.deliverables.lifecyclestatus

RequestResponse
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

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

status.deliverable

RequestResponse
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

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

task.remind

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

update.timeline

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

derivatives

Command name

Arguments

create.variant

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

create.draft

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

detach.draft

RequestResponse
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:

RequestResponse
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:

RequestResponse
await MClient.Commands.ExecuteCommandAsync("automation", "apply.state", new JObject
{
    new JProperty("target_id", 111),
    new JProperty("route_id", 999)
});

Do you have some feedback for us?

If you have suggestions for improving this article,