---
title: "Create or update a script credential binding"
method: POST
path: "/api/credential-bindings"
tags: ["Script Connections"]
---

# Create or update a script credential binding

`POST /api/credential-bindings`

## Request body

- object
  - `id` string, uuid
  - `configKey` string, required
  - `allowedHosts` string[], required
  - `headerTemplate` string
  - `queryTemplate` string
  - `scope` 'global' | 'agent' | 'repo'
  - `scopeId` string, nullable
  - `active` boolean
  - `authKind` 'config' | 'oauth'
  - `oauthAuthorizationId` string

## Response `200`

Saved credential binding

- object
  - `binding` object, required
    - `id` string, required
    - `configKey` string, required
    - `allowedHosts` string[], required
    - `headerTemplate` string
    - `queryTemplate` string
    - `scope` 'global' | 'agent' | 'repo', required
    - `scopeId` string, nullable
    - `active` boolean, required
    - `authKind` 'config' | 'oauth', required
    - `oauthAuthorizationId` string
    - `source` 'default' | 'user' | 'migration' | 'connection', required
    - `managedByConnectionId` string, nullable, required
    - `createdAt` string, required
    - `updatedAt` string, required
    - `createdBy` string, nullable, required
    - `updatedBy` string, nullable, required
    - `tokenStatus` 'ok' | 'expiring' | 'refresh-failed' | 'revoked' | 'missing'

## Other responses

- `400` — Validation 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 warning, 1 info
  - removed the request property `oauthProvider`
  - added the new optional request property `oauthAuthorizationId`
- **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/credential-bindings/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)
