Admin API key for organization-level operations (managing projects, API keys). Create one in Settings > API Keys or via POST /api/api-keys. Format: sk-lw-{id}_{secret}.
Stop an agent
Requests a stop of the agent on every target of its plan. Send expectedTargetIds with the plan's target ids to refuse the stop (agent_stop_plan_changed) when the plan changed since you read it. A critical stop is applied at once; any other severity waits for an approval by another credential (status: pending_approval). The targets are applied in the background: read the stop back to follow each target's outcome. A trace rule's webhook action can post here with the API key in its Authorization header.
Try this endpoint
app.langwatch.ai
API key · Authorization
Kept in this tab. Cleared when you reload.
This sends a live request to app.langwatch.ai.
Request and response examples
import osimport requestsorigin = "https://app.langwatch.ai"path = "/api/v1/governance/agents/<agentId>/stop"api_key = os.environ["LANGWATCH_API_KEY"]headers = { "Authorization": "Bearer " + api_key, "Content-Type": "application/json",}payload = {}response = requests.post( origin + path, headers=headers, json=payload,)print(response.json())const url = "https://app.langwatch.ai/api/v1/governance/agents/<agentId>/stop";const response = await fetch(url, { method: "POST", headers: { "Authorization": "Bearer " + process.env.LANGWATCH_API_KEY, "Content-Type": "application/json", }, body: JSON.stringify({}),});const data = await response.json();curl --request POST \ --url 'https://app.langwatch.ai/api/v1/governance/agents/<agentId>/stop' \ --header "Authorization: Bearer $LANGWATCH_API_KEY" \ --header 'Content-Type: application/json' \ --data '{}'Call the LangWatch API from this project: Stop an agent.Request: POST https://app.langwatch.ai/api/v1/governance/agents/<agentId>/stopReference: https://langwatch.ai/docs/api-reference/governance-kill-switch/stop-an-agent.mdAuthentication: send the Authorization header as a Bearer token, read from the LANGWATCH_API_KEY environment variable. Never hard-code the key.Body (application/json):```json{}```Use the HTTP client this project already uses, handle non-2xx responses, and show me the parsed result.Success
application/json · Generated from schema
{ "data": { "id": "string", "agentId": "string", "agentName": "string", "status": "pending_approval", "severity": "low", "approval": "immediate", "trigger": "user", "reason": "string", "requestedBy": { "userId": "string", "apiKeyId": "string" }, "decidedByUserId": "string", "restoredByUserId": "string", "targets": [ { "id": "string", "label": "string", "target": { "kind": null, "ingestionSourceId": null, "endpointName": null }, "state": "pending", "errorCode": "string", "appliedAt": "string", "revertedAt": "string", "alreadyStopped": false, "gone": false, "keptDisabled": false, "dropped": false, "dropId": "string" } ], "requestedAt": "string", "decidedAt": "string", "quarantinedAt": "string", "restoreRequestedAt": "string", "restoredAt": "string", "lastRequestId": "string" }}Bad Request
application/json · Generated from schema
{ "type": "string", "code": "string", "message": "string", "retryable": false, "meta": {}, "trace_id": "string", "span_id": "string", "trace": { "traceId": "string", "spanId": "string", "traceUrl": "string", "logsUrl": "string" }, "tips": [ "string" ], "docs_url": "string", "fault": "customer", "reasons": [ null ]}Unauthorized
application/json · Generated from schema
{ "type": "string", "code": "string", "message": "string", "retryable": false, "meta": {}, "trace_id": "string", "span_id": "string", "trace": { "traceId": "string", "spanId": "string", "traceUrl": "string", "logsUrl": "string" }, "tips": [ "string" ], "docs_url": "string", "fault": "customer", "reasons": [ null ]}Forbidden
application/json · Generated from schema
{ "type": "string", "code": "string", "message": "string", "retryable": false, "meta": {}, "trace_id": "string", "span_id": "string", "trace": { "traceId": "string", "spanId": "string", "traceUrl": "string", "logsUrl": "string" }, "tips": [ "string" ], "docs_url": "string", "fault": "customer", "reasons": [ null ]}Not Found
application/json · Generated from schema
{ "type": "string", "code": "string", "message": "string", "retryable": false, "meta": {}, "trace_id": "string", "span_id": "string", "trace": { "traceId": "string", "spanId": "string", "traceUrl": "string", "logsUrl": "string" }, "tips": [ "string" ], "docs_url": "string", "fault": "customer", "reasons": [ null ]}The stop or its plan is not in a state that allows this
application/json · Generated from schema
{ "type": "string", "code": "string", "message": "string", "retryable": false, "meta": {}, "trace_id": "string", "span_id": "string", "trace": { "traceId": "string", "spanId": "string", "traceUrl": "string", "logsUrl": "string" }, "tips": [ "string" ], "docs_url": "string", "fault": "customer", "reasons": [ null ]}Unprocessable Entity
application/json · Generated from schema
{ "type": "string", "code": "string", "message": "string", "retryable": false, "meta": {}, "trace_id": "string", "span_id": "string", "trace": { "traceId": "string", "spanId": "string", "traceUrl": "string", "logsUrl": "string" }, "tips": [ "string" ], "docs_url": "string", "fault": "customer", "reasons": [ null ]}Internal Server Error
application/json · Generated from schema
{ "type": "string", "code": "string", "message": "string", "retryable": false, "meta": {}, "trace_id": "string", "span_id": "string", "trace": { "traceId": "string", "spanId": "string", "traceUrl": "string", "logsUrl": "string" }, "tips": [ "string" ], "docs_url": "string", "fault": "customer", "reasons": [ null ]}Path parameters
agentIdstringrequiredRequest body
application/json · Required
reasonstringrequiredseveritystring"low""medium""high""critical""high"expectedTargetIdsstring[]Responses
202Success
application/json
dataobjectrequired400Bad Request
application/json
typestringrequiredcodestringrequiredmessagestringrequiredretryablebooleanrequiredmetaobjecttrace_idstringspan_idstringtraceobjecttipsstring[]docs_urlstringfaultstring"customer""platform""provider""presumed_platform"reasonsany[]401Unauthorized
application/json
typestringrequiredcodestringrequiredmessagestringrequiredretryablebooleanrequiredmetaobjecttrace_idstringspan_idstringtraceobjecttipsstring[]docs_urlstringfaultstring"customer""platform""provider""presumed_platform"reasonsany[]403Forbidden
application/json
typestringrequiredcodestringrequiredmessagestringrequiredretryablebooleanrequiredmetaobjecttrace_idstringspan_idstringtraceobjecttipsstring[]docs_urlstringfaultstring"customer""platform""provider""presumed_platform"reasonsany[]404Not Found
application/json
typestringrequiredcodestringrequiredmessagestringrequiredretryablebooleanrequiredmetaobjecttrace_idstringspan_idstringtraceobjecttipsstring[]docs_urlstringfaultstring"customer""platform""provider""presumed_platform"reasonsany[]409The stop or its plan is not in a state that allows this
application/json
typestringrequiredcodestringrequiredmessagestringrequiredretryablebooleanrequiredmetaobjecttrace_idstringspan_idstringtraceobjecttipsstring[]docs_urlstringfaultstring"customer""platform""provider""presumed_platform"reasonsany[]422Unprocessable Entity
application/json
typestringrequiredcodestringrequiredmessagestringrequiredretryablebooleanrequiredmetaobjecttrace_idstringspan_idstringtraceobjecttipsstring[]docs_urlstringfaultstring"customer""platform""provider""presumed_platform"reasonsany[]500Internal Server Error
application/json
typestringrequiredcodestringrequiredmessagestringrequiredretryablebooleanrequiredmetaobjecttrace_idstringspan_idstringtraceobjecttipsstring[]docs_urlstringfaultstring"customer""platform""provider""presumed_platform"reasonsany[]