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

# Agent Disable API

> Enable or disable an agent programmatically

Enables or disables an agent in your workspace. Disabled agents cannot be used by workspace members until re-enabled.

## Before You Start

* **Legacy Assistants API**: This is the new Agents API with native Vercel AI SDK compatibility. If you're using the legacy Assistants API, see the [migration guide](/en/developer/agents-api/assistant-to-agent-migration).
* **Admin action**: This is an administrative action. Only workspace admins or users with appropriate permissions can disable/enable agents.

## Base URL

```
https://api.langdock.com/agent/v1/disable
```

<Warning>
  **Dedicated deployments**

  Replace `api.langdock.com` with `<your-deployment-url>/api/public` in all requests.
</Warning>

## Use Cases

* **Temporarily disable** an agent that needs maintenance or updates
* **Re-enable** a previously disabled agent
* **Control agent availability** during rollouts or testing

## Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `agentId` | string | Yes | UUID of the agent to enable/disable |
| `disabled` | boolean | Yes | `true` to disable, `false` to enable |

## Example

```javascript theme={null}
const axios = require("axios");

async function toggleAgentStatus(agentId, disabled) {
  const response = await axios.patch(
    "https://api.langdock.com/agent/v1/disable",
    {
      agentId: agentId,
      disabled: disabled
    },
    {
      headers: {
        Authorization: "Bearer YOUR_API_KEY",
        "Content-Type": "application/json"
      }
    }
  );

  console.log(`Agent ${disabled ? 'disabled' : 'enabled'}:`, response.data);
}

// Disable an agent
toggleAgentStatus("550e8400-e29b-41d4-a716-446655440000", true);

// Re-enable an agent
toggleAgentStatus("550e8400-e29b-41d4-a716-446655440000", false);
```

## Response Format

### Success Response (200 OK)

```typescript theme={null}
{
  status: "success";
  message: "Agent disabled successfully" | "Agent enabled successfully";
}
```

## Error Handling

| Status Code | Description |
| - | - |
| 400 | Invalid parameters (missing agentId or disabled) |
| 401 | Invalid or missing API key |
| 403 | Insufficient permissions to disable agents |
| 404 | Agent not found or API key does not have access |
| 429 | Rate limit exceeded |

## Behavior

When an agent is disabled:

* Users cannot start new conversations with the agent
* The agent does not appear in the agent library for regular users
* Existing conversations may still be viewable but the agent cannot respond
* Admins can still view and manage the agent
* The agent can be re-enabled at any time

<Info>
  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](/en/admin/ai-adoption-and-rollout/best-practices/api-key-best-practices).
</Info>


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