Debian Codegraph @

src/anthropic/resources/beta/vaults/credentials.py

raw
1 from __future__ import annotations
2
3 from typing import Dict, List, Optional
4 from itertools import chain
5
6 import httpx2
7
8 from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
9 from ...._utils import is_given, path_template, strip_not_given
10 from ...._compat import cached_property
11 from ...._resource import SyncAPIResource, AsyncAPIResource
12 from ...._response import (
13 to_raw_response_wrapper,
14 to_streamed_response_wrapper,
15 async_to_raw_response_wrapper,
16 async_to_streamed_response_wrapper,
17 )
18 from ....pagination import SyncPageCursor, AsyncPageCursor
19 from ...._base_client import AsyncPaginator, make_request_options
20 from ....types.beta.vaults import credential_create_params, credential_update_params
21 from ....types.anthropic_beta_param import AnthropicBetaParam
22 from ....types.beta.vaults.beta_managed_agents_credential import BetaManagedAgentsCredential
23 from ....types.beta.vaults.beta_managed_agents_deleted_credential import BetaManagedAgentsDeletedCredential
24 from ....types.beta.vaults.beta_managed_agents_credential_validation import BetaManagedAgentsCredentialValidation
25
26 __all__ = ["Credentials", "AsyncCredentials"]
27
28
29 class Credentials(SyncAPIResource):
30 @cached_property
31 def with_raw_response(self) -> CredentialsWithRawResponse:
32 """
33 This property can be used as a prefix for any HTTP method call to return
34 the raw response object instead of the parsed content.
35
36 For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers
37 """
38 return CredentialsWithRawResponse(self)
39
40 @cached_property
41 def with_streaming_response(self) -> CredentialsWithStreamingResponse:
42 """
43 An alternative to `.with_raw_response` that doesn't eagerly read the response body.
44
45 For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response
46 """
47 return CredentialsWithStreamingResponse(self)
48
49 def create(
50 self,
51 vault_id: str,
52 *,
53 auth: credential_create_params.Auth,
54 display_name: Optional[str] | Omit = omit,
55 metadata: Dict[str, str] | Omit = omit,
56 betas: List[AnthropicBetaParam] | Omit = omit,
57 workspace_id: str | Omit = omit,
58 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
59 # The extra values given here take precedence over values defined on the client or passed to this method.
60 extra_headers: Headers | None = None,
61 extra_query: Query | None = None,
62 extra_body: Body | None = None,
63 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
64 ) -> BetaManagedAgentsCredential:
65 """
66 Create Credential
67
68 Args:
69 vault_id: Identifier of the vault to create the credential in.
70
71 auth: Authentication configuration for the credential.
72
73 display_name: Human-readable name for the credential. Up to 255 characters.
74
75 metadata: Arbitrary key-value metadata to attach to the credential. Maximum 16 pairs, keys
76 up to 64 chars, values up to 512 chars.
77
78 betas: Optional header to specify the beta version(s) you want to use.
79
80 workspace_id: Optional header to select the Workspace for this request. The value is a
81 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
82
83 Only needed for credentials that can act on more than one Workspace. A
84 credential that belongs to a specific Workspace may omit it; if sent, it must
85 match that Workspace.
86
87 extra_headers: Send extra headers
88
89 extra_query: Add additional query parameters to the request
90
91 extra_body: Add additional JSON properties to the request
92
93 timeout: Override the client-level default timeout for this request, in seconds
94 """
95 if not vault_id:
96 raise ValueError(f"Expected a non-empty value for `vault_id` but received {vault_id!r}")
97 extra_headers = {
98 **strip_not_given(
99 {
100 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"]))
101 if is_given(betas)
102 else not_given,
103 "anthropic-workspace-id": workspace_id,
104 }
105 ),
106 **(extra_headers or {}),
107 }
108 extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})}
109 return self._post(
110 path_template("/v1/vaults/{vault_id}/credentials?beta=true", vault_id=vault_id),
111 body={
112 "auth": auth,
113 "display_name": display_name,
114 "metadata": metadata,
115 },
116 options=make_request_options(
117 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
118 ),
119 cast_to=BetaManagedAgentsCredential,
120 )
121
122 def retrieve(
123 self,
124 credential_id: str,
125 *,
126 vault_id: str,
127 betas: List[AnthropicBetaParam] | Omit = omit,
128 workspace_id: str | Omit = omit,
129 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
130 # The extra values given here take precedence over values defined on the client or passed to this method.
131 extra_headers: Headers | None = None,
132 extra_query: Query | None = None,
133 extra_body: Body | None = None,
134 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
135 ) -> BetaManagedAgentsCredential:
136 """
137 Get Credential
138
139 Args:
140 vault_id: Identifier of the vault containing the credential.
141
142 credential_id: Unique identifier of the credential to retrieve.
143
144 betas: Optional header to specify the beta version(s) you want to use.
145
146 workspace_id: Optional header to select the Workspace for this request. The value is a
147 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
148
149 Only needed for credentials that can act on more than one Workspace. A
150 credential that belongs to a specific Workspace may omit it; if sent, it must
151 match that Workspace.
152
153 extra_headers: Send extra headers
154
155 extra_query: Add additional query parameters to the request
156
157 extra_body: Add additional JSON properties to the request
158
159 timeout: Override the client-level default timeout for this request, in seconds
160 """
161 if not vault_id:
162 raise ValueError(f"Expected a non-empty value for `vault_id` but received {vault_id!r}")
163 if not credential_id:
164 raise ValueError(f"Expected a non-empty value for `credential_id` but received {credential_id!r}")
165 extra_headers = {
166 **strip_not_given(
167 {
168 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"]))
169 if is_given(betas)
170 else not_given,
171 "anthropic-workspace-id": workspace_id,
172 }
173 ),
174 **(extra_headers or {}),
175 }
176 extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})}
177 return self._get(
178 path_template(
179 "/v1/vaults/{vault_id}/credentials/{credential_id}?beta=true",
180 vault_id=vault_id,
181 credential_id=credential_id,
182 ),
183 options=make_request_options(
184 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
185 ),
186 cast_to=BetaManagedAgentsCredential,
187 )
188
189 def update(
190 self,
191 credential_id: str,
192 *,
193 vault_id: str,
194 auth: credential_update_params.Auth | Omit = omit,
195 display_name: Optional[str] | Omit = omit,
196 metadata: Optional[Dict[str, Optional[str]]] | Omit = omit,
197 betas: List[AnthropicBetaParam] | Omit = omit,
198 workspace_id: str | Omit = omit,
199 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
200 # The extra values given here take precedence over values defined on the client or passed to this method.
201 extra_headers: Headers | None = None,
202 extra_query: Query | None = None,
203 extra_body: Body | None = None,
204 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
205 ) -> BetaManagedAgentsCredential:
206 """
207 Update Credential
208
209 Args:
210 vault_id: Identifier of the vault containing the credential.
211
212 credential_id: Unique identifier of the credential to update.
213
214 auth: Updated authentication configuration. The `type` is immutable; the variant sent
215 must match the stored credential's type.
216
217 display_name: Updated human-readable name for the credential. 1-255 characters.
218
219 metadata: Metadata patch. Set a key to a string to upsert it, or to null to delete it.
220 Omitted keys are preserved.
221
222 betas: Optional header to specify the beta version(s) you want to use.
223
224 workspace_id: Optional header to select the Workspace for this request. The value is a
225 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
226
227 Only needed for credentials that can act on more than one Workspace. A
228 credential that belongs to a specific Workspace may omit it; if sent, it must
229 match that Workspace.
230
231 extra_headers: Send extra headers
232
233 extra_query: Add additional query parameters to the request
234
235 extra_body: Add additional JSON properties to the request
236
237 timeout: Override the client-level default timeout for this request, in seconds
238 """
239 if not vault_id:
240 raise ValueError(f"Expected a non-empty value for `vault_id` but received {vault_id!r}")
241 if not credential_id:
242 raise ValueError(f"Expected a non-empty value for `credential_id` but received {credential_id!r}")
243 extra_headers = {
244 **strip_not_given(
245 {
246 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"]))
247 if is_given(betas)
248 else not_given,
249 "anthropic-workspace-id": workspace_id,
250 }
251 ),
252 **(extra_headers or {}),
253 }
254 extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})}
255 return self._post(
256 path_template(
257 "/v1/vaults/{vault_id}/credentials/{credential_id}?beta=true",
258 vault_id=vault_id,
259 credential_id=credential_id,
260 ),
261 body={
262 "auth": auth,
263 "display_name": display_name,
264 "metadata": metadata,
265 },
266 options=make_request_options(
267 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
268 ),
269 cast_to=BetaManagedAgentsCredential,
270 )
271
272 def list(
273 self,
274 vault_id: str,
275 *,
276 include_archived: bool | Omit = omit,
277 limit: int | Omit = omit,
278 page: str | Omit = omit,
279 betas: List[AnthropicBetaParam] | Omit = omit,
280 workspace_id: str | Omit = omit,
281 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
282 # The extra values given here take precedence over values defined on the client or passed to this method.
283 extra_headers: Headers | None = None,
284 extra_query: Query | None = None,
285 extra_body: Body | None = None,
286 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
287 ) -> SyncPageCursor[BetaManagedAgentsCredential]:
288 """
289 List Credentials
290
291 Args:
292 vault_id: Identifier of the vault to list credentials for.
293
294 include_archived: Whether to include archived credentials in the results.
295
296 limit: Maximum number of credentials to return per page. Defaults to 20, maximum 100.
297
298 page: Opaque pagination token from a previous `list_credentials` response.
299
300 betas: Optional header to specify the beta version(s) you want to use.
301
302 workspace_id: Optional header to select the Workspace for this request. The value is a
303 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
304
305 Only needed for credentials that can act on more than one Workspace. A
306 credential that belongs to a specific Workspace may omit it; if sent, it must
307 match that Workspace.
308
309 extra_headers: Send extra headers
310
311 extra_query: Add additional query parameters to the request
312
313 extra_body: Add additional JSON properties to the request
314
315 timeout: Override the client-level default timeout for this request, in seconds
316 """
317 if not vault_id:
318 raise ValueError(f"Expected a non-empty value for `vault_id` but received {vault_id!r}")
319 extra_headers = {
320 **strip_not_given(
321 {
322 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"]))
323 if is_given(betas)
324 else not_given,
325 "anthropic-workspace-id": workspace_id,
326 }
327 ),
328 **(extra_headers or {}),
329 }
330 extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})}
331 return self._get_api_list(
332 path_template("/v1/vaults/{vault_id}/credentials?beta=true", vault_id=vault_id),
333 page=SyncPageCursor[BetaManagedAgentsCredential],
334 options=make_request_options(
335 extra_headers=extra_headers,
336 extra_query=extra_query,
337 extra_body=extra_body,
338 timeout=timeout,
339 query={
340 "include_archived": include_archived,
341 "limit": limit,
342 "page": page,
343 },
344 ),
345 model=BetaManagedAgentsCredential,
346 )
347
348 def delete(
349 self,
350 credential_id: str,
351 *,
352 vault_id: str,
353 betas: List[AnthropicBetaParam] | Omit = omit,
354 workspace_id: str | Omit = omit,
355 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
356 # The extra values given here take precedence over values defined on the client or passed to this method.
357 extra_headers: Headers | None = None,
358 extra_query: Query | None = None,
359 extra_body: Body | None = None,
360 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
361 ) -> BetaManagedAgentsDeletedCredential:
362 """
363 Delete Credential
364
365 Args:
366 vault_id: Identifier of the vault containing the credential.
367
368 credential_id: Unique identifier of the credential to delete.
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 if not vault_id:
388 raise ValueError(f"Expected a non-empty value for `vault_id` but received {vault_id!r}")
389 if not credential_id:
390 raise ValueError(f"Expected a non-empty value for `credential_id` but received {credential_id!r}")
391 extra_headers = {
392 **strip_not_given(
393 {
394 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"]))
395 if is_given(betas)
396 else not_given,
397 "anthropic-workspace-id": workspace_id,
398 }
399 ),
400 **(extra_headers or {}),
401 }
402 extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})}
403 return self._delete(
404 path_template(
405 "/v1/vaults/{vault_id}/credentials/{credential_id}?beta=true",
406 vault_id=vault_id,
407 credential_id=credential_id,
408 ),
409 options=make_request_options(
410 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
411 ),
412 cast_to=BetaManagedAgentsDeletedCredential,
413 )
414
415 def archive(
416 self,
417 credential_id: str,
418 *,
419 vault_id: str,
420 betas: List[AnthropicBetaParam] | Omit = omit,
421 workspace_id: str | Omit = omit,
422 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
423 # The extra values given here take precedence over values defined on the client or passed to this method.
424 extra_headers: Headers | None = None,
425 extra_query: Query | None = None,
426 extra_body: Body | None = None,
427 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
428 ) -> BetaManagedAgentsCredential:
429 """
430 Archive Credential
431
432 Args:
433 vault_id: Identifier of the vault containing the credential.
434
435 credential_id: Unique identifier of the credential to archive.
436
437 betas: Optional header to specify the beta version(s) you want to use.
438
439 workspace_id: Optional header to select the Workspace for this request. The value is a
440 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
441
442 Only needed for credentials that can act on more than one Workspace. A
443 credential that belongs to a specific Workspace may omit it; if sent, it must
444 match that Workspace.
445
446 extra_headers: Send extra headers
447
448 extra_query: Add additional query parameters to the request
449
450 extra_body: Add additional JSON properties to the request
451
452 timeout: Override the client-level default timeout for this request, in seconds
453 """
454 if not vault_id:
455 raise ValueError(f"Expected a non-empty value for `vault_id` but received {vault_id!r}")
456 if not credential_id:
457 raise ValueError(f"Expected a non-empty value for `credential_id` but received {credential_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(
472 "/v1/vaults/{vault_id}/credentials/{credential_id}/archive?beta=true",
473 vault_id=vault_id,
474 credential_id=credential_id,
475 ),
476 options=make_request_options(
477 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
478 ),
479 cast_to=BetaManagedAgentsCredential,
480 )
481
482 def mcp_oauth_validate(
483 self,
484 credential_id: str,
485 *,
486 vault_id: str,
487 betas: List[AnthropicBetaParam] | Omit = omit,
488 workspace_id: str | Omit = omit,
489 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
490 # The extra values given here take precedence over values defined on the client or passed to this method.
491 extra_headers: Headers | None = None,
492 extra_query: Query | None = None,
493 extra_body: Body | None = None,
494 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
495 ) -> BetaManagedAgentsCredentialValidation:
496 """
497 Validate Credential
498
499 Args:
500 vault_id: Identifier of the vault containing the credential.
501
502 credential_id: Unique identifier of the credential to validate.
503
504 betas: Optional header to specify the beta version(s) you want to use.
505
506 workspace_id: Optional header to select the Workspace for this request. The value is a
507 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
508
509 Only needed for credentials that can act on more than one Workspace. A
510 credential that belongs to a specific Workspace may omit it; if sent, it must
511 match that Workspace.
512
513 extra_headers: Send extra headers
514
515 extra_query: Add additional query parameters to the request
516
517 extra_body: Add additional JSON properties to the request
518
519 timeout: Override the client-level default timeout for this request, in seconds
520 """
521 if not vault_id:
522 raise ValueError(f"Expected a non-empty value for `vault_id` but received {vault_id!r}")
523 if not credential_id:
524 raise ValueError(f"Expected a non-empty value for `credential_id` but received {credential_id!r}")
525 extra_headers = {
526 **strip_not_given(
527 {
528 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"]))
529 if is_given(betas)
530 else not_given,
531 "anthropic-workspace-id": workspace_id,
532 }
533 ),
534 **(extra_headers or {}),
535 }
536 extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})}
537 return self._post(
538 path_template(
539 "/v1/vaults/{vault_id}/credentials/{credential_id}/mcp_oauth_validate?beta=true",
540 vault_id=vault_id,
541 credential_id=credential_id,
542 ),
543 options=make_request_options(
544 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
545 ),
546 cast_to=BetaManagedAgentsCredentialValidation,
547 )
548
549
550 class AsyncCredentials(AsyncAPIResource):
551 @cached_property
552 def with_raw_response(self) -> AsyncCredentialsWithRawResponse:
553 """
554 This property can be used as a prefix for any HTTP method call to return
555 the raw response object instead of the parsed content.
556
557 For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers
558 """
559 return AsyncCredentialsWithRawResponse(self)
560
561 @cached_property
562 def with_streaming_response(self) -> AsyncCredentialsWithStreamingResponse:
563 """
564 An alternative to `.with_raw_response` that doesn't eagerly read the response body.
565
566 For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response
567 """
568 return AsyncCredentialsWithStreamingResponse(self)
569
570 async def create(
571 self,
572 vault_id: str,
573 *,
574 auth: credential_create_params.Auth,
575 display_name: Optional[str] | Omit = omit,
576 metadata: Dict[str, str] | Omit = omit,
577 betas: List[AnthropicBetaParam] | Omit = omit,
578 workspace_id: str | Omit = omit,
579 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
580 # The extra values given here take precedence over values defined on the client or passed to this method.
581 extra_headers: Headers | None = None,
582 extra_query: Query | None = None,
583 extra_body: Body | None = None,
584 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
585 ) -> BetaManagedAgentsCredential:
586 """
587 Create Credential
588
589 Args:
590 vault_id: Identifier of the vault to create the credential in.
591
592 auth: Authentication configuration for the credential.
593
594 display_name: Human-readable name for the credential. Up to 255 characters.
595
596 metadata: Arbitrary key-value metadata to attach to the credential. Maximum 16 pairs, keys
597 up to 64 chars, values up to 512 chars.
598
599 betas: Optional header to specify the beta version(s) you want to use.
600
601 workspace_id: Optional header to select the Workspace for this request. The value is a
602 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
603
604 Only needed for credentials that can act on more than one Workspace. A
605 credential that belongs to a specific Workspace may omit it; if sent, it must
606 match that Workspace.
607
608 extra_headers: Send extra headers
609
610 extra_query: Add additional query parameters to the request
611
612 extra_body: Add additional JSON properties to the request
613
614 timeout: Override the client-level default timeout for this request, in seconds
615 """
616 if not vault_id:
617 raise ValueError(f"Expected a non-empty value for `vault_id` but received {vault_id!r}")
618 extra_headers = {
619 **strip_not_given(
620 {
621 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"]))
622 if is_given(betas)
623 else not_given,
624 "anthropic-workspace-id": workspace_id,
625 }
626 ),
627 **(extra_headers or {}),
628 }
629 extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})}
630 return await self._post(
631 path_template("/v1/vaults/{vault_id}/credentials?beta=true", vault_id=vault_id),
632 body={
633 "auth": auth,
634 "display_name": display_name,
635 "metadata": metadata,
636 },
637 options=make_request_options(
638 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
639 ),
640 cast_to=BetaManagedAgentsCredential,
641 )
642
643 async def retrieve(
644 self,
645 credential_id: str,
646 *,
647 vault_id: str,
648 betas: List[AnthropicBetaParam] | Omit = omit,
649 workspace_id: str | Omit = omit,
650 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
651 # The extra values given here take precedence over values defined on the client or passed to this method.
652 extra_headers: Headers | None = None,
653 extra_query: Query | None = None,
654 extra_body: Body | None = None,
655 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
656 ) -> BetaManagedAgentsCredential:
657 """
658 Get Credential
659
660 Args:
661 vault_id: Identifier of the vault containing the credential.
662
663 credential_id: Unique identifier of the credential to retrieve.
664
665 betas: Optional header to specify the beta version(s) you want to use.
666
667 workspace_id: Optional header to select the Workspace for this request. The value is a
668 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
669
670 Only needed for credentials that can act on more than one Workspace. A
671 credential that belongs to a specific Workspace may omit it; if sent, it must
672 match that Workspace.
673
674 extra_headers: Send extra headers
675
676 extra_query: Add additional query parameters to the request
677
678 extra_body: Add additional JSON properties to the request
679
680 timeout: Override the client-level default timeout for this request, in seconds
681 """
682 if not vault_id:
683 raise ValueError(f"Expected a non-empty value for `vault_id` but received {vault_id!r}")
684 if not credential_id:
685 raise ValueError(f"Expected a non-empty value for `credential_id` but received {credential_id!r}")
686 extra_headers = {
687 **strip_not_given(
688 {
689 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"]))
690 if is_given(betas)
691 else not_given,
692 "anthropic-workspace-id": workspace_id,
693 }
694 ),
695 **(extra_headers or {}),
696 }
697 extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})}
698 return await self._get(
699 path_template(
700 "/v1/vaults/{vault_id}/credentials/{credential_id}?beta=true",
701 vault_id=vault_id,
702 credential_id=credential_id,
703 ),
704 options=make_request_options(
705 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
706 ),
707 cast_to=BetaManagedAgentsCredential,
708 )
709
710 async def update(
711 self,
712 credential_id: str,
713 *,
714 vault_id: str,
715 auth: credential_update_params.Auth | Omit = omit,
716 display_name: Optional[str] | Omit = omit,
717 metadata: Optional[Dict[str, Optional[str]]] | Omit = omit,
718 betas: List[AnthropicBetaParam] | Omit = omit,
719 workspace_id: str | Omit = omit,
720 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
721 # The extra values given here take precedence over values defined on the client or passed to this method.
722 extra_headers: Headers | None = None,
723 extra_query: Query | None = None,
724 extra_body: Body | None = None,
725 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
726 ) -> BetaManagedAgentsCredential:
727 """
728 Update Credential
729
730 Args:
731 vault_id: Identifier of the vault containing the credential.
732
733 credential_id: Unique identifier of the credential to update.
734
735 auth: Updated authentication configuration. The `type` is immutable; the variant sent
736 must match the stored credential's type.
737
738 display_name: Updated human-readable name for the credential. 1-255 characters.
739
740 metadata: Metadata patch. Set a key to a string to upsert it, or to null to delete it.
741 Omitted keys are preserved.
742
743 betas: Optional header to specify the beta version(s) you want to use.
744
745 workspace_id: Optional header to select the Workspace for this request. The value is a
746 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
747
748 Only needed for credentials that can act on more than one Workspace. A
749 credential that belongs to a specific Workspace may omit it; if sent, it must
750 match that Workspace.
751
752 extra_headers: Send extra headers
753
754 extra_query: Add additional query parameters to the request
755
756 extra_body: Add additional JSON properties to the request
757
758 timeout: Override the client-level default timeout for this request, in seconds
759 """
760 if not vault_id:
761 raise ValueError(f"Expected a non-empty value for `vault_id` but received {vault_id!r}")
762 if not credential_id:
763 raise ValueError(f"Expected a non-empty value for `credential_id` but received {credential_id!r}")
764 extra_headers = {
765 **strip_not_given(
766 {
767 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"]))
768 if is_given(betas)
769 else not_given,
770 "anthropic-workspace-id": workspace_id,
771 }
772 ),
773 **(extra_headers or {}),
774 }
775 extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})}
776 return await self._post(
777 path_template(
778 "/v1/vaults/{vault_id}/credentials/{credential_id}?beta=true",
779 vault_id=vault_id,
780 credential_id=credential_id,
781 ),
782 body={
783 "auth": auth,
784 "display_name": display_name,
785 "metadata": metadata,
786 },
787 options=make_request_options(
788 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
789 ),
790 cast_to=BetaManagedAgentsCredential,
791 )
792
793 def list(
794 self,
795 vault_id: str,
796 *,
797 include_archived: bool | Omit = omit,
798 limit: int | Omit = omit,
799 page: str | Omit = omit,
800 betas: List[AnthropicBetaParam] | Omit = omit,
801 workspace_id: str | Omit = omit,
802 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
803 # The extra values given here take precedence over values defined on the client or passed to this method.
804 extra_headers: Headers | None = None,
805 extra_query: Query | None = None,
806 extra_body: Body | None = None,
807 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
808 ) -> AsyncPaginator[BetaManagedAgentsCredential, AsyncPageCursor[BetaManagedAgentsCredential]]:
809 """
810 List Credentials
811
812 Args:
813 vault_id: Identifier of the vault to list credentials for.
814
815 include_archived: Whether to include archived credentials in the results.
816
817 limit: Maximum number of credentials to return per page. Defaults to 20, maximum 100.
818
819 page: Opaque pagination token from a previous `list_credentials` response.
820
821 betas: Optional header to specify the beta version(s) you want to use.
822
823 workspace_id: Optional header to select the Workspace for this request. The value is a
824 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
825
826 Only needed for credentials that can act on more than one Workspace. A
827 credential that belongs to a specific Workspace may omit it; if sent, it must
828 match that Workspace.
829
830 extra_headers: Send extra headers
831
832 extra_query: Add additional query parameters to the request
833
834 extra_body: Add additional JSON properties to the request
835
836 timeout: Override the client-level default timeout for this request, in seconds
837 """
838 if not vault_id:
839 raise ValueError(f"Expected a non-empty value for `vault_id` but received {vault_id!r}")
840 extra_headers = {
841 **strip_not_given(
842 {
843 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"]))
844 if is_given(betas)
845 else not_given,
846 "anthropic-workspace-id": workspace_id,
847 }
848 ),
849 **(extra_headers or {}),
850 }
851 extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})}
852 return self._get_api_list(
853 path_template("/v1/vaults/{vault_id}/credentials?beta=true", vault_id=vault_id),
854 page=AsyncPageCursor[BetaManagedAgentsCredential],
855 options=make_request_options(
856 extra_headers=extra_headers,
857 extra_query=extra_query,
858 extra_body=extra_body,
859 timeout=timeout,
860 query={
861 "include_archived": include_archived,
862 "limit": limit,
863 "page": page,
864 },
865 ),
866 model=BetaManagedAgentsCredential,
867 )
868
869 async def delete(
870 self,
871 credential_id: str,
872 *,
873 vault_id: str,
874 betas: List[AnthropicBetaParam] | Omit = omit,
875 workspace_id: str | Omit = omit,
876 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
877 # The extra values given here take precedence over values defined on the client or passed to this method.
878 extra_headers: Headers | None = None,
879 extra_query: Query | None = None,
880 extra_body: Body | None = None,
881 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
882 ) -> BetaManagedAgentsDeletedCredential:
883 """
884 Delete Credential
885
886 Args:
887 vault_id: Identifier of the vault containing the credential.
888
889 credential_id: Unique identifier of the credential to delete.
890
891 betas: Optional header to specify the beta version(s) you want to use.
892
893 workspace_id: Optional header to select the Workspace for this request. The value is a
894 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
895
896 Only needed for credentials that can act on more than one Workspace. A
897 credential that belongs to a specific Workspace may omit it; if sent, it must
898 match that Workspace.
899
900 extra_headers: Send extra headers
901
902 extra_query: Add additional query parameters to the request
903
904 extra_body: Add additional JSON properties to the request
905
906 timeout: Override the client-level default timeout for this request, in seconds
907 """
908 if not vault_id:
909 raise ValueError(f"Expected a non-empty value for `vault_id` but received {vault_id!r}")
910 if not credential_id:
911 raise ValueError(f"Expected a non-empty value for `credential_id` but received {credential_id!r}")
912 extra_headers = {
913 **strip_not_given(
914 {
915 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"]))
916 if is_given(betas)
917 else not_given,
918 "anthropic-workspace-id": workspace_id,
919 }
920 ),
921 **(extra_headers or {}),
922 }
923 extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})}
924 return await self._delete(
925 path_template(
926 "/v1/vaults/{vault_id}/credentials/{credential_id}?beta=true",
927 vault_id=vault_id,
928 credential_id=credential_id,
929 ),
930 options=make_request_options(
931 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
932 ),
933 cast_to=BetaManagedAgentsDeletedCredential,
934 )
935
936 async def archive(
937 self,
938 credential_id: str,
939 *,
940 vault_id: str,
941 betas: List[AnthropicBetaParam] | Omit = omit,
942 workspace_id: str | Omit = omit,
943 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
944 # The extra values given here take precedence over values defined on the client or passed to this method.
945 extra_headers: Headers | None = None,
946 extra_query: Query | None = None,
947 extra_body: Body | None = None,
948 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
949 ) -> BetaManagedAgentsCredential:
950 """
951 Archive Credential
952
953 Args:
954 vault_id: Identifier of the vault containing the credential.
955
956 credential_id: Unique identifier of the credential to archive.
957
958 betas: Optional header to specify the beta version(s) you want to use.
959
960 workspace_id: Optional header to select the Workspace for this request. The value is a
961 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
962
963 Only needed for credentials that can act on more than one Workspace. A
964 credential that belongs to a specific Workspace may omit it; if sent, it must
965 match that Workspace.
966
967 extra_headers: Send extra headers
968
969 extra_query: Add additional query parameters to the request
970
971 extra_body: Add additional JSON properties to the request
972
973 timeout: Override the client-level default timeout for this request, in seconds
974 """
975 if not vault_id:
976 raise ValueError(f"Expected a non-empty value for `vault_id` but received {vault_id!r}")
977 if not credential_id:
978 raise ValueError(f"Expected a non-empty value for `credential_id` but received {credential_id!r}")
979 extra_headers = {
980 **strip_not_given(
981 {
982 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"]))
983 if is_given(betas)
984 else not_given,
985 "anthropic-workspace-id": workspace_id,
986 }
987 ),
988 **(extra_headers or {}),
989 }
990 extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})}
991 return await self._post(
992 path_template(
993 "/v1/vaults/{vault_id}/credentials/{credential_id}/archive?beta=true",
994 vault_id=vault_id,
995 credential_id=credential_id,
996 ),
997 options=make_request_options(
998 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
999 ),
1000 cast_to=BetaManagedAgentsCredential,
1001 )
1002
1003 async def mcp_oauth_validate(
1004 self,
1005 credential_id: str,
1006 *,
1007 vault_id: str,
1008 betas: List[AnthropicBetaParam] | Omit = omit,
1009 workspace_id: str | Omit = omit,
1010 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1011 # The extra values given here take precedence over values defined on the client or passed to this method.
1012 extra_headers: Headers | None = None,
1013 extra_query: Query | None = None,
1014 extra_body: Body | None = None,
1015 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
1016 ) -> BetaManagedAgentsCredentialValidation:
1017 """
1018 Validate Credential
1019
1020 Args:
1021 vault_id: Identifier of the vault containing the credential.
1022
1023 credential_id: Unique identifier of the credential to validate.
1024
1025 betas: Optional header to specify the beta version(s) you want to use.
1026
1027 workspace_id: Optional header to select the Workspace for this request. The value is a
1028 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
1029
1030 Only needed for credentials that can act on more than one Workspace. A
1031 credential that belongs to a specific Workspace may omit it; if sent, it must
1032 match that Workspace.
1033
1034 extra_headers: Send extra headers
1035
1036 extra_query: Add additional query parameters to the request
1037
1038 extra_body: Add additional JSON properties to the request
1039
1040 timeout: Override the client-level default timeout for this request, in seconds
1041 """
1042 if not vault_id:
1043 raise ValueError(f"Expected a non-empty value for `vault_id` but received {vault_id!r}")
1044 if not credential_id:
1045 raise ValueError(f"Expected a non-empty value for `credential_id` but received {credential_id!r}")
1046 extra_headers = {
1047 **strip_not_given(
1048 {
1049 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"]))
1050 if is_given(betas)
1051 else not_given,
1052 "anthropic-workspace-id": workspace_id,
1053 }
1054 ),
1055 **(extra_headers or {}),
1056 }
1057 extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})}
1058 return await self._post(
1059 path_template(
1060 "/v1/vaults/{vault_id}/credentials/{credential_id}/mcp_oauth_validate?beta=true",
1061 vault_id=vault_id,
1062 credential_id=credential_id,
1063 ),
1064 options=make_request_options(
1065 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
1066 ),
1067 cast_to=BetaManagedAgentsCredentialValidation,
1068 )
1069
1070
1071 class CredentialsWithRawResponse:
1072 def __init__(self, credentials: Credentials) -> None:
1073 self._credentials = credentials
1074
1075 self.create = to_raw_response_wrapper(
1076 credentials.create,
1077 )
1078 self.retrieve = to_raw_response_wrapper(
1079 credentials.retrieve,
1080 )
1081 self.update = to_raw_response_wrapper(
1082 credentials.update,
1083 )
1084 self.list = to_raw_response_wrapper(
1085 credentials.list,
1086 )
1087 self.delete = to_raw_response_wrapper(
1088 credentials.delete,
1089 )
1090 self.archive = to_raw_response_wrapper(
1091 credentials.archive,
1092 )
1093 self.mcp_oauth_validate = to_raw_response_wrapper(
1094 credentials.mcp_oauth_validate,
1095 )
1096
1097
1098 class AsyncCredentialsWithRawResponse:
1099 def __init__(self, credentials: AsyncCredentials) -> None:
1100 self._credentials = credentials
1101
1102 self.create = async_to_raw_response_wrapper(
1103 credentials.create,
1104 )
1105 self.retrieve = async_to_raw_response_wrapper(
1106 credentials.retrieve,
1107 )
1108 self.update = async_to_raw_response_wrapper(
1109 credentials.update,
1110 )
1111 self.list = async_to_raw_response_wrapper(
1112 credentials.list,
1113 )
1114 self.delete = async_to_raw_response_wrapper(
1115 credentials.delete,
1116 )
1117 self.archive = async_to_raw_response_wrapper(
1118 credentials.archive,
1119 )
1120 self.mcp_oauth_validate = async_to_raw_response_wrapper(
1121 credentials.mcp_oauth_validate,
1122 )
1123
1124
1125 class CredentialsWithStreamingResponse:
1126 def __init__(self, credentials: Credentials) -> None:
1127 self._credentials = credentials
1128
1129 self.create = to_streamed_response_wrapper(
1130 credentials.create,
1131 )
1132 self.retrieve = to_streamed_response_wrapper(
1133 credentials.retrieve,
1134 )
1135 self.update = to_streamed_response_wrapper(
1136 credentials.update,
1137 )
1138 self.list = to_streamed_response_wrapper(
1139 credentials.list,
1140 )
1141 self.delete = to_streamed_response_wrapper(
1142 credentials.delete,
1143 )
1144 self.archive = to_streamed_response_wrapper(
1145 credentials.archive,
1146 )
1147 self.mcp_oauth_validate = to_streamed_response_wrapper(
1148 credentials.mcp_oauth_validate,
1149 )
1150
1151
1152 class AsyncCredentialsWithStreamingResponse:
1153 def __init__(self, credentials: AsyncCredentials) -> None:
1154 self._credentials = credentials
1155
1156 self.create = async_to_streamed_response_wrapper(
1157 credentials.create,
1158 )
1159 self.retrieve = async_to_streamed_response_wrapper(
1160 credentials.retrieve,
1161 )
1162 self.update = async_to_streamed_response_wrapper(
1163 credentials.update,
1164 )
1165 self.list = async_to_streamed_response_wrapper(
1166 credentials.list,
1167 )
1168 self.delete = async_to_streamed_response_wrapper(
1169 credentials.delete,
1170 )
1171 self.archive = async_to_streamed_response_wrapper(
1172 credentials.archive,
1173 )
1174 self.mcp_oauth_validate = async_to_streamed_response_wrapper(
1175 credentials.mcp_oauth_validate,
1176 )