---
title: "Run a reusable or inline script"
method: POST
path: "/api/scripts/run"
tags: ["Scripts"]
---

# Run a reusable or inline script

`POST /api/scripts/run`

Inline source skips typecheck and is auto-saved as a scratch script only on success.

## Request body

- object
  - `name` string
  - `source` string
  - `args` unknown
  - `intent` string
  - `scope` 'global' | 'agent'
  - `fsMode` 'none' | 'workspace-rw'
  - `idempotencyKey` string

## Response `200`

Script run completed

- object
  - `result` unknown
  - `autoSaved` object
    - `slug` string, required
    - `reason` string, required
  - `kvSaved` object
    - `namespace` string, required
    - `key` string, required
  - `truncated` object, required
    - `stdout` boolean, required
    - `stderr` boolean, required
  - `durationMs` number, required
  - `stdout` string, required
  - `stderr` string, required
  - `exitCode` number, required
  - `error` 'timeout' | 'oom' | 'killed' | 'import_violation' | 'eval_error' | 'executor_error'
  - `runtimeError` object
    - `name` string, required
    - `message` string, required
    - `stack` string, required
    - `userFrames` object[], required
      - `file` string, required
      - `line` number, required
      - `column` number, required
      - `raw` string, required
    - `userScriptLine` number
    - `userScriptColumn` number

## Other responses

- `400` — Validation error
- `404` — Script not found
- `501` — workspace-rw scripts are not supported in v1

---

[API](https://skmtc.net/desplega-ai/apis/agent-swarm-api.md) · [All operations](https://skmtc.net/desplega-ai/apis/agent-swarm-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/desplega-ai/agent-swarm-api/versions/0375890be8c4/schema)
