---
title: "Scripts client"
slug: "scripts-client"
abstract: "Overview of the Scripts client used to execute action scripts, with examples."
---
# Scripts client

The SDK provides a `Scripts client` to execute Action scripts.

> [!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.

## Action script example

Assume the following `Action` script is `published` and `enabled`:

```shell
// For simplicity, assume 'name' is always present
var name = Context.Data["name"].ToString();

Context.Result["message"] = $"Hello, {name}!";

```

This script will get the "name" property from the `Data`, and sets a hello message under `message` in the `Result`.

For more information, see [creating scripts](https://doc.sitecore.com/ch/en/developers/cloud-dev/work-with-scripts.html "Work with scripts").

## Executing a script with the SDK

Assume that the script above has identifier `fYaE4Q518ECLRtO2b3W-3Q`. With the SDK, the script can be executed as follows:

```shell
// using Newtonsoft.Json.Linq;
// ...

var arguments = new JObject
{
  { "name", "world" } // Key: "name", value: "world"
};

var scriptIdentifier = "fYaE4Q518ECLRtO2b3W-3Q";
var result = await MClient.Scripts.ExecuteActionScriptAsync(scriptIdentifier, arguments);
MClient.Logger.Info(result["message"].ToString());

```

This will log the message that the script returned, which should be: "Hello, world!".

The `result` returned by the `ExecuteActionScriptAsync` is identical to the `Context.Result` object from the Action script.