Action API

Prefix: /api/v1/action Authentication: Required (Bearer token)


POST /api/v1/action/run

Execute an action. Can either execute an existing action by LAUI or create and execute a new action.

Access Control: Inherits from catalog create/access patterns.

Request Body

BaseCreateItemRequest with extra="allow":

FieldTypeRequiredDescription
item_typestringYesMust be "action"
item_lauiObjectIdConditionalLAUI of existing action (if running existing)
namestringConditionalRequired for new actions. Regex: ^[a-zA-Z0-9_\-]+\.action$
parent_lauiObjectIdConditionalRequired for new actions
project_lauiObjectIdConditionalRequired for new actions
account_lauiObjectIdConditionalRequired for new actions
codeblockobjectConditionalRequired for new actions. Python code to execute
bashblockobjectConditionalRequired for new actions. Bash setup code
connection_lauiObjectIdNoConnection to use during execution
action_variablesobjectNoVariables passed to the action

Variation 1: Execute Existing Action

{
  "item_type": "action",
  "item_laui": "507f1f77bcf86cd799439011",
  "connection_laui": "60d5ecb54b24a67d8c8b4567",
  "action_variables": {
    "target_table": "users",
    "batch_size": 1000,
    "dry_run": false
  }
}

Variation 2: Create and Execute New Action

{
  "item_type": "action",
  "name": "cleanup-temp-files.action",
  "parent_laui": "60d5ecb54b24a67d8c8b1234",
  "project_laui": "60d5ecb54b24a67d8c8b5678",
  "account_laui": "60d5ecb54b24a67d8c8b9012",
  "codeblock": {
    "language": "python",
    "content": "import os\n\ndef run(context):\n    target_dir = context.get('action_variables', {}).get('target_dir', '/tmp')\n    count = 0\n    for f in os.listdir(target_dir):\n        if f.endswith('.tmp'):\n            os.remove(os.path.join(target_dir, f))\n            count += 1\n    return {'deleted_files': count}"
  },
  "bashblock": {
    "content": "pip install boto3"
  },
  "connection_laui": "60d5ecb54b24a67d8c8b4567",
  "action_variables": {
    "target_dir": "/tmp/staging"
  }
}

Variation 3: Action Without Connection

{
  "item_type": "action",
  "item_laui": "507f1f77bcf86cd799439011",
  "action_variables": {
    "message": "Hello from action"
  }
}

Variation 4: Action With Empty Variables

{
  "item_type": "action",
  "item_laui": "507f1f77bcf86cd799439011",
  "connection_laui": "60d5ecb54b24a67d8c8b4567"
}

Success Response

Status: 200 OK

{
  "result": {
    "deleted_files": 42,
    "status": "completed"
  }
}

The response shape depends on what the action's run() function returns.

Error Responses

422 Unprocessable Entity — Wrong item type

{"detail": "Only Action can be executed"}

422 Unprocessable Entity — item_type not action

{"detail": "Request item_type must be 'action'"}

422 Unprocessable Entity — Schema validation failure

{
  "detail": {
    "summary": "errors found in action.json",
    "validation_context": {
      "name": "regex pattern ^[a-zA-Z0-9_\\-]+\\.action$ not matched"
    }
  }
}

404 Not Found — Action not found

{"detail": "Item not found"}

500 Internal Server Error — Execution failure

{"detail": "Internal server error: Action execution timed out"}

Action Types in Task Context

Actions can also be attached to tasks and executed at different stages of the task lifecycle. See Task API for details.

Action TypeWhen ExecutedBlocking
create_actionsDuring task creation, before the item is persistedYes — task is not created if action fails
pre_actionsAfter validation, before dispatchYes — task is not dispatched if action fails
running_actionsDuring execution, triggered by SLANo — runs alongside the main task
post_actionsAfter task completes (success or failure)No — runs asynchronously

Action Item Schema (in task context)

{
  "laui": "507f1f77bcf86cd799439011",
  "name": "notify-slack.action",
  "session_id": "sess_abc123",
  "connection_laui": "60d5ecb54b24a67d8c8b4567",
  "connection": {},
  "action_variables": {"channel": "#alerts"},
  "user_laui": "60d5ecb54b24a67d8c8b9012",
  "sla": 5,
  "timeout": 300,
  "action_type": "pre_actions"
}
FieldTypeDescription
lauiObjectIdAction item LAUI
namestringAction name
session_idstringSession identifier
connection_lauiObjectIdConnection to use
connectionobjectConnection content (fetched at runtime)
action_variablesobjectVariables passed to the action
user_lauiObjectIdUser who triggered the action
slaintSLA threshold in minutes (for running_actions)
timeoutintMaximum execution time in seconds
action_typestringOne of: create_actions, pre_actions, running_actions, post_actions