Stop Work
BetaSelfHostedWork beta().environments().work().stop(WorkStopParamsparams, RequestOptionsrequestOptions = RequestOptions.none())POST/v1/environments/{environment_id}/work/{work_id}/stop
Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments. They are included here as a reference; you do not need to invoke them directly.
Stop a work item, initiating graceful or forced shutdown.
Parameters
Returns
Stop Work
package com.anthropic.example;
import com.anthropic.client.AnthropicClient;
import com.anthropic.client.okhttp.AnthropicOkHttpClient;
import com.anthropic.models.beta.environments.work.BetaSelfHostedWork;
import com.anthropic.models.beta.environments.work.BetaSelfHostedWorkStopRequest;
import com.anthropic.models.beta.environments.work.WorkStopParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
AnthropicClient client = AnthropicOkHttpClient.fromEnv();
WorkStopParams params = WorkStopParams.builder()
.environmentId("env_011CZkZ9X2dpNyB7HsEFoRfW")
.workId("work_id")
.betaSelfHostedWorkStopRequest(BetaSelfHostedWorkStopRequest.builder().build())
.build();
BetaSelfHostedWork betaSelfHostedWork = client.beta().environments().work().stop(params);
}
}{
"id": "id",
"acknowledged_at": "acknowledged_at",
"created_at": "created_at",
"data": {
"id": "id",
"type": "session"
},
"environment_id": "environment_id",
"latest_heartbeat_at": "latest_heartbeat_at",
"metadata": {
"foo": "string"
},
"secret": "secret",
"started_at": "started_at",
"state": "queued",
"stop_requested_at": "stop_requested_at",
"stopped_at": "stopped_at",
"type": "work"
}Returns Examples
{
"id": "id",
"acknowledged_at": "acknowledged_at",
"created_at": "created_at",
"data": {
"id": "id",
"type": "session"
},
"environment_id": "environment_id",
"latest_heartbeat_at": "latest_heartbeat_at",
"metadata": {
"foo": "string"
},
"secret": "secret",
"started_at": "started_at",
"state": "queued",
"stop_requested_at": "stop_requested_at",
"stopped_at": "stopped_at",
"type": "work"
}