> ## Documentation Index
> Fetch the complete documentation index at: https://docs.langdock.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Disable or Re-enable an Agent

> Turn an agent off with a stored reason, or turn it back on.

Turns an agent off, or back on, as a governance action. A disabled agent cannot be used until you turn it back on. The response is the updated agent, with the same fields as [Get an agent](https://docs.langdock.com/en/developer/governance-api/get-agent.md).

The [Agent Disable API](https://docs.langdock.com/en/developer/agents-api/agent-disable.md) is a different call. It uses the `ASSISTANT_API` scope and only reaches an agent that key can edit. This call does not require the agent to be shared with the key.

## Base URL

```
https://api.langdock.com/governance/v1/agents/{agentId}/disable
```

> [!WARNING]
>
> **Dedicated deployments**
>
> Replace `api.langdock.com` with `<your-deployment-url>/api/public` in all requests.

## Prerequisites

* **API key** with the `GOVERNANCE_API` scope
* **Enable Governance** is on
* `agentId` is the agent UUID

## Request body

| Field | Type | Required | Description |
| - | - | - | - |
| `disabled` | boolean | Yes | `true` to turn the agent off, `false` to turn it back on |
| `disabledReason` | string | No | Up to 500 characters, stored while the agent is off |

Whitespace at the ends of `disabledReason` is removed. An empty reason is stored as null. Everyone who can see the agent sees the reason on its **Disabled** badge. The owner and editors also see it in the agent editor.

Turning the agent back on clears `disabledReason` and `disabledAt`, including when the request still sends a reason. The API key's user is stored as the person who disabled the agent. This response does not include that id.

```bash theme={null}
curl -X PATCH "https://api.langdock.com/governance/v1/agents/2f1c7b9e-5d7a-4f2a-9d2e-5b2c0e8f1a3b/disable" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "disabled": true, "disabledReason": "ServiceNow INC0012345: failed compliance review" }'
```

```bash theme={null}
curl -X PATCH "https://api.langdock.com/governance/v1/agents/2f1c7b9e-5d7a-4f2a-9d2e-5b2c0e8f1a3b/disable" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "disabled": false }'
```

## Behavior

* **Turned off:** `disabled` is `true`, `disabledReason` is the stored reason, and `disabledAt` is set.
* **Turned back on:** `disabled` is `false`, and `disabledReason` and `disabledAt` are null.
* **Agent not available?** Returns `404` with the message `Agent not found`.
* **Missing `disabled`, or a reason longer than 500 characters?** Returns `400`.

> [!NOTE]
>
> Langdock intentionally blocks browser-origin requests to protect your API key and ensure your applications remain secure. For more information, please see our guide on [API Key Best Practices](https://docs.langdock.com/en/admin/ai-adoption-and-rollout/best-practices/api-key-best-practices.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.