---
title: "Create or update a script connection"
method: POST
path: "/api/script-connections"
tags: ["Script Connections"]
---

# Create or update a script connection

`POST /api/script-connections`

## Request body

- union
  - object
    - `id` string, uuid
    - `slug` string, required
    - `displayName` string
    - `scope` 'global' | 'agent' | 'repo'
    - `scopeId` string, nullable
    - `allowedHosts` string[]
    - `credentialBindingId` string, uuid, nullable
    - `auth` union
      - object
        - `type` 'none', required
      - object
        - `type` 'bearer', required
        - `secret` string
        - `configKey` string
        - `template` string
        - `hosts` string[]
      - object
        - `type` 'header', required
        - `headerName` string, required
        - `secret` string
        - `configKey` string
        - `template` string
        - `hosts` string[]
      - object
        - `type` 'query', required
        - `paramName` string, required
        - `secret` string
        - `configKey` string
        - `template` string
        - `hosts` string[]
      - object
        - `type` 'oauth', required
        - `authorizationId` string, required
        - `configKey` string
        - `template` string
        - `hosts` string[]
    - `configKey` string
    - `headerTemplate` string
    - `queryTemplate` string
    - `authKind` 'config' | 'oauth'
    - `oauthAuthorizationId` string
    - `enabled` boolean
    - `kind` 'openapi', required
    - `baseUrl` string, uri
    - `openapiSpecUrl` string, uri
    - `openapiSpecJson` string
    - `specSource` object
      - `kind` 'vendored', required
      - `slug` string, required
  - object
    - `id` string, uuid
    - `slug` string, required
    - `displayName` string
    - `scope` 'global' | 'agent' | 'repo'
    - `scopeId` string, nullable
    - `allowedHosts` string[], required
    - `credentialBindingId` string, uuid, nullable
    - `auth` union
      - object
        - `type` 'none', required
      - object
        - `type` 'bearer', required
        - `secret` string
        - `configKey` string
        - `template` string
        - `hosts` string[]
      - object
        - `type` 'header', required
        - `headerName` string, required
        - `secret` string
        - `configKey` string
        - `template` string
        - `hosts` string[]
      - object
        - `type` 'query', required
        - `paramName` string, required
        - `secret` string
        - `configKey` string
        - `template` string
        - `hosts` string[]
      - object
        - `type` 'oauth', required
        - `authorizationId` string, required
        - `configKey` string
        - `template` string
        - `hosts` string[]
    - `configKey` string
    - `headerTemplate` string
    - `queryTemplate` string
    - `authKind` 'config' | 'oauth'
    - `oauthAuthorizationId` string
    - `enabled` boolean
    - `kind` 'graphql', required
    - `baseUrl` string, uri, required
  - object
    - `id` string, uuid
    - `slug` string, required
    - `displayName` string
    - `scope` 'global' | 'agent' | 'repo'
    - `scopeId` string, nullable
    - `allowedHosts` string[]
    - `credentialBindingId` string, uuid, nullable
    - `auth` union
      - object
        - `type` 'none', required
      - object
        - `type` 'bearer', required
        - `secret` string
        - `configKey` string
        - `template` string
        - `hosts` string[]
      - object
        - `type` 'header', required
        - `headerName` string, required
        - `secret` string
        - `configKey` string
        - `template` string
        - `hosts` string[]
      - object
        - `type` 'query', required
        - `paramName` string, required
        - `secret` string
        - `configKey` string
        - `template` string
        - `hosts` string[]
      - object
        - `type` 'oauth', required
        - `authorizationId` string, required
        - `configKey` string
        - `template` string
        - `hosts` string[]
    - `configKey` string
    - `headerTemplate` string
    - `queryTemplate` string
    - `authKind` 'config' | 'oauth'
    - `oauthAuthorizationId` string
    - `enabled` boolean
    - `kind` 'mcp', required
    - `mcpServerId` string, uuid, required

## Response `200`

Saved script connection

- object
  - `connection` object, required
    - `id` string, required
    - `slug` string, required
    - `displayName` string, nullable, required
    - `kind` 'raw' | 'openapi' | 'mcp' | 'graphql', required
    - `scope` 'global' | 'agent' | 'repo', required
    - `scopeId` string, nullable, required
    - `baseUrl` string, nullable, required
    - `baseUrlSource` 'user' | 'spec', required
    - `baseUrlMismatch` object
      - `specUrl` string, required
      - `effectiveUrl` string, required
    - `allowedHosts` string[], required
    - `credentialBindingId` string, nullable, required
    - `authType` 'none' | 'bearer' | 'header' | 'query' | 'oauth', required
    - `authConfigKey` string, nullable, required
    - `authAuthorizationId` string, nullable, required
    - `authParamName` string, nullable, required
    - `authTemplateOverride` string, nullable, required
    - `authHostsOverride` string[], nullable, required
    - `openapiSpecSourceKind` 'url' | 'inline' | 'agent_fs' | 'vendored' | 'null', nullable, required
    - `openapiSpecSource` string, nullable, required
    - `openapiSpecEtag` string, nullable, required
    - `openapiSpecFetchedAt` string, nullable, required
    - `mcpServerId` string, nullable, required
    - `generatedAt` string, nullable, required
    - `generationError` string, nullable, required
    - `enabled` boolean, required
    - `version` number, required
    - `createdAt` string, required
    - `updatedAt` string, required
    - `createdBy` string, nullable, required
    - `updatedBy` string, nullable, required
    - `operationCount` number, required
    - `toolCount` number, required
    - `credentialBinding` object, nullable, required
      - `id` string, required
      - `configKey` string, required
      - `authKind` 'config' | 'oauth', required
      - `oauthAuthorizationId` string
      - `tokenStatus` 'ok' | 'expiring' | 'refresh-failed' | 'revoked' | 'missing'
    - `auth` object, required
      - `type` 'none' | 'bearer' | 'header' | 'query' | 'oauth', required
      - `configKey` string
      - `authorizationId` string
      - `paramName` string
      - `status` 'ok' | 'expiring' | 'refresh-failed' | 'revoked' | 'missing'

## Other responses

- `400` — Validation or generation error
- `403` — Only the lead agent can manage script connections

## 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`
- **2026-07-24** `5caa2f4d1afb` — 1 breaking, 1 info
  - removed `subschema #1, subschema #2, subschema #3` from the request body `oneOf` list
  - added `subschema #1, subschema #2, subschema #3` to the request body `oneOf` list
- **2026-07-09** `4f56890cc278` — 1 info
  - endpoint added
- **2026-07-02** `0c910612f9ac` — 1 breaking
  - api path removed without deprecation

[Change history](https://skmtc.dev/desplega-ai/apis/agent-swarm-api/changes/api/script-connections/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/db1079e034dc/schema)
