---
title: "Execute code on a Gateway"
method: POST
path: "/gateway_manager/v1/code/run"
tags: ["Gateway Manager"]
---

# Execute code on a Gateway

`POST /gateway_manager/v1/code/run`

## Request

- Base URL: `https://example.itential.io`
- URL: `https://example.itential.io/gateway_manager/v1/code/run`
- Auth: none declared

Executes code (e.g. Python) on a Gateway5 cluster without requiring a pre-configured service. The code is sent directly to the gateway for execution.

## Request body

- object
  - `clusterId` string
  - `language` 'python'
  - `code` string
  - `data` GatewayManagerV1CodeRunPostRequestBodyContentApplicationJsonSchemaData
  - `safety` GatewayManagerV1CodeRunPostRequestBodyContentApplicationJsonSchemaSafety
    - `timeout` number, double, required: Execution timeout in seconds (1-1000)
  - `packages` string[]

## Response `200`

The execution result from the gateway including stdout, stderr, return code, and timing

- GatewayManagerRunCodeResponse200
  - `id` string
  - `jsonrpc` string
  - `status` 'completed' | 'error'
  - `receiveTime` integer
  - `return_code` integer: Process exit code (0 = success, >=1 = error)
  - `stdout` string: Raw standard output from the script execution
  - `stderr` string: Standard error from the script execution
  - `stdout_json` union: Parsed JSON from stdout, present only when stdout is valid JSON
    - object
    - unknown[]
      - unknown
    - string
    - number, double
    - boolean
  - `started_at` string: ISO 8601 timestamp when execution started on the runner
  - `finished_at` string: ISO 8601 timestamp when execution completed on the runner
  - `elapsed_ms` number, double: Server-measured execution time in milliseconds

## Other responses

- `500`: Error response from API

## Changes

- **2026-10-31** `2095cc90e583`: 2 info
  - api tag `Gateway Manager` added
  - api tag `gatewayManager` removed

[Operation history](https://skmtc.dev/itential/apis/itential-2/changes/gateway_manager/v1/code/run/post.md)

---

[API](https://skmtc.dev/itential/apis/itential-2.md) - [All operations](https://skmtc.dev/itential/apis/itential-2/llms.txt) - [OpenAPI document](https://skmtc.dev/itential/apis/itential-2/revisions/2095cc90e583?raw)
