Skip to navigation

Scripts

View as Markdown

platform.extensions.scripts

A script action runs Python code. Use it when a Data Mapper expression can’t do the transformation.

To learn what scripts do, see Scripts in the Tool Studio docs.

  • Endpoint: /platform/extensions/scripts | Methods: GET, PATCH, POST
  • Request shape: fields go at the top level of the JSON body, with no resource wrapper. The item’s id goes in the URL for reads and updates, not in the body.
  • Updates: a JSON merge-patch with version: {num, change_description} from your last read. Lists of objects merge row by row, so read first and send the whole list when you remove or reorder rows. See Tool Studio.
  • References: Conversational processes, data types and plugins call the script by its id; compound actions call it by signature.name.

Endpoints

All paths are relative to https://api.moveworks.ai/configurations/v1alpha1. Each endpoint page lists the request and response schema, an example, and the errors it can return.

MethodPathEndpoint reference
GET/platform/extensions/scriptsList scripts
POST/platform/extensions/scriptsCreate script
GET/platform/extensions/scripts/{id}Get script
PATCH/platform/extensions/scripts/{id}Update script

Rules the API checks

  • code is required. The script’s inputs are available as plain variable names.
  • The last line must be an expression, which becomes the result. Assign inside if, for or try blocks, then put the variable alone on the last line.
  • Read a secret with _SECRETS['name']. Secrets come back redacted.
  • language is always Python and can’t be changed.

Fields

FieldTypeRequiredNotes
idstringread-onlyUnique identifier of the script, assigned by the server.
signatureFunctionSignatureSettings✅The script’s name, description, input arguments and result schema. The name is the key the script is referenced by.
languagestringread-onlyProgramming language of the script. Set to PYTHON for scripts created through this API.
codestring✅Script code. Inputs are available by their argument names, and the last line must be an expression whose value is returned.
secretsarray<ScriptSecretSettings>Secrets the script can read by name.
updated_timestringread-onlyWhen the configuration was last updated.
updated_bystringread-onlyWho last updated the configuration.
versionVersion✅Document version. On update, send back the num from your last read.

Example create body

{
"signature": {
"name": "format_user_data",
"display_name": "Format User Data",
"description": "Formats a user's name and lowercases the email.",
"arguments": [
{
"name": "first_name",
"description": "First name",
"type": {
"primitive": "string"
},
"required": true,
"example_value": "John"
},
{
"name": "last_name",
"description": "Last name",
"type": {
"primitive": "string"
},
"required": true,
"example_value": "Doe"
},
{
"name": "email",
"description": "Email",
"type": {
"primitive": "string"
},
"required": true,
"example_value": "john.doe@example.com"
}
]
},
"code": "name = first_name + ' ' + last_name\n{'full_name': name, 'email': email.lower()}",
"version": {
"change_description": "Initial version."
}
}