---
title: "Invoke an externally-exposed swarm script"
method: POST
path: "/api/x/script/{endpointId}"
tags: ["External APIs"]
---

# Invoke an externally-exposed swarm script

`POST /api/x/script/{endpointId}`

Runs the script bound to this endpoint and returns a JSON envelope `{ ok, result, error, durationMs }` (HTTP 200) once execution is reached. Auth/routing failures use 401 (bad/missing bearer) and 404 (unknown or disabled endpoint). Optional `X-Swarm-Timeout-Ms` header (default 60000, clamped 1000–300000) sets the wall-clock timeout.

## Path parameters

- `endpointId` string, required

## Response `200`

Script executed — see `ok` in the envelope

- object
  - `ok` boolean, required
  - `result` unknown
  - `error` object, nullable, required
    - `type` string, required
    - `message` string, required
    - `details` string[]
  - `durationMs` number, required

## Other responses

- `401` — Missing or invalid bearer token
- `404` — Endpoint not found or disabled
- `501` — workspace-rw scripts are not supported

---

[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/ef761849166b/schema)
