| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
from typing import Dict, List, Union, Iterable, Optional |
| 4 |
from datetime import datetime |
| 5 |
from itertools import chain |
| 6 |
|
| 7 |
import httpx2 |
| 8 |
|
| 9 |
from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given |
| 10 |
from ..._utils import is_given, path_template, strip_not_given |
| 11 |
from ..._compat import cached_property |
| 12 |
from ..._resource import SyncAPIResource, AsyncAPIResource |
| 13 |
from ..._response import ( |
| 14 |
to_raw_response_wrapper, |
| 15 |
to_streamed_response_wrapper, |
| 16 |
async_to_raw_response_wrapper, |
| 17 |
async_to_streamed_response_wrapper, |
| 18 |
) |
| 19 |
from ...pagination import SyncPageCursor, AsyncPageCursor |
| 20 |
from ...types.beta import ( |
| 21 |
BetaManagedAgentsScheduleParams, |
| 22 |
BetaManagedAgentsDeploymentStatus, |
| 23 |
deployment_create_params, |
| 24 |
deployment_update_params, |
| 25 |
) |
| 26 |
from ..._base_client import AsyncPaginator, make_request_options |
| 27 |
from ...types.anthropic_beta_param import AnthropicBetaParam |
| 28 |
from ...types.beta.beta_managed_agents_deployment import BetaManagedAgentsDeployment |
| 29 |
from ...types.beta.beta_managed_agents_deployment_run import BetaManagedAgentsDeploymentRun |
| 30 |
from ...types.beta.beta_managed_agents_schedule_params import BetaManagedAgentsScheduleParams |
| 31 |
from ...types.beta.beta_managed_agents_deployment_status import BetaManagedAgentsDeploymentStatus |
| 32 |
from ...types.beta.beta_managed_agents_budget_limit_param import BetaManagedAgentsBudgetLimitParam |
| 33 |
from ...types.beta.beta_managed_agents_deployment_initial_event_params import ( |
| 34 |
BetaManagedAgentsDeploymentInitialEventParams, |
| 35 |
) |
| 36 |
|
| 37 |
__all__ = ["Deployments", "AsyncDeployments"] |
| 38 |
|
| 39 |
|
| 40 |
class Deployments(SyncAPIResource): |
| 41 |
@cached_property |
| 42 |
def with_raw_response(self) -> DeploymentsWithRawResponse: |
| 43 |
""" |
| 44 |
This property can be used as a prefix for any HTTP method call to return |
| 45 |
the raw response object instead of the parsed content. |
| 46 |
|
| 47 |
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers |
| 48 |
""" |
| 49 |
return DeploymentsWithRawResponse(self) |
| 50 |
|
| 51 |
@cached_property |
| 52 |
def with_streaming_response(self) -> DeploymentsWithStreamingResponse: |
| 53 |
""" |
| 54 |
An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 55 |
|
| 56 |
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response |
| 57 |
""" |
| 58 |
return DeploymentsWithStreamingResponse(self) |
| 59 |
|
| 60 |
def create( |
| 61 |
self, |
| 62 |
*, |
| 63 |
agent: deployment_create_params.Agent, |
| 64 |
environment_id: str, |
| 65 |
initial_events: Iterable[BetaManagedAgentsDeploymentInitialEventParams], |
| 66 |
name: str, |
| 67 |
budget: Optional[BetaManagedAgentsBudgetLimitParam] | Omit = omit, |
| 68 |
description: Optional[str] | Omit = omit, |
| 69 |
metadata: Dict[str, str] | Omit = omit, |
| 70 |
resources: Iterable[deployment_create_params.Resource] | Omit = omit, |
| 71 |
schedule: Optional[BetaManagedAgentsScheduleParams] | Omit = omit, |
| 72 |
vault_ids: SequenceNotStr[str] | Omit = omit, |
| 73 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 74 |
workspace_id: str | Omit = omit, |
| 75 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 76 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 77 |
extra_headers: Headers | None = None, |
| 78 |
extra_query: Query | None = None, |
| 79 |
extra_body: Body | None = None, |
| 80 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 81 |
) -> BetaManagedAgentsDeployment: |
| 82 |
"""Create Deployment |
| 83 |
|
| 84 |
Args: |
| 85 |
agent: Agent to deploy. |
| 86 |
|
| 87 |
Accepts the `agent` ID string, which pins the latest version, |
| 88 |
or an `agent` object with both id and version specified. The agent must exist |
| 89 |
and not be archived. |
| 90 |
|
| 91 |
environment_id: ID of the `environment` defining the container configuration for sessions |
| 92 |
created from this deployment. |
| 93 |
|
| 94 |
initial_events: Events to send to each session immediately after creation. At least 1, |
| 95 |
maximum 50. |
| 96 |
|
| 97 |
name: Human-readable name for the deployment. |
| 98 |
|
| 99 |
budget: A hard spend ceiling. The session stops issuing new model requests once the |
| 100 |
tracked list cost reaches `max_list_cost`. |
| 101 |
|
| 102 |
description: Description of what the deployment does. |
| 103 |
|
| 104 |
metadata: Arbitrary key-value metadata. Maximum 16 pairs, keys up to 64 chars, values up |
| 105 |
to 512 chars. |
| 106 |
|
| 107 |
resources: Resources (e.g. repositories, files) to mount into each session's container. |
| 108 |
Maximum 500. |
| 109 |
|
| 110 |
schedule: 5-field POSIX cron schedule. Literal wall-clock matching in the configured |
| 111 |
timezone. |
| 112 |
|
| 113 |
vault_ids: Vault IDs for stored credentials the agent can use during sessions created from |
| 114 |
this deployment. Maximum 50. |
| 115 |
|
| 116 |
betas: Optional header to specify the beta version(s) you want to use. |
| 117 |
|
| 118 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 119 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 120 |
|
| 121 |
Only needed for credentials that can act on more than one Workspace. A |
| 122 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 123 |
match that Workspace. |
| 124 |
|
| 125 |
extra_headers: Send extra headers |
| 126 |
|
| 127 |
extra_query: Add additional query parameters to the request |
| 128 |
|
| 129 |
extra_body: Add additional JSON properties to the request |
| 130 |
|
| 131 |
timeout: Override the client-level default timeout for this request, in seconds |
| 132 |
""" |
| 133 |
extra_headers = { |
| 134 |
**strip_not_given( |
| 135 |
{ |
| 136 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 137 |
if is_given(betas) |
| 138 |
else not_given, |
| 139 |
"anthropic-workspace-id": workspace_id, |
| 140 |
} |
| 141 |
), |
| 142 |
**(extra_headers or {}), |
| 143 |
} |
| 144 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 145 |
return self._post( |
| 146 |
"/v1/deployments?beta=true", |
| 147 |
body={ |
| 148 |
"agent": agent, |
| 149 |
"environment_id": environment_id, |
| 150 |
"initial_events": initial_events, |
| 151 |
"name": name, |
| 152 |
"budget": budget, |
| 153 |
"description": description, |
| 154 |
"metadata": metadata, |
| 155 |
"resources": resources, |
| 156 |
"schedule": schedule, |
| 157 |
"vault_ids": vault_ids, |
| 158 |
}, |
| 159 |
options=make_request_options( |
| 160 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 161 |
), |
| 162 |
cast_to=BetaManagedAgentsDeployment, |
| 163 |
) |
| 164 |
|
| 165 |
def retrieve( |
| 166 |
self, |
| 167 |
deployment_id: str, |
| 168 |
*, |
| 169 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 170 |
workspace_id: str | Omit = omit, |
| 171 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 172 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 173 |
extra_headers: Headers | None = None, |
| 174 |
extra_query: Query | None = None, |
| 175 |
extra_body: Body | None = None, |
| 176 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 177 |
) -> BetaManagedAgentsDeployment: |
| 178 |
""" |
| 179 |
Get Deployment |
| 180 |
|
| 181 |
Args: |
| 182 |
deployment_id: Unique identifier of the deployment. |
| 183 |
|
| 184 |
betas: Optional header to specify the beta version(s) you want to use. |
| 185 |
|
| 186 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 187 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 188 |
|
| 189 |
Only needed for credentials that can act on more than one Workspace. A |
| 190 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 191 |
match that Workspace. |
| 192 |
|
| 193 |
extra_headers: Send extra headers |
| 194 |
|
| 195 |
extra_query: Add additional query parameters to the request |
| 196 |
|
| 197 |
extra_body: Add additional JSON properties to the request |
| 198 |
|
| 199 |
timeout: Override the client-level default timeout for this request, in seconds |
| 200 |
""" |
| 201 |
if not deployment_id: |
| 202 |
raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") |
| 203 |
extra_headers = { |
| 204 |
**strip_not_given( |
| 205 |
{ |
| 206 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 207 |
if is_given(betas) |
| 208 |
else not_given, |
| 209 |
"anthropic-workspace-id": workspace_id, |
| 210 |
} |
| 211 |
), |
| 212 |
**(extra_headers or {}), |
| 213 |
} |
| 214 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 215 |
return self._get( |
| 216 |
path_template("/v1/deployments/{deployment_id}?beta=true", deployment_id=deployment_id), |
| 217 |
options=make_request_options( |
| 218 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 219 |
), |
| 220 |
cast_to=BetaManagedAgentsDeployment, |
| 221 |
) |
| 222 |
|
| 223 |
def update( |
| 224 |
self, |
| 225 |
deployment_id: str, |
| 226 |
*, |
| 227 |
agent: deployment_update_params.Agent | Omit = omit, |
| 228 |
budget: Optional[BetaManagedAgentsBudgetLimitParam] | Omit = omit, |
| 229 |
description: Optional[str] | Omit = omit, |
| 230 |
environment_id: str | Omit = omit, |
| 231 |
initial_events: Iterable[BetaManagedAgentsDeploymentInitialEventParams] | Omit = omit, |
| 232 |
metadata: Optional[Dict[str, Optional[str]]] | Omit = omit, |
| 233 |
name: str | Omit = omit, |
| 234 |
resources: Optional[Iterable[deployment_update_params.Resource]] | Omit = omit, |
| 235 |
schedule: Optional[BetaManagedAgentsScheduleParams] | Omit = omit, |
| 236 |
vault_ids: Optional[SequenceNotStr[str]] | Omit = omit, |
| 237 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 238 |
workspace_id: str | Omit = omit, |
| 239 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 240 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 241 |
extra_headers: Headers | None = None, |
| 242 |
extra_query: Query | None = None, |
| 243 |
extra_body: Body | None = None, |
| 244 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 245 |
) -> BetaManagedAgentsDeployment: |
| 246 |
""" |
| 247 |
Update Deployment |
| 248 |
|
| 249 |
Args: |
| 250 |
deployment_id: Unique identifier of the deployment to update. |
| 251 |
|
| 252 |
agent: Agent to deploy. Accepts the `agent` ID string, which re-pins to the latest |
| 253 |
version, or an `agent` object with both id and version specified. Omit to |
| 254 |
preserve. Cannot be cleared. |
| 255 |
|
| 256 |
budget: A hard spend ceiling. The session stops issuing new model requests once the |
| 257 |
tracked list cost reaches `max_list_cost`. |
| 258 |
|
| 259 |
description: Description. Omit to preserve; send empty string or null to clear. |
| 260 |
|
| 261 |
environment_id: ID of the `environment` where sessions run. Omit to preserve. Cannot be cleared. |
| 262 |
|
| 263 |
initial_events: Initial events. Full replacement. Omit to preserve. Cannot be cleared. At least |
| 264 |
1, maximum 50. |
| 265 |
|
| 266 |
metadata: Metadata patch. Set a key to a string to upsert it, or to null to delete it. |
| 267 |
Omit the field to preserve. The stored bag is limited to 16 keys (up to 64 chars |
| 268 |
each) with values up to 512 chars. |
| 269 |
|
| 270 |
name: Human-readable name. Must be non-empty. Omit to preserve. Cannot be cleared. |
| 271 |
|
| 272 |
resources: Session resources. Full replacement. Omit to preserve; send empty array or null |
| 273 |
to clear. Maximum 500. |
| 274 |
|
| 275 |
schedule: 5-field POSIX cron schedule. Literal wall-clock matching in the configured |
| 276 |
timezone. |
| 277 |
|
| 278 |
vault_ids: Vault IDs. Full replacement. Omit to preserve; send empty array or null to |
| 279 |
clear. Maximum 50. |
| 280 |
|
| 281 |
betas: Optional header to specify the beta version(s) you want to use. |
| 282 |
|
| 283 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 284 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 285 |
|
| 286 |
Only needed for credentials that can act on more than one Workspace. A |
| 287 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 288 |
match that Workspace. |
| 289 |
|
| 290 |
extra_headers: Send extra headers |
| 291 |
|
| 292 |
extra_query: Add additional query parameters to the request |
| 293 |
|
| 294 |
extra_body: Add additional JSON properties to the request |
| 295 |
|
| 296 |
timeout: Override the client-level default timeout for this request, in seconds |
| 297 |
""" |
| 298 |
if not deployment_id: |
| 299 |
raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") |
| 300 |
extra_headers = { |
| 301 |
**strip_not_given( |
| 302 |
{ |
| 303 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 304 |
if is_given(betas) |
| 305 |
else not_given, |
| 306 |
"anthropic-workspace-id": workspace_id, |
| 307 |
} |
| 308 |
), |
| 309 |
**(extra_headers or {}), |
| 310 |
} |
| 311 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 312 |
return self._post( |
| 313 |
path_template("/v1/deployments/{deployment_id}?beta=true", deployment_id=deployment_id), |
| 314 |
body={ |
| 315 |
"agent": agent, |
| 316 |
"budget": budget, |
| 317 |
"description": description, |
| 318 |
"environment_id": environment_id, |
| 319 |
"initial_events": initial_events, |
| 320 |
"metadata": metadata, |
| 321 |
"name": name, |
| 322 |
"resources": resources, |
| 323 |
"schedule": schedule, |
| 324 |
"vault_ids": vault_ids, |
| 325 |
}, |
| 326 |
options=make_request_options( |
| 327 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 328 |
), |
| 329 |
cast_to=BetaManagedAgentsDeployment, |
| 330 |
) |
| 331 |
|
| 332 |
def list( |
| 333 |
self, |
| 334 |
*, |
| 335 |
agent_id: str | Omit = omit, |
| 336 |
created_at_gte: Union[str, datetime] | Omit = omit, |
| 337 |
created_at_lte: Union[str, datetime] | Omit = omit, |
| 338 |
include_archived: bool | Omit = omit, |
| 339 |
limit: int | Omit = omit, |
| 340 |
page: str | Omit = omit, |
| 341 |
status: BetaManagedAgentsDeploymentStatus | Omit = omit, |
| 342 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 343 |
workspace_id: str | Omit = omit, |
| 344 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 345 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 346 |
extra_headers: Headers | None = None, |
| 347 |
extra_query: Query | None = None, |
| 348 |
extra_body: Body | None = None, |
| 349 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 350 |
) -> SyncPageCursor[BetaManagedAgentsDeployment]: |
| 351 |
""" |
| 352 |
List Deployments |
| 353 |
|
| 354 |
Args: |
| 355 |
agent_id: Filter by agent ID. |
| 356 |
|
| 357 |
created_at_gte: Return deployments created at or after this time (inclusive). |
| 358 |
|
| 359 |
created_at_lte: Return deployments created at or before this time (inclusive). |
| 360 |
|
| 361 |
include_archived: When true, includes archived deployments. Default: false (exclude archived). |
| 362 |
|
| 363 |
limit: Maximum results per page. Default 20, maximum 100. |
| 364 |
|
| 365 |
page: Opaque pagination cursor. |
| 366 |
|
| 367 |
status: Filter by status: `active` or `paused`. Omit for both. To include archived |
| 368 |
deployments, use `include_archived` instead; the two cannot be combined. |
| 369 |
|
| 370 |
betas: Optional header to specify the beta version(s) you want to use. |
| 371 |
|
| 372 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 373 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 374 |
|
| 375 |
Only needed for credentials that can act on more than one Workspace. A |
| 376 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 377 |
match that Workspace. |
| 378 |
|
| 379 |
extra_headers: Send extra headers |
| 380 |
|
| 381 |
extra_query: Add additional query parameters to the request |
| 382 |
|
| 383 |
extra_body: Add additional JSON properties to the request |
| 384 |
|
| 385 |
timeout: Override the client-level default timeout for this request, in seconds |
| 386 |
""" |
| 387 |
extra_headers = { |
| 388 |
**strip_not_given( |
| 389 |
{ |
| 390 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 391 |
if is_given(betas) |
| 392 |
else not_given, |
| 393 |
"anthropic-workspace-id": workspace_id, |
| 394 |
} |
| 395 |
), |
| 396 |
**(extra_headers or {}), |
| 397 |
} |
| 398 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 399 |
return self._get_api_list( |
| 400 |
"/v1/deployments?beta=true", |
| 401 |
page=SyncPageCursor[BetaManagedAgentsDeployment], |
| 402 |
options=make_request_options( |
| 403 |
extra_headers=extra_headers, |
| 404 |
extra_query=extra_query, |
| 405 |
extra_body=extra_body, |
| 406 |
timeout=timeout, |
| 407 |
query={ |
| 408 |
"agent_id": agent_id, |
| 409 |
"created_at[gte]": created_at_gte, |
| 410 |
"created_at[lte]": created_at_lte, |
| 411 |
"include_archived": include_archived, |
| 412 |
"limit": limit, |
| 413 |
"page": page, |
| 414 |
"status": status, |
| 415 |
}, |
| 416 |
), |
| 417 |
model=BetaManagedAgentsDeployment, |
| 418 |
) |
| 419 |
|
| 420 |
def archive( |
| 421 |
self, |
| 422 |
deployment_id: str, |
| 423 |
*, |
| 424 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 425 |
workspace_id: str | Omit = omit, |
| 426 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 427 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 428 |
extra_headers: Headers | None = None, |
| 429 |
extra_query: Query | None = None, |
| 430 |
extra_body: Body | None = None, |
| 431 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 432 |
) -> BetaManagedAgentsDeployment: |
| 433 |
""" |
| 434 |
Archive Deployment |
| 435 |
|
| 436 |
Args: |
| 437 |
deployment_id: Unique identifier of the deployment to archive. |
| 438 |
|
| 439 |
betas: Optional header to specify the beta version(s) you want to use. |
| 440 |
|
| 441 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 442 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 443 |
|
| 444 |
Only needed for credentials that can act on more than one Workspace. A |
| 445 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 446 |
match that Workspace. |
| 447 |
|
| 448 |
extra_headers: Send extra headers |
| 449 |
|
| 450 |
extra_query: Add additional query parameters to the request |
| 451 |
|
| 452 |
extra_body: Add additional JSON properties to the request |
| 453 |
|
| 454 |
timeout: Override the client-level default timeout for this request, in seconds |
| 455 |
""" |
| 456 |
if not deployment_id: |
| 457 |
raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") |
| 458 |
extra_headers = { |
| 459 |
**strip_not_given( |
| 460 |
{ |
| 461 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 462 |
if is_given(betas) |
| 463 |
else not_given, |
| 464 |
"anthropic-workspace-id": workspace_id, |
| 465 |
} |
| 466 |
), |
| 467 |
**(extra_headers or {}), |
| 468 |
} |
| 469 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 470 |
return self._post( |
| 471 |
path_template("/v1/deployments/{deployment_id}/archive?beta=true", deployment_id=deployment_id), |
| 472 |
options=make_request_options( |
| 473 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 474 |
), |
| 475 |
cast_to=BetaManagedAgentsDeployment, |
| 476 |
) |
| 477 |
|
| 478 |
def pause( |
| 479 |
self, |
| 480 |
deployment_id: str, |
| 481 |
*, |
| 482 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 483 |
workspace_id: str | Omit = omit, |
| 484 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 485 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 486 |
extra_headers: Headers | None = None, |
| 487 |
extra_query: Query | None = None, |
| 488 |
extra_body: Body | None = None, |
| 489 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 490 |
) -> BetaManagedAgentsDeployment: |
| 491 |
""" |
| 492 |
Pause Deployment |
| 493 |
|
| 494 |
Args: |
| 495 |
deployment_id: Unique identifier of the deployment to pause. |
| 496 |
|
| 497 |
betas: Optional header to specify the beta version(s) you want to use. |
| 498 |
|
| 499 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 500 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 501 |
|
| 502 |
Only needed for credentials that can act on more than one Workspace. A |
| 503 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 504 |
match that Workspace. |
| 505 |
|
| 506 |
extra_headers: Send extra headers |
| 507 |
|
| 508 |
extra_query: Add additional query parameters to the request |
| 509 |
|
| 510 |
extra_body: Add additional JSON properties to the request |
| 511 |
|
| 512 |
timeout: Override the client-level default timeout for this request, in seconds |
| 513 |
""" |
| 514 |
if not deployment_id: |
| 515 |
raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") |
| 516 |
extra_headers = { |
| 517 |
**strip_not_given( |
| 518 |
{ |
| 519 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 520 |
if is_given(betas) |
| 521 |
else not_given, |
| 522 |
"anthropic-workspace-id": workspace_id, |
| 523 |
} |
| 524 |
), |
| 525 |
**(extra_headers or {}), |
| 526 |
} |
| 527 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 528 |
return self._post( |
| 529 |
path_template("/v1/deployments/{deployment_id}/pause?beta=true", deployment_id=deployment_id), |
| 530 |
options=make_request_options( |
| 531 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 532 |
), |
| 533 |
cast_to=BetaManagedAgentsDeployment, |
| 534 |
) |
| 535 |
|
| 536 |
def run( |
| 537 |
self, |
| 538 |
deployment_id: str, |
| 539 |
*, |
| 540 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 541 |
workspace_id: str | Omit = omit, |
| 542 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 543 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 544 |
extra_headers: Headers | None = None, |
| 545 |
extra_query: Query | None = None, |
| 546 |
extra_body: Body | None = None, |
| 547 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 548 |
) -> BetaManagedAgentsDeploymentRun: |
| 549 |
""" |
| 550 |
Run Deployment Now |
| 551 |
|
| 552 |
Args: |
| 553 |
deployment_id: Unique identifier of the deployment to run. |
| 554 |
|
| 555 |
betas: Optional header to specify the beta version(s) you want to use. |
| 556 |
|
| 557 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 558 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 559 |
|
| 560 |
Only needed for credentials that can act on more than one Workspace. A |
| 561 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 562 |
match that Workspace. |
| 563 |
|
| 564 |
extra_headers: Send extra headers |
| 565 |
|
| 566 |
extra_query: Add additional query parameters to the request |
| 567 |
|
| 568 |
extra_body: Add additional JSON properties to the request |
| 569 |
|
| 570 |
timeout: Override the client-level default timeout for this request, in seconds |
| 571 |
""" |
| 572 |
if not deployment_id: |
| 573 |
raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") |
| 574 |
extra_headers = { |
| 575 |
**strip_not_given( |
| 576 |
{ |
| 577 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 578 |
if is_given(betas) |
| 579 |
else not_given, |
| 580 |
"anthropic-workspace-id": workspace_id, |
| 581 |
} |
| 582 |
), |
| 583 |
**(extra_headers or {}), |
| 584 |
} |
| 585 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 586 |
return self._post( |
| 587 |
path_template("/v1/deployments/{deployment_id}/run?beta=true", deployment_id=deployment_id), |
| 588 |
options=make_request_options( |
| 589 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 590 |
), |
| 591 |
cast_to=BetaManagedAgentsDeploymentRun, |
| 592 |
) |
| 593 |
|
| 594 |
def unpause( |
| 595 |
self, |
| 596 |
deployment_id: str, |
| 597 |
*, |
| 598 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 599 |
workspace_id: str | Omit = omit, |
| 600 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 601 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 602 |
extra_headers: Headers | None = None, |
| 603 |
extra_query: Query | None = None, |
| 604 |
extra_body: Body | None = None, |
| 605 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 606 |
) -> BetaManagedAgentsDeployment: |
| 607 |
""" |
| 608 |
Unpause Deployment |
| 609 |
|
| 610 |
Args: |
| 611 |
deployment_id: Unique identifier of the deployment to unpause. |
| 612 |
|
| 613 |
betas: Optional header to specify the beta version(s) you want to use. |
| 614 |
|
| 615 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 616 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 617 |
|
| 618 |
Only needed for credentials that can act on more than one Workspace. A |
| 619 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 620 |
match that Workspace. |
| 621 |
|
| 622 |
extra_headers: Send extra headers |
| 623 |
|
| 624 |
extra_query: Add additional query parameters to the request |
| 625 |
|
| 626 |
extra_body: Add additional JSON properties to the request |
| 627 |
|
| 628 |
timeout: Override the client-level default timeout for this request, in seconds |
| 629 |
""" |
| 630 |
if not deployment_id: |
| 631 |
raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") |
| 632 |
extra_headers = { |
| 633 |
**strip_not_given( |
| 634 |
{ |
| 635 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 636 |
if is_given(betas) |
| 637 |
else not_given, |
| 638 |
"anthropic-workspace-id": workspace_id, |
| 639 |
} |
| 640 |
), |
| 641 |
**(extra_headers or {}), |
| 642 |
} |
| 643 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 644 |
return self._post( |
| 645 |
path_template("/v1/deployments/{deployment_id}/unpause?beta=true", deployment_id=deployment_id), |
| 646 |
options=make_request_options( |
| 647 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 648 |
), |
| 649 |
cast_to=BetaManagedAgentsDeployment, |
| 650 |
) |
| 651 |
|
| 652 |
|
| 653 |
class AsyncDeployments(AsyncAPIResource): |
| 654 |
@cached_property |
| 655 |
def with_raw_response(self) -> AsyncDeploymentsWithRawResponse: |
| 656 |
""" |
| 657 |
This property can be used as a prefix for any HTTP method call to return |
| 658 |
the raw response object instead of the parsed content. |
| 659 |
|
| 660 |
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers |
| 661 |
""" |
| 662 |
return AsyncDeploymentsWithRawResponse(self) |
| 663 |
|
| 664 |
@cached_property |
| 665 |
def with_streaming_response(self) -> AsyncDeploymentsWithStreamingResponse: |
| 666 |
""" |
| 667 |
An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 668 |
|
| 669 |
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response |
| 670 |
""" |
| 671 |
return AsyncDeploymentsWithStreamingResponse(self) |
| 672 |
|
| 673 |
async def create( |
| 674 |
self, |
| 675 |
*, |
| 676 |
agent: deployment_create_params.Agent, |
| 677 |
environment_id: str, |
| 678 |
initial_events: Iterable[BetaManagedAgentsDeploymentInitialEventParams], |
| 679 |
name: str, |
| 680 |
budget: Optional[BetaManagedAgentsBudgetLimitParam] | Omit = omit, |
| 681 |
description: Optional[str] | Omit = omit, |
| 682 |
metadata: Dict[str, str] | Omit = omit, |
| 683 |
resources: Iterable[deployment_create_params.Resource] | Omit = omit, |
| 684 |
schedule: Optional[BetaManagedAgentsScheduleParams] | Omit = omit, |
| 685 |
vault_ids: SequenceNotStr[str] | Omit = omit, |
| 686 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 687 |
workspace_id: str | Omit = omit, |
| 688 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 689 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 690 |
extra_headers: Headers | None = None, |
| 691 |
extra_query: Query | None = None, |
| 692 |
extra_body: Body | None = None, |
| 693 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 694 |
) -> BetaManagedAgentsDeployment: |
| 695 |
"""Create Deployment |
| 696 |
|
| 697 |
Args: |
| 698 |
agent: Agent to deploy. |
| 699 |
|
| 700 |
Accepts the `agent` ID string, which pins the latest version, |
| 701 |
or an `agent` object with both id and version specified. The agent must exist |
| 702 |
and not be archived. |
| 703 |
|
| 704 |
environment_id: ID of the `environment` defining the container configuration for sessions |
| 705 |
created from this deployment. |
| 706 |
|
| 707 |
initial_events: Events to send to each session immediately after creation. At least 1, |
| 708 |
maximum 50. |
| 709 |
|
| 710 |
name: Human-readable name for the deployment. |
| 711 |
|
| 712 |
budget: A hard spend ceiling. The session stops issuing new model requests once the |
| 713 |
tracked list cost reaches `max_list_cost`. |
| 714 |
|
| 715 |
description: Description of what the deployment does. |
| 716 |
|
| 717 |
metadata: Arbitrary key-value metadata. Maximum 16 pairs, keys up to 64 chars, values up |
| 718 |
to 512 chars. |
| 719 |
|
| 720 |
resources: Resources (e.g. repositories, files) to mount into each session's container. |
| 721 |
Maximum 500. |
| 722 |
|
| 723 |
schedule: 5-field POSIX cron schedule. Literal wall-clock matching in the configured |
| 724 |
timezone. |
| 725 |
|
| 726 |
vault_ids: Vault IDs for stored credentials the agent can use during sessions created from |
| 727 |
this deployment. Maximum 50. |
| 728 |
|
| 729 |
betas: Optional header to specify the beta version(s) you want to use. |
| 730 |
|
| 731 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 732 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 733 |
|
| 734 |
Only needed for credentials that can act on more than one Workspace. A |
| 735 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 736 |
match that Workspace. |
| 737 |
|
| 738 |
extra_headers: Send extra headers |
| 739 |
|
| 740 |
extra_query: Add additional query parameters to the request |
| 741 |
|
| 742 |
extra_body: Add additional JSON properties to the request |
| 743 |
|
| 744 |
timeout: Override the client-level default timeout for this request, in seconds |
| 745 |
""" |
| 746 |
extra_headers = { |
| 747 |
**strip_not_given( |
| 748 |
{ |
| 749 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 750 |
if is_given(betas) |
| 751 |
else not_given, |
| 752 |
"anthropic-workspace-id": workspace_id, |
| 753 |
} |
| 754 |
), |
| 755 |
**(extra_headers or {}), |
| 756 |
} |
| 757 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 758 |
return await self._post( |
| 759 |
"/v1/deployments?beta=true", |
| 760 |
body={ |
| 761 |
"agent": agent, |
| 762 |
"environment_id": environment_id, |
| 763 |
"initial_events": initial_events, |
| 764 |
"name": name, |
| 765 |
"budget": budget, |
| 766 |
"description": description, |
| 767 |
"metadata": metadata, |
| 768 |
"resources": resources, |
| 769 |
"schedule": schedule, |
| 770 |
"vault_ids": vault_ids, |
| 771 |
}, |
| 772 |
options=make_request_options( |
| 773 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 774 |
), |
| 775 |
cast_to=BetaManagedAgentsDeployment, |
| 776 |
) |
| 777 |
|
| 778 |
async def retrieve( |
| 779 |
self, |
| 780 |
deployment_id: str, |
| 781 |
*, |
| 782 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 783 |
workspace_id: str | Omit = omit, |
| 784 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 785 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 786 |
extra_headers: Headers | None = None, |
| 787 |
extra_query: Query | None = None, |
| 788 |
extra_body: Body | None = None, |
| 789 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 790 |
) -> BetaManagedAgentsDeployment: |
| 791 |
""" |
| 792 |
Get Deployment |
| 793 |
|
| 794 |
Args: |
| 795 |
deployment_id: Unique identifier of the deployment. |
| 796 |
|
| 797 |
betas: Optional header to specify the beta version(s) you want to use. |
| 798 |
|
| 799 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 800 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 801 |
|
| 802 |
Only needed for credentials that can act on more than one Workspace. A |
| 803 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 804 |
match that Workspace. |
| 805 |
|
| 806 |
extra_headers: Send extra headers |
| 807 |
|
| 808 |
extra_query: Add additional query parameters to the request |
| 809 |
|
| 810 |
extra_body: Add additional JSON properties to the request |
| 811 |
|
| 812 |
timeout: Override the client-level default timeout for this request, in seconds |
| 813 |
""" |
| 814 |
if not deployment_id: |
| 815 |
raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") |
| 816 |
extra_headers = { |
| 817 |
**strip_not_given( |
| 818 |
{ |
| 819 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 820 |
if is_given(betas) |
| 821 |
else not_given, |
| 822 |
"anthropic-workspace-id": workspace_id, |
| 823 |
} |
| 824 |
), |
| 825 |
**(extra_headers or {}), |
| 826 |
} |
| 827 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 828 |
return await self._get( |
| 829 |
path_template("/v1/deployments/{deployment_id}?beta=true", deployment_id=deployment_id), |
| 830 |
options=make_request_options( |
| 831 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 832 |
), |
| 833 |
cast_to=BetaManagedAgentsDeployment, |
| 834 |
) |
| 835 |
|
| 836 |
async def update( |
| 837 |
self, |
| 838 |
deployment_id: str, |
| 839 |
*, |
| 840 |
agent: deployment_update_params.Agent | Omit = omit, |
| 841 |
budget: Optional[BetaManagedAgentsBudgetLimitParam] | Omit = omit, |
| 842 |
description: Optional[str] | Omit = omit, |
| 843 |
environment_id: str | Omit = omit, |
| 844 |
initial_events: Iterable[BetaManagedAgentsDeploymentInitialEventParams] | Omit = omit, |
| 845 |
metadata: Optional[Dict[str, Optional[str]]] | Omit = omit, |
| 846 |
name: str | Omit = omit, |
| 847 |
resources: Optional[Iterable[deployment_update_params.Resource]] | Omit = omit, |
| 848 |
schedule: Optional[BetaManagedAgentsScheduleParams] | Omit = omit, |
| 849 |
vault_ids: Optional[SequenceNotStr[str]] | Omit = omit, |
| 850 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 851 |
workspace_id: str | Omit = omit, |
| 852 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 853 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 854 |
extra_headers: Headers | None = None, |
| 855 |
extra_query: Query | None = None, |
| 856 |
extra_body: Body | None = None, |
| 857 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 858 |
) -> BetaManagedAgentsDeployment: |
| 859 |
""" |
| 860 |
Update Deployment |
| 861 |
|
| 862 |
Args: |
| 863 |
deployment_id: Unique identifier of the deployment to update. |
| 864 |
|
| 865 |
agent: Agent to deploy. Accepts the `agent` ID string, which re-pins to the latest |
| 866 |
version, or an `agent` object with both id and version specified. Omit to |
| 867 |
preserve. Cannot be cleared. |
| 868 |
|
| 869 |
budget: A hard spend ceiling. The session stops issuing new model requests once the |
| 870 |
tracked list cost reaches `max_list_cost`. |
| 871 |
|
| 872 |
description: Description. Omit to preserve; send empty string or null to clear. |
| 873 |
|
| 874 |
environment_id: ID of the `environment` where sessions run. Omit to preserve. Cannot be cleared. |
| 875 |
|
| 876 |
initial_events: Initial events. Full replacement. Omit to preserve. Cannot be cleared. At least |
| 877 |
1, maximum 50. |
| 878 |
|
| 879 |
metadata: Metadata patch. Set a key to a string to upsert it, or to null to delete it. |
| 880 |
Omit the field to preserve. The stored bag is limited to 16 keys (up to 64 chars |
| 881 |
each) with values up to 512 chars. |
| 882 |
|
| 883 |
name: Human-readable name. Must be non-empty. Omit to preserve. Cannot be cleared. |
| 884 |
|
| 885 |
resources: Session resources. Full replacement. Omit to preserve; send empty array or null |
| 886 |
to clear. Maximum 500. |
| 887 |
|
| 888 |
schedule: 5-field POSIX cron schedule. Literal wall-clock matching in the configured |
| 889 |
timezone. |
| 890 |
|
| 891 |
vault_ids: Vault IDs. Full replacement. Omit to preserve; send empty array or null to |
| 892 |
clear. Maximum 50. |
| 893 |
|
| 894 |
betas: Optional header to specify the beta version(s) you want to use. |
| 895 |
|
| 896 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 897 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 898 |
|
| 899 |
Only needed for credentials that can act on more than one Workspace. A |
| 900 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 901 |
match that Workspace. |
| 902 |
|
| 903 |
extra_headers: Send extra headers |
| 904 |
|
| 905 |
extra_query: Add additional query parameters to the request |
| 906 |
|
| 907 |
extra_body: Add additional JSON properties to the request |
| 908 |
|
| 909 |
timeout: Override the client-level default timeout for this request, in seconds |
| 910 |
""" |
| 911 |
if not deployment_id: |
| 912 |
raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") |
| 913 |
extra_headers = { |
| 914 |
**strip_not_given( |
| 915 |
{ |
| 916 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 917 |
if is_given(betas) |
| 918 |
else not_given, |
| 919 |
"anthropic-workspace-id": workspace_id, |
| 920 |
} |
| 921 |
), |
| 922 |
**(extra_headers or {}), |
| 923 |
} |
| 924 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 925 |
return await self._post( |
| 926 |
path_template("/v1/deployments/{deployment_id}?beta=true", deployment_id=deployment_id), |
| 927 |
body={ |
| 928 |
"agent": agent, |
| 929 |
"budget": budget, |
| 930 |
"description": description, |
| 931 |
"environment_id": environment_id, |
| 932 |
"initial_events": initial_events, |
| 933 |
"metadata": metadata, |
| 934 |
"name": name, |
| 935 |
"resources": resources, |
| 936 |
"schedule": schedule, |
| 937 |
"vault_ids": vault_ids, |
| 938 |
}, |
| 939 |
options=make_request_options( |
| 940 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 941 |
), |
| 942 |
cast_to=BetaManagedAgentsDeployment, |
| 943 |
) |
| 944 |
|
| 945 |
def list( |
| 946 |
self, |
| 947 |
*, |
| 948 |
agent_id: str | Omit = omit, |
| 949 |
created_at_gte: Union[str, datetime] | Omit = omit, |
| 950 |
created_at_lte: Union[str, datetime] | Omit = omit, |
| 951 |
include_archived: bool | Omit = omit, |
| 952 |
limit: int | Omit = omit, |
| 953 |
page: str | Omit = omit, |
| 954 |
status: BetaManagedAgentsDeploymentStatus | Omit = omit, |
| 955 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 956 |
workspace_id: str | Omit = omit, |
| 957 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 958 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 959 |
extra_headers: Headers | None = None, |
| 960 |
extra_query: Query | None = None, |
| 961 |
extra_body: Body | None = None, |
| 962 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 963 |
) -> AsyncPaginator[BetaManagedAgentsDeployment, AsyncPageCursor[BetaManagedAgentsDeployment]]: |
| 964 |
""" |
| 965 |
List Deployments |
| 966 |
|
| 967 |
Args: |
| 968 |
agent_id: Filter by agent ID. |
| 969 |
|
| 970 |
created_at_gte: Return deployments created at or after this time (inclusive). |
| 971 |
|
| 972 |
created_at_lte: Return deployments created at or before this time (inclusive). |
| 973 |
|
| 974 |
include_archived: When true, includes archived deployments. Default: false (exclude archived). |
| 975 |
|
| 976 |
limit: Maximum results per page. Default 20, maximum 100. |
| 977 |
|
| 978 |
page: Opaque pagination cursor. |
| 979 |
|
| 980 |
status: Filter by status: `active` or `paused`. Omit for both. To include archived |
| 981 |
deployments, use `include_archived` instead; the two cannot be combined. |
| 982 |
|
| 983 |
betas: Optional header to specify the beta version(s) you want to use. |
| 984 |
|
| 985 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 986 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 987 |
|
| 988 |
Only needed for credentials that can act on more than one Workspace. A |
| 989 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 990 |
match that Workspace. |
| 991 |
|
| 992 |
extra_headers: Send extra headers |
| 993 |
|
| 994 |
extra_query: Add additional query parameters to the request |
| 995 |
|
| 996 |
extra_body: Add additional JSON properties to the request |
| 997 |
|
| 998 |
timeout: Override the client-level default timeout for this request, in seconds |
| 999 |
""" |
| 1000 |
extra_headers = { |
| 1001 |
**strip_not_given( |
| 1002 |
{ |
| 1003 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 1004 |
if is_given(betas) |
| 1005 |
else not_given, |
| 1006 |
"anthropic-workspace-id": workspace_id, |
| 1007 |
} |
| 1008 |
), |
| 1009 |
**(extra_headers or {}), |
| 1010 |
} |
| 1011 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 1012 |
return self._get_api_list( |
| 1013 |
"/v1/deployments?beta=true", |
| 1014 |
page=AsyncPageCursor[BetaManagedAgentsDeployment], |
| 1015 |
options=make_request_options( |
| 1016 |
extra_headers=extra_headers, |
| 1017 |
extra_query=extra_query, |
| 1018 |
extra_body=extra_body, |
| 1019 |
timeout=timeout, |
| 1020 |
query={ |
| 1021 |
"agent_id": agent_id, |
| 1022 |
"created_at[gte]": created_at_gte, |
| 1023 |
"created_at[lte]": created_at_lte, |
| 1024 |
"include_archived": include_archived, |
| 1025 |
"limit": limit, |
| 1026 |
"page": page, |
| 1027 |
"status": status, |
| 1028 |
}, |
| 1029 |
), |
| 1030 |
model=BetaManagedAgentsDeployment, |
| 1031 |
) |
| 1032 |
|
| 1033 |
async def archive( |
| 1034 |
self, |
| 1035 |
deployment_id: str, |
| 1036 |
*, |
| 1037 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 1038 |
workspace_id: str | Omit = omit, |
| 1039 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 1040 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 1041 |
extra_headers: Headers | None = None, |
| 1042 |
extra_query: Query | None = None, |
| 1043 |
extra_body: Body | None = None, |
| 1044 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 1045 |
) -> BetaManagedAgentsDeployment: |
| 1046 |
""" |
| 1047 |
Archive Deployment |
| 1048 |
|
| 1049 |
Args: |
| 1050 |
deployment_id: Unique identifier of the deployment to archive. |
| 1051 |
|
| 1052 |
betas: Optional header to specify the beta version(s) you want to use. |
| 1053 |
|
| 1054 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 1055 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 1056 |
|
| 1057 |
Only needed for credentials that can act on more than one Workspace. A |
| 1058 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 1059 |
match that Workspace. |
| 1060 |
|
| 1061 |
extra_headers: Send extra headers |
| 1062 |
|
| 1063 |
extra_query: Add additional query parameters to the request |
| 1064 |
|
| 1065 |
extra_body: Add additional JSON properties to the request |
| 1066 |
|
| 1067 |
timeout: Override the client-level default timeout for this request, in seconds |
| 1068 |
""" |
| 1069 |
if not deployment_id: |
| 1070 |
raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") |
| 1071 |
extra_headers = { |
| 1072 |
**strip_not_given( |
| 1073 |
{ |
| 1074 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 1075 |
if is_given(betas) |
| 1076 |
else not_given, |
| 1077 |
"anthropic-workspace-id": workspace_id, |
| 1078 |
} |
| 1079 |
), |
| 1080 |
**(extra_headers or {}), |
| 1081 |
} |
| 1082 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 1083 |
return await self._post( |
| 1084 |
path_template("/v1/deployments/{deployment_id}/archive?beta=true", deployment_id=deployment_id), |
| 1085 |
options=make_request_options( |
| 1086 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 1087 |
), |
| 1088 |
cast_to=BetaManagedAgentsDeployment, |
| 1089 |
) |
| 1090 |
|
| 1091 |
async def pause( |
| 1092 |
self, |
| 1093 |
deployment_id: str, |
| 1094 |
*, |
| 1095 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 1096 |
workspace_id: str | Omit = omit, |
| 1097 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 1098 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 1099 |
extra_headers: Headers | None = None, |
| 1100 |
extra_query: Query | None = None, |
| 1101 |
extra_body: Body | None = None, |
| 1102 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 1103 |
) -> BetaManagedAgentsDeployment: |
| 1104 |
""" |
| 1105 |
Pause Deployment |
| 1106 |
|
| 1107 |
Args: |
| 1108 |
deployment_id: Unique identifier of the deployment to pause. |
| 1109 |
|
| 1110 |
betas: Optional header to specify the beta version(s) you want to use. |
| 1111 |
|
| 1112 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 1113 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 1114 |
|
| 1115 |
Only needed for credentials that can act on more than one Workspace. A |
| 1116 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 1117 |
match that Workspace. |
| 1118 |
|
| 1119 |
extra_headers: Send extra headers |
| 1120 |
|
| 1121 |
extra_query: Add additional query parameters to the request |
| 1122 |
|
| 1123 |
extra_body: Add additional JSON properties to the request |
| 1124 |
|
| 1125 |
timeout: Override the client-level default timeout for this request, in seconds |
| 1126 |
""" |
| 1127 |
if not deployment_id: |
| 1128 |
raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") |
| 1129 |
extra_headers = { |
| 1130 |
**strip_not_given( |
| 1131 |
{ |
| 1132 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 1133 |
if is_given(betas) |
| 1134 |
else not_given, |
| 1135 |
"anthropic-workspace-id": workspace_id, |
| 1136 |
} |
| 1137 |
), |
| 1138 |
**(extra_headers or {}), |
| 1139 |
} |
| 1140 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 1141 |
return await self._post( |
| 1142 |
path_template("/v1/deployments/{deployment_id}/pause?beta=true", deployment_id=deployment_id), |
| 1143 |
options=make_request_options( |
| 1144 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 1145 |
), |
| 1146 |
cast_to=BetaManagedAgentsDeployment, |
| 1147 |
) |
| 1148 |
|
| 1149 |
async def run( |
| 1150 |
self, |
| 1151 |
deployment_id: str, |
| 1152 |
*, |
| 1153 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 1154 |
workspace_id: str | Omit = omit, |
| 1155 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 1156 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 1157 |
extra_headers: Headers | None = None, |
| 1158 |
extra_query: Query | None = None, |
| 1159 |
extra_body: Body | None = None, |
| 1160 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 1161 |
) -> BetaManagedAgentsDeploymentRun: |
| 1162 |
""" |
| 1163 |
Run Deployment Now |
| 1164 |
|
| 1165 |
Args: |
| 1166 |
deployment_id: Unique identifier of the deployment to run. |
| 1167 |
|
| 1168 |
betas: Optional header to specify the beta version(s) you want to use. |
| 1169 |
|
| 1170 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 1171 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 1172 |
|
| 1173 |
Only needed for credentials that can act on more than one Workspace. A |
| 1174 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 1175 |
match that Workspace. |
| 1176 |
|
| 1177 |
extra_headers: Send extra headers |
| 1178 |
|
| 1179 |
extra_query: Add additional query parameters to the request |
| 1180 |
|
| 1181 |
extra_body: Add additional JSON properties to the request |
| 1182 |
|
| 1183 |
timeout: Override the client-level default timeout for this request, in seconds |
| 1184 |
""" |
| 1185 |
if not deployment_id: |
| 1186 |
raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") |
| 1187 |
extra_headers = { |
| 1188 |
**strip_not_given( |
| 1189 |
{ |
| 1190 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 1191 |
if is_given(betas) |
| 1192 |
else not_given, |
| 1193 |
"anthropic-workspace-id": workspace_id, |
| 1194 |
} |
| 1195 |
), |
| 1196 |
**(extra_headers or {}), |
| 1197 |
} |
| 1198 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 1199 |
return await self._post( |
| 1200 |
path_template("/v1/deployments/{deployment_id}/run?beta=true", deployment_id=deployment_id), |
| 1201 |
options=make_request_options( |
| 1202 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 1203 |
), |
| 1204 |
cast_to=BetaManagedAgentsDeploymentRun, |
| 1205 |
) |
| 1206 |
|
| 1207 |
async def unpause( |
| 1208 |
self, |
| 1209 |
deployment_id: str, |
| 1210 |
*, |
| 1211 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 1212 |
workspace_id: str | Omit = omit, |
| 1213 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 1214 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 1215 |
extra_headers: Headers | None = None, |
| 1216 |
extra_query: Query | None = None, |
| 1217 |
extra_body: Body | None = None, |
| 1218 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 1219 |
) -> BetaManagedAgentsDeployment: |
| 1220 |
""" |
| 1221 |
Unpause Deployment |
| 1222 |
|
| 1223 |
Args: |
| 1224 |
deployment_id: Unique identifier of the deployment to unpause. |
| 1225 |
|
| 1226 |
betas: Optional header to specify the beta version(s) you want to use. |
| 1227 |
|
| 1228 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 1229 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 1230 |
|
| 1231 |
Only needed for credentials that can act on more than one Workspace. A |
| 1232 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 1233 |
match that Workspace. |
| 1234 |
|
| 1235 |
extra_headers: Send extra headers |
| 1236 |
|
| 1237 |
extra_query: Add additional query parameters to the request |
| 1238 |
|
| 1239 |
extra_body: Add additional JSON properties to the request |
| 1240 |
|
| 1241 |
timeout: Override the client-level default timeout for this request, in seconds |
| 1242 |
""" |
| 1243 |
if not deployment_id: |
| 1244 |
raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") |
| 1245 |
extra_headers = { |
| 1246 |
**strip_not_given( |
| 1247 |
{ |
| 1248 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 1249 |
if is_given(betas) |
| 1250 |
else not_given, |
| 1251 |
"anthropic-workspace-id": workspace_id, |
| 1252 |
} |
| 1253 |
), |
| 1254 |
**(extra_headers or {}), |
| 1255 |
} |
| 1256 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 1257 |
return await self._post( |
| 1258 |
path_template("/v1/deployments/{deployment_id}/unpause?beta=true", deployment_id=deployment_id), |
| 1259 |
options=make_request_options( |
| 1260 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 1261 |
), |
| 1262 |
cast_to=BetaManagedAgentsDeployment, |
| 1263 |
) |
| 1264 |
|
| 1265 |
|
| 1266 |
class DeploymentsWithRawResponse: |
| 1267 |
def __init__(self, deployments: Deployments) -> None: |
| 1268 |
self._deployments = deployments |
| 1269 |
|
| 1270 |
self.create = to_raw_response_wrapper( |
| 1271 |
deployments.create, |
| 1272 |
) |
| 1273 |
self.retrieve = to_raw_response_wrapper( |
| 1274 |
deployments.retrieve, |
| 1275 |
) |
| 1276 |
self.update = to_raw_response_wrapper( |
| 1277 |
deployments.update, |
| 1278 |
) |
| 1279 |
self.list = to_raw_response_wrapper( |
| 1280 |
deployments.list, |
| 1281 |
) |
| 1282 |
self.archive = to_raw_response_wrapper( |
| 1283 |
deployments.archive, |
| 1284 |
) |
| 1285 |
self.pause = to_raw_response_wrapper( |
| 1286 |
deployments.pause, |
| 1287 |
) |
| 1288 |
self.run = to_raw_response_wrapper( |
| 1289 |
deployments.run, |
| 1290 |
) |
| 1291 |
self.unpause = to_raw_response_wrapper( |
| 1292 |
deployments.unpause, |
| 1293 |
) |
| 1294 |
|
| 1295 |
|
| 1296 |
class AsyncDeploymentsWithRawResponse: |
| 1297 |
def __init__(self, deployments: AsyncDeployments) -> None: |
| 1298 |
self._deployments = deployments |
| 1299 |
|
| 1300 |
self.create = async_to_raw_response_wrapper( |
| 1301 |
deployments.create, |
| 1302 |
) |
| 1303 |
self.retrieve = async_to_raw_response_wrapper( |
| 1304 |
deployments.retrieve, |
| 1305 |
) |
| 1306 |
self.update = async_to_raw_response_wrapper( |
| 1307 |
deployments.update, |
| 1308 |
) |
| 1309 |
self.list = async_to_raw_response_wrapper( |
| 1310 |
deployments.list, |
| 1311 |
) |
| 1312 |
self.archive = async_to_raw_response_wrapper( |
| 1313 |
deployments.archive, |
| 1314 |
) |
| 1315 |
self.pause = async_to_raw_response_wrapper( |
| 1316 |
deployments.pause, |
| 1317 |
) |
| 1318 |
self.run = async_to_raw_response_wrapper( |
| 1319 |
deployments.run, |
| 1320 |
) |
| 1321 |
self.unpause = async_to_raw_response_wrapper( |
| 1322 |
deployments.unpause, |
| 1323 |
) |
| 1324 |
|
| 1325 |
|
| 1326 |
class DeploymentsWithStreamingResponse: |
| 1327 |
def __init__(self, deployments: Deployments) -> None: |
| 1328 |
self._deployments = deployments |
| 1329 |
|
| 1330 |
self.create = to_streamed_response_wrapper( |
| 1331 |
deployments.create, |
| 1332 |
) |
| 1333 |
self.retrieve = to_streamed_response_wrapper( |
| 1334 |
deployments.retrieve, |
| 1335 |
) |
| 1336 |
self.update = to_streamed_response_wrapper( |
| 1337 |
deployments.update, |
| 1338 |
) |
| 1339 |
self.list = to_streamed_response_wrapper( |
| 1340 |
deployments.list, |
| 1341 |
) |
| 1342 |
self.archive = to_streamed_response_wrapper( |
| 1343 |
deployments.archive, |
| 1344 |
) |
| 1345 |
self.pause = to_streamed_response_wrapper( |
| 1346 |
deployments.pause, |
| 1347 |
) |
| 1348 |
self.run = to_streamed_response_wrapper( |
| 1349 |
deployments.run, |
| 1350 |
) |
| 1351 |
self.unpause = to_streamed_response_wrapper( |
| 1352 |
deployments.unpause, |
| 1353 |
) |
| 1354 |
|
| 1355 |
|
| 1356 |
class AsyncDeploymentsWithStreamingResponse: |
| 1357 |
def __init__(self, deployments: AsyncDeployments) -> None: |
| 1358 |
self._deployments = deployments |
| 1359 |
|
| 1360 |
self.create = async_to_streamed_response_wrapper( |
| 1361 |
deployments.create, |
| 1362 |
) |
| 1363 |
self.retrieve = async_to_streamed_response_wrapper( |
| 1364 |
deployments.retrieve, |
| 1365 |
) |
| 1366 |
self.update = async_to_streamed_response_wrapper( |
| 1367 |
deployments.update, |
| 1368 |
) |
| 1369 |
self.list = async_to_streamed_response_wrapper( |
| 1370 |
deployments.list, |
| 1371 |
) |
| 1372 |
self.archive = async_to_streamed_response_wrapper( |
| 1373 |
deployments.archive, |
| 1374 |
) |
| 1375 |
self.pause = async_to_streamed_response_wrapper( |
| 1376 |
deployments.pause, |
| 1377 |
) |
| 1378 |
self.run = async_to_streamed_response_wrapper( |
| 1379 |
deployments.run, |
| 1380 |
) |
| 1381 |
self.unpause = async_to_streamed_response_wrapper( |
| 1382 |
deployments.unpause, |
| 1383 |
) |