---
title: "Create or update a reusable script"
method: POST
path: "/api/scripts/upsert"
tags: ["Scripts"]
---

# Create or update a reusable script

`POST /api/scripts/upsert`

Explicit script upserts run a TypeScript typecheck before writing.

## Request body

- object
  - `name` string, required
  - `source` string, required
  - `description` string
  - `intent` string
  - `scope` 'global' | 'agent'
  - `fsMode` 'none' | 'workspace-rw'

## Response `200`

Script upserted

- object
  - `name` string, required
  - `version` number, required
  - `contentDeduped` boolean, required

## Other responses

- `400` — Validation or typecheck failure
- `403` — Global write requires lead agent

---

[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)
