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

## Changes

- **2026-08-07** `06cac6a7c5bc` — 3 info
  - added the media type `application/json` for the response with the status `200`
  - added the media type `application/json` for the response with the status `400`
  - added the media type `application/json` for the response with the status `403`

[Change history](https://skmtc.dev/desplega-ai/apis/agent-swarm-api/changes/api/scripts/upsert/post.md)

---

[API](https://skmtc.dev/desplega-ai/apis/agent-swarm-api.md) · [All operations](https://skmtc.dev/desplega-ai/apis/agent-swarm-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/desplega-ai/agent-swarm-api/revisions/e0acd2155cad/schema)
