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