spend-limits-api changedmanage-claude/spend-limits-api
Nearest release: v2.1.301, published 5 hours before this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Recorded here
Lines+1,990added
Lines−104removed
From line
34
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits13to this page, all time
The whole hunk
from line 34, old and new numbered
/
The two sides of this change are more than 400 edits apart, too far apart to line up, so this is the differ's own diff of it and the words inside a line are not marked.
from line 34
3434* Your organization must be on a Claude Enterprise plan.
3535* Usage credits must be turned on for your organization. Your primary owner can turn them on in claude.ai billing settings.
3636
37The SDK exposes these endpoints under `client.beta.organization.spend_limits` (typescript: `client.beta.organization.spendLimits`; csharp, go: `client.Beta.Organization.SpendLimits`; java: `client.beta().organization().spendLimits()`; php: `$client->beta->organization->spendLimits`), and the `ant` CLI under `ant beta:organization:spend-limits`. Both send the `anthropic-version` header for you. The examples read the Admin API key from the `ANTHROPIC_API_KEY` environment variable. The SDK and the CLI fetch more pages for you as you go through the results, so `limit` sets the page size, not the total (see [Pagination](https://platform.claude.com/docs/en/manage-claude/spend-limits-api#pagination)).
38
3739## Quick start
3840
3941List every member's effective monthly spend limit and period-to-date spend:
4042
41```bash cURL
42curl "https://api.anthropic.com/v1/organizations/spend_limits/effective?limit=20" \
43 --header "x-api-key: $ANTHROPIC_ADMIN_KEY" \
44 --header "anthropic-version: 2023-06-01"
45```
43<CodeGroup>
44 ```bash cURL
45 curl "https://api.anthropic.com/v1/organizations/spend_limits/effective?limit=20" \
46 -H "x-api-key: $ANTHROPIC_API_KEY" \
47 -H "anthropic-version: 2023-06-01"
48 ```
49
50 ```bash CLI
51 ant beta:organization:spend-limits:effective list --limit 20
52 ```
53
54 ```python Python
55 client = anthropic.Anthropic()
56
57 effective_limits = client.beta.organization.spend_limits.effective.list(limit=20)
58
59 for effective_limit in effective_limits:
60 scope = effective_limit.scope
61 if scope.type == "user":
62 amount = effective_limit.amount or "unlimited"
63 print(f"{scope.user_id}: {effective_limit.period_to_date_spend} of {amount}")
64 ```
65
66 ```typescript TypeScript
67 const client = new Anthropic();
68
69 const effectiveLimits = await client.beta.organization.spendLimits.effective.list({
70 limit: 20
71 });
72
73 for await (const effectiveLimit of effectiveLimits) {
74 const { scope } = effectiveLimit;
75 if (scope.type === "user") {
76 const amount = effectiveLimit.amount ?? "unlimited";
77 console.log(`${scope.user_id}: ${effectiveLimit.period_to_date_spend} of ${amount}`);
78 }
79 }
80 ```
81
82 ```csharp C#
83 AnthropicClient client = new();
84
85 var page = await client.Beta.Organization.SpendLimits.Effective.List(
86 new() { Limit = 20 }
87 );
88
89 await foreach (var effectiveLimit in page.Paginate())
90 {
91 if (effectiveLimit.Scope.TryPickBetaSpendLimitUser(out var userScope))
92 {
93 var amount = effectiveLimit.Amount ?? "unlimited";
94 Console.WriteLine($"{userScope.UserID}: {effectiveLimit.PeriodToDateSpend} of {amount}");
95 }
96 }
97 ```
98
99 ```go Go
100 client := anthropic.NewClient()
101
102 effectiveLimits := client.Beta.Organization.SpendLimits.Effective.ListAutoPaging(context.Background(), anthropic.BetaOrganizationSpendLimitEffectiveListParams{
103 Limit: anthropic.Int(20),
104 })
105
106 for effectiveLimits.Next() {
107 effectiveLimit := effectiveLimits.Current()
108 if userScope, ok := effectiveLimit.Scope.AsAny().(anthropic.BetaSpendLimitUserScope); ok {
109 amount := effectiveLimit.Amount
110 if !effectiveLimit.JSON.Amount.Valid() {
111 amount = "unlimited"
112 }
113 fmt.Printf("%s: %s of %s\n", userScope.UserID, effectiveLimit.PeriodToDateSpend, amount)
114 }
115 }
116 if err := effectiveLimits.Err(); err != nil {
117 log.Fatal(err)
118 }
119 ```
120
121 ```java Java
122 import com.anthropic.models.beta.organization.spendlimits.effective.EffectiveListParams;
123
124 void main() {
125 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
126
127 var params = EffectiveListParams.builder()
128 .limit(20)
129 .build();
130 var effectiveLimits = client.beta().organization().spendLimits().effective().list(params);
131
132 for (var effectiveLimit : effectiveLimits.autoPager()) {
133 var amount = effectiveLimit.amount().orElse("unlimited");
134 effectiveLimit.scope().user().ifPresent(userScope ->
135 IO.println(userScope.userId() + ": " + effectiveLimit.periodToDateSpend() + " of " + amount)
136 );
137 }
138 }
139 ```
140
141 ```php PHP
142 use Anthropic\Beta\Organization\SpendLimits\SpendLimitUserScope;
143 // ...
144
145 $client = new Client();
146
147 $effectiveLimits = $client->beta->organization->spendLimits->effective->list(limit: 20);
148
149 foreach ($effectiveLimits->pagingEachItem() as $effectiveLimit) {
150 $scope = $effectiveLimit->scope;
151 if ($scope instanceof SpendLimitUserScope) {
152 $amount = $effectiveLimit->amount ?? 'unlimited';
153 echo "{$scope->userID}: {$effectiveLimit->periodToDateSpend} of {$amount}\n";
154 }
155 }
156 ```
157
158 ```ruby Ruby
159 client = Anthropic::Client.new
160
161 page = client.beta.organization.spend_limits.effective.list(limit: 20)
162
163 page.auto_paging_each do |effective_limit|
164 scope = effective_limit.scope
165 if scope.is_a?(Anthropic::Models::Beta::Organization::BetaSpendLimitUserScope)
166 amount = effective_limit.amount || "unlimited"
167 puts "#{scope.user_id}: #{effective_limit.period_to_date_spend} of #{amount}"
168 end
169 end
170 ```
171</CodeGroup>
46172
47173## Key concepts
48174
from line 242
116242
117243For complete parameter details and response schemas, see [List effective spend limits](https://platform.claude.com/docs/en/api/beta/organization/spend_limits/effective/list) in the API reference.
118244
119```bash cURL
120curl "https://api.anthropic.com/v1/organizations/spend_limits/effective?limit=20" \
121 --header "x-api-key: $ANTHROPIC_ADMIN_KEY" \
122 --header "anthropic-version: 2023-06-01"
123```
245<CodeGroup>
246 ```bash cURL
247 curl "https://api.anthropic.com/v1/organizations/spend_limits/effective?limit=20" \
248 -H "x-api-key: $ANTHROPIC_API_KEY" \
249 -H "anthropic-version: 2023-06-01"
250 ```
251
252 ```bash CLI
253 ant beta:organization:spend-limits:effective list --limit 20
254 ```
255
256 ```python Python
257 client = anthropic.Anthropic()
258
259 effective_limits = client.beta.organization.spend_limits.effective.list(limit=20)
260
261 for effective_limit in effective_limits:
262 scope = effective_limit.scope
263 if scope.type == "user":
264 amount = effective_limit.amount or "unlimited"
265 print(f"{scope.user_id}: {effective_limit.period_to_date_spend} of {amount}")
266 ```
267
268 ```typescript TypeScript
269 const client = new Anthropic();
270
271 const effectiveLimits = await client.beta.organization.spendLimits.effective.list({
272 limit: 20
273 });
274
275 for await (const effectiveLimit of effectiveLimits) {
276 const { scope } = effectiveLimit;
277 if (scope.type === "user") {
278 const amount = effectiveLimit.amount ?? "unlimited";
279 console.log(`${scope.user_id}: ${effectiveLimit.period_to_date_spend} of ${amount}`);
280 }
281 }
282 ```
283
284 ```csharp C#
285 AnthropicClient client = new();
286
287 var page = await client.Beta.Organization.SpendLimits.Effective.List(
288 new() { Limit = 20 }
289 );
290
291 await foreach (var effectiveLimit in page.Paginate())
292 {
293 if (effectiveLimit.Scope.TryPickBetaSpendLimitUser(out var userScope))
294 {
295 var amount = effectiveLimit.Amount ?? "unlimited";
296 Console.WriteLine($"{userScope.UserID}: {effectiveLimit.PeriodToDateSpend} of {amount}");
297 }
298 }
299 ```
300
301 ```go Go
302 client := anthropic.NewClient()
303
304 effectiveLimits := client.Beta.Organization.SpendLimits.Effective.ListAutoPaging(context.Background(), anthropic.BetaOrganizationSpendLimitEffectiveListParams{
305 Limit: anthropic.Int(20),
306 })
307
308 for effectiveLimits.Next() {
309 effectiveLimit := effectiveLimits.Current()
310 if userScope, ok := effectiveLimit.Scope.AsAny().(anthropic.BetaSpendLimitUserScope); ok {
311 amount := effectiveLimit.Amount
312 if !effectiveLimit.JSON.Amount.Valid() {
313 amount = "unlimited"
314 }
315 fmt.Printf("%s: %s of %s\n", userScope.UserID, effectiveLimit.PeriodToDateSpend, amount)
316 }
317 }
318 if err := effectiveLimits.Err(); err != nil {
319 log.Fatal(err)
320 }
321 ```
322
323 ```java Java
324 import com.anthropic.models.beta.organization.spendlimits.effective.EffectiveListParams;
325
326 void main() {
327 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
328
329 var params = EffectiveListParams.builder()
330 .limit(20)
331 .build();
332 var effectiveLimits = client.beta().organization().spendLimits().effective().list(params);
333
334 for (var effectiveLimit : effectiveLimits.autoPager()) {
335 var amount = effectiveLimit.amount().orElse("unlimited");
336 effectiveLimit.scope().user().ifPresent(userScope ->
337 IO.println(userScope.userId() + ": " + effectiveLimit.periodToDateSpend() + " of " + amount)
338 );
339 }
340 }
341 ```
342
343 ```php PHP
344 use Anthropic\Beta\Organization\SpendLimits\SpendLimitUserScope;
345 // ...
346
347 $client = new Client();
348
349 $effectiveLimits = $client->beta->organization->spendLimits->effective->list(limit: 20);
350
351 foreach ($effectiveLimits->pagingEachItem() as $effectiveLimit) {
352 $scope = $effectiveLimit->scope;
353 if ($scope instanceof SpendLimitUserScope) {
354 $amount = $effectiveLimit->amount ?? 'unlimited';
355 echo "{$scope->userID}: {$effectiveLimit->periodToDateSpend} of {$amount}\n";
356 }
357 }
358 ```
359
360 ```ruby Ruby
361 client = Anthropic::Client.new
362
363 page = client.beta.organization.spend_limits.effective.list(limit: 20)
364
365 page.auto_paging_each do |effective_limit|
366 scope = effective_limit.scope
367 if scope.is_a?(Anthropic::Models::Beta::Organization::BetaSpendLimitUserScope)
368 amount = effective_limit.amount || "unlimited"
369 puts "#{scope.user_id}: #{effective_limit.period_to_date_spend} of #{amount}"
370 end
371 end
372 ```
373</CodeGroup>
124374
125375```json
126376{
from line 402
152402
153403For complete parameter details and response schemas, see [Retrieve a spend limit](https://platform.claude.com/docs/en/api/beta/organization/spend_limits/retrieve) in the API reference.
154404
155```bash cURL
156curl "https://api.anthropic.com/v1/organizations/spend_limits/spl_01AbCdEfGhIjKlMnOpQrSt" \
157 --header "x-api-key: $ANTHROPIC_ADMIN_KEY" \
158 --header "anthropic-version: 2023-06-01"
159```
405<CodeGroup>
406 ```bash cURL
407 curl "https://api.anthropic.com/v1/organizations/spend_limits/spl_01AbCdEfGhIjKlMnOpQrSt" \
408 -H "x-api-key: $ANTHROPIC_API_KEY" \
409 -H "anthropic-version: 2023-06-01"
410 ```
411
412 ```bash CLI
413 ant beta:organization:spend-limits retrieve \
414 --spend-limit-id spl_01AbCdEfGhIjKlMnOpQrSt
415 ```
416
417 ```python Python
418 client = anthropic.Anthropic()
419
420 spend_limit = client.beta.organization.spend_limits.retrieve(
421 "spl_01AbCdEfGhIjKlMnOpQrSt"
422 )
423
424 amount = spend_limit.amount or "none"
425 print(f"id: {spend_limit.id}")
426 print(f"amount: {amount}")
427 ```
428
429 ```typescript TypeScript
430 const client = new Anthropic();
431
432 const spendLimit = await client.beta.organization.spendLimits.retrieve(
433 "spl_01AbCdEfGhIjKlMnOpQrSt"
434 );
435
436 const amount = spendLimit.amount ?? "none";
437 console.log(`id: ${spendLimit.id}`);
438 console.log(`amount: ${amount}`);
439 ```
440
441 ```csharp C#
442 AnthropicClient client = new();
443
444 var spendLimit = await client.Beta.Organization.SpendLimits.Retrieve(
445 "spl_01AbCdEfGhIjKlMnOpQrSt"
446 );
447
448 var amount = spendLimit.Amount ?? "none";
449 Console.WriteLine($"id: {spendLimit.ID}");
450 Console.WriteLine($"amount: {amount}");
451 ```
452
453 ```go Go
454 client := anthropic.NewClient()
455
456 spendLimit, err := client.Beta.Organization.SpendLimits.Get(context.Background(), "spl_01AbCdEfGhIjKlMnOpQrSt")
457 if err != nil {
458 log.Fatal(err)
459 }
460
461 amount := spendLimit.Amount
462 if !spendLimit.JSON.Amount.Valid() {
463 amount = "none"
464 }
465
466 fmt.Printf("id: %s\n", spendLimit.ID)
467 fmt.Printf("amount: %s\n", amount)
468 ```
469
470 ```java Java
471 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
472
473 var spendLimit = client.beta().organization().spendLimits()
474 .retrieve("spl_01AbCdEfGhIjKlMnOpQrSt");
475
476 var amount = spendLimit.amount().orElse("none");
477 IO.println("id: " + spendLimit.id());
478 IO.println("amount: " + amount);
479 ```
480
481 ```php PHP
482 $client = new Client();
483
484 $spendLimit = $client->beta->organization->spendLimits->retrieve('spl_01AbCdEfGhIjKlMnOpQrSt');
485
486 $amount = $spendLimit->amount ?? 'none';
487 echo "id: {$spendLimit->id}\n";
488 echo "amount: {$amount}\n";
489 ```
490
491 ```ruby Ruby
492 client = Anthropic::Client.new
493
494 spend_limit = client.beta.organization.spend_limits.retrieve("spl_01AbCdEfGhIjKlMnOpQrSt")
495
496 amount = spend_limit.amount || "none"
497 puts "id: #{spend_limit.id}"
498 puts "amount: #{amount}"
499 ```
500</CodeGroup>
160501
161502### Set a per-user override
162503
from line 505
164505
165506For complete parameter details and response schemas, see [Create a spend limit](https://platform.claude.com/docs/en/api/beta/organization/spend_limits/set) in the API reference.
166507
167```bash cURL
168curl --request POST "https://api.anthropic.com/v1/organizations/spend_limits" \
169 --header "content-type: application/json" \
170 --header "x-api-key: $ANTHROPIC_ADMIN_KEY" \
171 --header "anthropic-version: 2023-06-01" \
172 --data '{"scope": {"type": "user", "user_id": "user_01AbCdEfGh"}, "amount": "75000"}'
173```
508<CodeGroup>
509 ```bash cURL
510 curl -X POST "https://api.anthropic.com/v1/organizations/spend_limits" \
511 -H "content-type: application/json" \
512 -H "x-api-key: $ANTHROPIC_API_KEY" \
513 -H "anthropic-version: 2023-06-01" \
514 -d '{"scope": {"type": "user", "user_id": "user_01AbCdEfGh"}, "amount": "75000"}'
515 ```
516
517 ```bash CLI
518 ant beta:organization:spend-limits set \
519 --scope '{type: user, user_id: user_01AbCdEfGh}' \
520 --amount 75000
521 ```
522
523 ```python Python
524 client = anthropic.Anthropic()
525
526 spend_limit = client.beta.organization.spend_limits.set(
527 scope={"type": "user", "user_id": "user_01AbCdEfGh"}, amount="75000"
528 )
529
530 print(f"id: {spend_limit.id}")
531 print(f"amount: {spend_limit.amount}")
532 ```
533
534 ```typescript TypeScript
535 const client = new Anthropic();
536
537 const spendLimit = await client.beta.organization.spendLimits.set({
538 scope: { type: "user", user_id: "user_01AbCdEfGh" },
539 amount: "75000"
540 });
541
542 console.log(`id: ${spendLimit.id}`);
543 console.log(`amount: ${spendLimit.amount}`);
544 ```
545
546 ```csharp C#
547 using Anthropic.Models.Beta.Organization.SpendLimits;
548
549 AnthropicClient client = new();
550
551 var spendLimit = await client.Beta.Organization.SpendLimits.Set(
552 new()
553 {
554 Scope = new BetaSpendLimitUserScope("user_01AbCdEfGh"),
555 Amount = "75000",
556 }
557 );
558
559 Console.WriteLine($"id: {spendLimit.ID}");
560 Console.WriteLine($"amount: {spendLimit.Amount}");
561 ```
562
563 ```go Go
564 client := anthropic.NewClient()
565
566 spendLimit, err := client.Beta.Organization.SpendLimits.Set(context.Background(), anthropic.BetaOrganizationSpendLimitSetParams{
567 Scope: anthropic.BetaOrganizationSpendLimitSetParamsScopeUnion{
568 OfUser: &anthropic.BetaSpendLimitUserScopeParam{UserID: "user_01AbCdEfGh"},
569 },
570 Amount: anthropic.String("75000"),
571 })
572 if err != nil {
573 log.Fatal(err)
574 }
575
576 fmt.Printf("id: %s\n", spendLimit.ID)
577 fmt.Printf("amount: %s\n", spendLimit.Amount)
578 ```
579
580 ```java Java
581 import com.anthropic.models.beta.organization.spendlimits.SpendLimitSetParams;
582
583 void main() {
584 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
585
586 var params = SpendLimitSetParams.builder()
587 .userScope("user_01AbCdEfGh")
588 .amount("75000")
589 .build();
590 var spendLimit = client.beta().organization().spendLimits().set(params);
591
592 IO.println("id: " + spendLimit.id());
593 IO.println("amount: " + spendLimit.amount().orElseThrow());
594 }
595 ```
596
597 ```php PHP
598 use Anthropic\Beta\Organization\SpendLimits\SpendLimitUserScope;
599 // ...
600
601 $client = new Client();
602
603 $spendLimit = $client->beta->organization->spendLimits->set(
604 scope: SpendLimitUserScope::with(userID: 'user_01AbCdEfGh'),
605 amount: '75000',
606 );
607
608 echo "id: {$spendLimit->id}\n";
609 echo "amount: {$spendLimit->amount}\n";
610 ```
611
612 ```ruby Ruby
613 client = Anthropic::Client.new
614
615 spend_limit = client.beta.organization.spend_limits.set(
616 scope: { type: :user, user_id: "user_01AbCdEfGh" },
617 amount: "75000"
618 )
619
620 puts "id: #{spend_limit.id}"
621 puts "amount: #{spend_limit.amount}"
622 ```
623</CodeGroup>
174624
175625```json
176626{
from line 641
191641
192642For complete parameter details and response schemas, see [Delete a spend limit](https://platform.claude.com/docs/en/api/beta/organization/spend_limits/delete) in the API reference.
193643
194```bash cURL
195curl --request DELETE "https://api.anthropic.com/v1/organizations/spend_limits/spl_01RsTuVwXyZaBcDeFgHiJk" \
196 --header "x-api-key: $ANTHROPIC_ADMIN_KEY" \
197 --header "anthropic-version: 2023-06-01"
198```
644<CodeGroup>
645 ```bash cURL
646 curl -X DELETE "https://api.anthropic.com/v1/organizations/spend_limits/spl_01RsTuVwXyZaBcDeFgHiJk" \
647 -H "x-api-key: $ANTHROPIC_API_KEY" \
648 -H "anthropic-version: 2023-06-01"
649 ```
650
651 ```bash CLI
652 ant beta:organization:spend-limits delete \
653 --spend-limit-id spl_01RsTuVwXyZaBcDeFgHiJk
654 ```
655
656 ```python Python
657 client = anthropic.Anthropic()
658
659 deleted_spend_limit = client.beta.organization.spend_limits.delete(
660 "spl_01RsTuVwXyZaBcDeFgHiJk"
661 )
662
663 print(f"id: {deleted_spend_limit.id}")
664 ```
665
666 ```typescript TypeScript
667 const client = new Anthropic();
668
669 const deletedSpendLimit = await client.beta.organization.spendLimits.delete(
670 "spl_01RsTuVwXyZaBcDeFgHiJk"
671 );
672
673 console.log(`id: ${deletedSpendLimit.id}`);
674 ```
675
676 ```csharp C#
677 AnthropicClient client = new();
678
679 var deletedSpendLimit = await client.Beta.Organization.SpendLimits.Delete(
680 "spl_01RsTuVwXyZaBcDeFgHiJk"
681 );
682
683 Console.WriteLine($"id: {deletedSpendLimit.ID}");
684 ```
685
686 ```go Go
687 client := anthropic.NewClient()
688
689 deletedSpendLimit, err := client.Beta.Organization.SpendLimits.Delete(context.Background(), "spl_01RsTuVwXyZaBcDeFgHiJk")
690 if err != nil {
691 log.Fatal(err)
692 }
693
694 fmt.Printf("id: %s\n", deletedSpendLimit.ID)
695 ```
696
697 ```java Java
698 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
699
700 var deletedSpendLimit = client.beta().organization().spendLimits()
701 .delete("spl_01RsTuVwXyZaBcDeFgHiJk");
702
703 IO.println("id: " + deletedSpendLimit.id());
704 ```
705
706 ```php PHP
707 $client = new Client();
708
709 $deletedSpendLimit = $client->beta->organization->spendLimits->delete('spl_01RsTuVwXyZaBcDeFgHiJk');
710
711 echo "id: {$deletedSpendLimit->id}\n";
712 ```
713
714 ```ruby Ruby
715 client = Anthropic::Client.new
716
717 deleted_spend_limit = client.beta.organization.spend_limits.delete("spl_01RsTuVwXyZaBcDeFgHiJk")
718
719 puts "id: #{deleted_spend_limit.id}"
720 ```
721</CodeGroup>
199722
200723## Spend limit increase requests
201724
from line 728
205728
206729For complete parameter details and response schemas, see [List spend limit increase requests](https://platform.claude.com/docs/en/api/beta/organization/spend_limits/increase_requests/list) in the API reference.
207730
208```bash cURL
209curl --globoff "https://api.anthropic.com/v1/organizations/spend_limit_increase_requests?status[]=pending&limit=50" \
210 --header "x-api-key: $ANTHROPIC_ADMIN_KEY" \
211 --header "anthropic-version: 2023-06-01"
212```
731<CodeGroup>
732 ```bash cURL
733 curl -g "https://api.anthropic.com/v1/organizations/spend_limit_increase_requests?status[]=pending&limit=50" \
734 -H "x-api-key: $ANTHROPIC_API_KEY" \
735 -H "anthropic-version: 2023-06-01"
736 ```
737
738 ```bash CLI
739 ant beta:organization:spend-limits:increase-requests list \
740 --status pending \
741 --limit 50
742 ```
743
744 ```python Python
745 client = anthropic.Anthropic()
746
747 increase_requests = client.beta.organization.spend_limits.increase_requests.list(
748 status=["pending"], limit=50
749 )
750
751 for increase_request in increase_requests:
752 print(f"{increase_request.id}: {increase_request.status}")
753 ```
754
755 ```typescript TypeScript
756 const client = new Anthropic();
757
758 const increaseRequests = await client.beta.organization.spendLimits.increaseRequests.list({
759 status: ["pending"],
760 limit: 50
761 });
762
763 for await (const increaseRequest of increaseRequests) {
764 console.log(`${increaseRequest.id}: ${increaseRequest.status}`);
765 }
766 ```
767
768 ```csharp C#
769 using Anthropic.Models.Beta.Organization.SpendLimits.IncreaseRequests;
770
771 AnthropicClient client = new();
772
773 var page = await client.Beta.Organization.SpendLimits.IncreaseRequests.List(
774 new() { Status = [BetaSpendLimitIncreaseRequestStatus.Pending], Limit = 50 }
775 );
776
777 await foreach (var increaseRequest in page.Paginate())
778 {
779 Console.WriteLine($"{increaseRequest.ID}: {increaseRequest.Status.Raw()}");
780 }
781 ```
782
783 ```go Go
784 client := anthropic.NewClient()
785
786 increaseRequests := client.Beta.Organization.SpendLimits.IncreaseRequests.ListAutoPaging(context.Background(), anthropic.BetaOrganizationSpendLimitIncreaseRequestListParams{
787 Status: []anthropic.BetaSpendLimitIncreaseRequestStatus{anthropic.BetaSpendLimitIncreaseRequestStatusPending},
788 Limit: anthropic.Int(50),
789 })
790
791 for increaseRequests.Next() {
792 increaseRequest := increaseRequests.Current()
793 fmt.Printf("%s: %s\n", increaseRequest.ID, increaseRequest.Status)
794 }
795 if err := increaseRequests.Err(); err != nil {
796 log.Fatal(err)
797 }
798 ```
799
800 ```java Java
801 import com.anthropic.models.beta.organization.spendlimits.increaserequests.BetaSpendLimitIncreaseRequestStatus;
802 import com.anthropic.models.beta.organization.spendlimits.increaserequests.IncreaseRequestListParams;
803
804 void main() {
805 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
806
807 var params = IncreaseRequestListParams.builder()
808 .addStatus(BetaSpendLimitIncreaseRequestStatus.PENDING)
809 .limit(50)
810 .build();
811 var increaseRequests = client.beta().organization().spendLimits().increaseRequests().list(params);
812
813 for (var increaseRequest : increaseRequests.autoPager()) {
814 IO.println(increaseRequest.id() + ": " + increaseRequest.status().asString());
815 }
816 }
817 ```
818
819 ```php PHP
820 $client = new Client();
821
822 $increaseRequests = $client->beta->organization->spendLimits->increaseRequests->list(
823 status: ['pending'],
824 limit: 50,
825 );
826
827 foreach ($increaseRequests->pagingEachItem() as $increaseRequest) {
828 echo "{$increaseRequest->id}: {$increaseRequest->status}\n";
829 }
830 ```
831
832 ```ruby Ruby
833 client = Anthropic::Client.new
834
835 page = client.beta.organization.spend_limits.increase_requests.list(status: [:pending], limit: 50)
836
837 page.auto_paging_each do |increase_request|
838 puts "#{increase_request.id}: #{increase_request.status}"
839 end
840 ```
841</CodeGroup>
213842
214843Each pending request carries a live `spend_summary` showing the requester's current effective spend limit and period-to-date spend, enough to decide without a separate lookup.
215844
from line 848
219848
220849For complete parameter details and response schemas, see [Retrieve a spend limit increase request](https://platform.claude.com/docs/en/api/beta/organization/spend_limits/increase_requests/retrieve) in the API reference.
221850
222```bash cURL
223curl "https://api.anthropic.com/v1/organizations/spend_limit_increase_requests/slir_01AbCdEfGhIjKlMnOpQrSt" \
224 --header "x-api-key: $ANTHROPIC_ADMIN_KEY" \
225 --header "anthropic-version: 2023-06-01"
226```
851<CodeGroup>
852 ```bash cURL
853 curl "https://api.anthropic.com/v1/organizations/spend_limit_increase_requests/slir_01AbCdEfGhIjKlMnOpQrSt" \
854 -H "x-api-key: $ANTHROPIC_API_KEY" \
855 -H "anthropic-version: 2023-06-01"
856 ```
857
858 ```bash CLI
859 ant beta:organization:spend-limits:increase-requests retrieve \
860 --spend-limit-increase-request-id slir_01AbCdEfGhIjKlMnOpQrSt
861 ```
862
863 ```python Python
864 client = anthropic.Anthropic()
865
866 increase_request = client.beta.organization.spend_limits.increase_requests.retrieve(
867 "slir_01AbCdEfGhIjKlMnOpQrSt"
868 )
869
870 print(f"id: {increase_request.id}")
871 print(f"status: {increase_request.status}")
872 ```
873
874 ```typescript TypeScript
875 const client = new Anthropic();
876
877 const increaseRequest = await client.beta.organization.spendLimits.increaseRequests.retrieve(
878 "slir_01AbCdEfGhIjKlMnOpQrSt"
879 );
880
881 console.log(`id: ${increaseRequest.id}`);
882 console.log(`status: ${increaseRequest.status}`);
883 ```
884
885 ```csharp C#
886 AnthropicClient client = new();
887
888 var increaseRequest = await client.Beta.Organization.SpendLimits.IncreaseRequests.Retrieve(
889 "slir_01AbCdEfGhIjKlMnOpQrSt"
890 );
891
892 Console.WriteLine($"id: {increaseRequest.ID}");
893 Console.WriteLine($"status: {increaseRequest.Status.Raw()}");
894 ```
895
896 ```go Go
897 client := anthropic.NewClient()
898
899 increaseRequest, err := client.Beta.Organization.SpendLimits.IncreaseRequests.Get(context.Background(), "slir_01AbCdEfGhIjKlMnOpQrSt")
900 if err != nil {
901 log.Fatal(err)
902 }
903
904 fmt.Printf("id: %s\n", increaseRequest.ID)
905 fmt.Printf("status: %s\n", increaseRequest.Status)
906 ```
907
908 ```java Java
909 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
910
911 var increaseRequest = client.beta().organization().spendLimits().increaseRequests()
912 .retrieve("slir_01AbCdEfGhIjKlMnOpQrSt");
913
914 IO.println("id: " + increaseRequest.id());
915 IO.println("status: " + increaseRequest.status().asString());
916 ```
917
918 ```php PHP
919 $client = new Client();
920
921 $increaseRequest = $client->beta->organization->spendLimits->increaseRequests->retrieve(
922 'slir_01AbCdEfGhIjKlMnOpQrSt',
923 );
924
925 echo "id: {$increaseRequest->id}\n";
926 echo "status: {$increaseRequest->status}\n";
927 ```
928
929 ```ruby Ruby
930 client = Anthropic::Client.new
931
932 increase_request = client.beta.organization.spend_limits.increase_requests.retrieve(
933 "slir_01AbCdEfGhIjKlMnOpQrSt"
934 )
935
936 puts "id: #{increase_request.id}"
937 puts "status: #{increase_request.status}"
938 ```
939</CodeGroup>
227940
228941### Approve an increase request
229942
from line 944
231944
232945For complete parameter details and response schemas, see [Approve a spend limit increase request](https://platform.claude.com/docs/en/api/beta/organization/spend_limits/increase_requests/approve) in the API reference.
233946
234```bash cURL
235curl --request POST "https://api.anthropic.com/v1/organizations/spend_limit_increase_requests/slir_01AbCdEfGhIjKlMnOpQrSt/approve" \
236 --header "content-type: application/json" \
237 --header "x-api-key: $ANTHROPIC_ADMIN_KEY" \
238 --header "anthropic-version: 2023-06-01" \
239 --data '{"amount": "75000", "suppress_notification": true}'
240```
947<CodeGroup>
948 ```bash cURL
949 curl -X POST "https://api.anthropic.com/v1/organizations/spend_limit_increase_requests/slir_01AbCdEfGhIjKlMnOpQrSt/approve" \
950 -H "content-type: application/json" \
951 -H "x-api-key: $ANTHROPIC_API_KEY" \
952 -H "anthropic-version: 2023-06-01" \
953 -d '{"amount": "75000", "suppress_notification": true}'
954 ```
955
956 ```bash CLI
957 ant beta:organization:spend-limits:increase-requests approve \
958 --spend-limit-increase-request-id slir_01AbCdEfGhIjKlMnOpQrSt \
959 --amount 75000 \
960 --suppress-notification
961 ```
962
963 ```python Python
964 client = anthropic.Anthropic()
965
966 increase_request = client.beta.organization.spend_limits.increase_requests.approve(
967 "slir_01AbCdEfGhIjKlMnOpQrSt", amount="75000", suppress_notification=True
968 )
969
970 print(f"id: {increase_request.id}")
971 print(f"status: {increase_request.status}")
972 ```
973
974 ```typescript TypeScript
975 const client = new Anthropic();
976
977 const increaseRequest = await client.beta.organization.spendLimits.increaseRequests.approve(
978 "slir_01AbCdEfGhIjKlMnOpQrSt",
979 {
980 amount: "75000",
981 suppress_notification: true
982 }
983 );
984
985 console.log(`id: ${increaseRequest.id}`);
986 console.log(`status: ${increaseRequest.status}`);
987 ```
988
989 ```csharp C#
990 AnthropicClient client = new();
991
992 var increaseRequest = await client.Beta.Organization.SpendLimits.IncreaseRequests.Approve(
993 "slir_01AbCdEfGhIjKlMnOpQrSt",
994 new() { Amount = "75000", SuppressNotification = true }
995 );
996
997 Console.WriteLine($"id: {increaseRequest.ID}");
998 Console.WriteLine($"status: {increaseRequest.Status.Raw()}");
999 ```
1000
1001 ```go Go
1002 client := anthropic.NewClient()
1003
1004 increaseRequest, err := client.Beta.Organization.SpendLimits.IncreaseRequests.Approve(
1005 context.Background(),
1006 "slir_01AbCdEfGhIjKlMnOpQrSt",
1007 anthropic.BetaOrganizationSpendLimitIncreaseRequestApproveParams{
1008 Amount: "75000",
1009 SuppressNotification: anthropic.Bool(true),
1010 },
1011 )
1012 if err != nil {
1013 log.Fatal(err)
1014 }
1015
1016 fmt.Printf("id: %s\n", increaseRequest.ID)
1017 fmt.Printf("status: %s\n", increaseRequest.Status)
1018 ```
1019
1020 ```java Java
1021 import com.anthropic.models.beta.organization.spendlimits.increaserequests.IncreaseRequestApproveParams;
1022
1023 void main() {
1024 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
1025
1026 var params = IncreaseRequestApproveParams.builder()
1027 .amount("75000")
1028 .suppressNotification(true)
1029 .build();
1030 var increaseRequest = client.beta().organization().spendLimits().increaseRequests()
1031 .approve("slir_01AbCdEfGhIjKlMnOpQrSt", params);
1032
1033 IO.println("id: " + increaseRequest.id());
1034 IO.println("status: " + increaseRequest.status().asString());
1035 }
1036 ```
1037
1038 ```php PHP
1039 $client = new Client();
1040
1041 $increaseRequest = $client->beta->organization->spendLimits->increaseRequests->approve(
1042 'slir_01AbCdEfGhIjKlMnOpQrSt',
1043 amount: '75000',
1044 suppressNotification: true,
1045 );
1046
1047 echo "id: {$increaseRequest->id}\n";
1048 echo "status: {$increaseRequest->status}\n";
1049 ```
1050
1051 ```ruby Ruby
1052 client = Anthropic::Client.new
1053
1054 increase_request = client.beta.organization.spend_limits.increase_requests.approve(
1055 "slir_01AbCdEfGhIjKlMnOpQrSt",
1056 amount: "75000",
1057 suppress_notification: true
1058 )
1059
1060 puts "id: #{increase_request.id}"
1061 puts "status: #{increase_request.status}"
1062 ```
1063</CodeGroup>
2411064
2421065### Deny an increase request
2431066
from line 1068
2451068
2461069For complete parameter details and response schemas, see [Deny a spend limit increase request](https://platform.claude.com/docs/en/api/beta/organization/spend_limits/increase_requests/deny) in the API reference.
2471070
248```bash cURL
249curl --request POST "https://api.anthropic.com/v1/organizations/spend_limit_increase_requests/slir_01AbCdEfGhIjKlMnOpQrSt/deny" \
250 --header "content-type: application/json" \
251 --header "x-api-key: $ANTHROPIC_ADMIN_KEY" \
252 --header "anthropic-version: 2023-06-01" \
253 --data '{"suppress_notification": true}'
254```
1071<CodeGroup>
1072 ```bash cURL
1073 curl -X POST "https://api.anthropic.com/v1/organizations/spend_limit_increase_requests/slir_01AbCdEfGhIjKlMnOpQrSt/deny" \
1074 -H "content-type: application/json" \
1075 -H "x-api-key: $ANTHROPIC_API_KEY" \
1076 -H "anthropic-version: 2023-06-01" \
1077 -d '{"suppress_notification": true}'
1078 ```
1079
1080 ```bash CLI
1081 ant beta:organization:spend-limits:increase-requests deny \
1082 --spend-limit-increase-request-id slir_01AbCdEfGhIjKlMnOpQrSt \
1083 --suppress-notification
1084 ```
1085
1086 ```python Python
1087 client = anthropic.Anthropic()
1088
1089 increase_request = client.beta.organization.spend_limits.increase_requests.deny(
1090 "slir_01AbCdEfGhIjKlMnOpQrSt", suppress_notification=True
1091 )
1092
1093 print(f"id: {increase_request.id}")
1094 print(f"status: {increase_request.status}")
1095 ```
1096
1097 ```typescript TypeScript
1098 const client = new Anthropic();
1099
1100 const increaseRequest = await client.beta.organization.spendLimits.increaseRequests.deny(
1101 "slir_01AbCdEfGhIjKlMnOpQrSt",
1102 {
1103 suppress_notification: true
1104 }
1105 );
1106
1107 console.log(`id: ${increaseRequest.id}`);
1108 console.log(`status: ${increaseRequest.status}`);
1109 ```
1110
1111 ```csharp C#
1112 AnthropicClient client = new();
1113
1114 var increaseRequest = await client.Beta.Organization.SpendLimits.IncreaseRequests.Deny(
1115 "slir_01AbCdEfGhIjKlMnOpQrSt",
1116 new() { SuppressNotification = true }
1117 );
1118
1119 Console.WriteLine($"id: {increaseRequest.ID}");
1120 Console.WriteLine($"status: {increaseRequest.Status.Raw()}");
1121 ```
1122
1123 ```go Go
1124 client := anthropic.NewClient()
1125
1126 increaseRequest, err := client.Beta.Organization.SpendLimits.IncreaseRequests.Deny(
1127 context.Background(),
1128 "slir_01AbCdEfGhIjKlMnOpQrSt",
1129 anthropic.BetaOrganizationSpendLimitIncreaseRequestDenyParams{
1130 SuppressNotification: anthropic.Bool(true),
1131 },
1132 )
1133 if err != nil {
1134 log.Fatal(err)
1135 }
1136
1137 fmt.Printf("id: %s\n", increaseRequest.ID)
1138 fmt.Printf("status: %s\n", increaseRequest.Status)
1139 ```
1140
1141 ```java Java
1142 import com.anthropic.models.beta.organization.spendlimits.increaserequests.IncreaseRequestDenyParams;
1143
1144 void main() {
1145 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
1146
1147 var params = IncreaseRequestDenyParams.builder()
1148 .suppressNotification(true)
1149 .build();
1150 var increaseRequest = client.beta().organization().spendLimits().increaseRequests()
1151 .deny("slir_01AbCdEfGhIjKlMnOpQrSt", params);
1152
1153 IO.println("id: " + increaseRequest.id());
1154 IO.println("status: " + increaseRequest.status().asString());
1155 }
1156 ```
1157
1158 ```php PHP
1159 $client = new Client();
1160
1161 $increaseRequest = $client->beta->organization->spendLimits->increaseRequests->deny(
1162 'slir_01AbCdEfGhIjKlMnOpQrSt',
1163 suppressNotification: true,
1164 );
1165
1166 echo "id: {$increaseRequest->id}\n";
1167 echo "status: {$increaseRequest->status}\n";
1168 ```
1169
1170 ```ruby Ruby
1171 client = Anthropic::Client.new
1172
1173 increase_request = client.beta.organization.spend_limits.increase_requests.deny(
1174 "slir_01AbCdEfGhIjKlMnOpQrSt",
1175 suppress_notification: true
1176 )
1177
1178 puts "id: #{increase_request.id}"
1179 puts "status: #{increase_request.status}"
1180 ```
1181</CodeGroup>
2551182
2561183## Example workflows
2571184
2581185Some of these workflows combine the Spend Limits API with the [Analytics APIs](https://platform.claude.com/docs/en/manage-claude/analytics-api) cost endpoints. The Analytics cost endpoints are designed for organization-wide spend reporting across a date range. `GET /spend_limits/effective` returns the cap that currently applies to each member. Start a sweep with Analytics to discover which members to look at, then read their current caps with `/effective`.
2591186
260Spend Limits endpoints require the `spend_limits` scopes and Analytics cost endpoints require `read:analytics`; see [Analytics APIs](https://platform.claude.com/docs/en/manage-claude/analytics-api) for how to provision access. All monetary values on both are decimal strings in minor units (cents). Both APIs paginate with an opaque cursor. Set an explicit `limit` and page through `next_page` until it's `null` to cover the whole organization.
1187Spend Limits endpoints require the `spend_limits` scopes and Analytics cost endpoints require `read:analytics`; see [Analytics APIs](https://platform.claude.com/docs/en/manage-claude/analytics-api) for how to provision access. The examples use one Admin API key that has the scopes of every API they call. A primary owner [selects these scopes when creating the key](https://platform.claude.com/docs/en/manage-claude/admin-api-keys#choose-scopes-for-a-claude-enterprise-key). All monetary values on both are decimal strings in minor units (cents). Both APIs paginate with an opaque cursor. Set an explicit `limit` and page through `next_page` until it's `null` to cover the whole organization.
2611188
2621189### Automate the increase-request review flow
2631190
from line 1192
2651192
26611931. List pending requests:
2671194
268 ```bash cURL
269 curl --globoff "https://api.anthropic.com/v1/organizations/spend_limit_increase_requests?status[]=pending&limit=100" \
270 --header "x-api-key: $ANTHROPIC_ADMIN_KEY" \
271 --header "anthropic-version: 2023-06-01"
272 ```
1195 <CodeGroup>
1196 ```bash cURL
1197 curl -g "https://api.anthropic.com/v1/organizations/spend_limit_increase_requests?status[]=pending&limit=100" \
1198 -H "x-api-key: $ANTHROPIC_API_KEY" \
1199 -H "anthropic-version: 2023-06-01"
1200 ```
1201
1202 ```bash CLI
1203 ant beta:organization:spend-limits:increase-requests list \
1204 --status pending \
1205 --limit 100
1206 ```
1207
1208 ```python Python
1209 client = anthropic.Anthropic()
1210
1211 increase_requests = client.beta.organization.spend_limits.increase_requests.list(
1212 status=["pending"], limit=100
1213 )
1214
1215 for increase_request in increase_requests:
1216 print(f"{increase_request.id}: {increase_request.status}")
1217 ```
1218
1219 ```typescript TypeScript
1220 const client = new Anthropic();
1221
1222 const increaseRequests = await client.beta.organization.spendLimits.increaseRequests.list({
1223 status: ["pending"],
1224 limit: 100
1225 });
1226
1227 for await (const increaseRequest of increaseRequests) {
1228 console.log(`${increaseRequest.id}: ${increaseRequest.status}`);
1229 }
1230 ```
1231
1232 ```csharp C#
1233 using Anthropic.Models.Beta.Organization.SpendLimits.IncreaseRequests;
1234
1235 AnthropicClient client = new();
1236
1237 var page = await client.Beta.Organization.SpendLimits.IncreaseRequests.List(
1238 new() { Status = [BetaSpendLimitIncreaseRequestStatus.Pending], Limit = 100 }
1239 );
1240
1241 await foreach (var increaseRequest in page.Paginate())
1242 {
1243 Console.WriteLine($"{increaseRequest.ID}: {increaseRequest.Status.Raw()}");
1244 }
1245 ```
1246
1247 ```go Go
1248 client := anthropic.NewClient()
1249
1250 increaseRequests := client.Beta.Organization.SpendLimits.IncreaseRequests.ListAutoPaging(context.Background(), anthropic.BetaOrganizationSpendLimitIncreaseRequestListParams{
1251 Status: []anthropic.BetaSpendLimitIncreaseRequestStatus{anthropic.BetaSpendLimitIncreaseRequestStatusPending},
1252 Limit: anthropic.Int(100),
1253 })
1254
1255 for increaseRequests.Next() {
1256 increaseRequest := increaseRequests.Current()
1257 fmt.Printf("%s: %s\n", increaseRequest.ID, increaseRequest.Status)
1258 }
1259 if err := increaseRequests.Err(); err != nil {
1260 log.Fatal(err)
1261 }
1262 ```
1263
1264 ```java Java
1265 import com.anthropic.models.beta.organization.spendlimits.increaserequests.BetaSpendLimitIncreaseRequestStatus;
1266 import com.anthropic.models.beta.organization.spendlimits.increaserequests.IncreaseRequestListParams;
1267
1268 void main() {
1269 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
1270
1271 var params = IncreaseRequestListParams.builder()
1272 .addStatus(BetaSpendLimitIncreaseRequestStatus.PENDING)
1273 .limit(100)
1274 .build();
1275 var increaseRequests = client.beta().organization().spendLimits().increaseRequests().list(params);
1276
1277 for (var increaseRequest : increaseRequests.autoPager()) {
1278 IO.println(increaseRequest.id() + ": " + increaseRequest.status().asString());
1279 }
1280 }
1281 ```
1282
1283 ```php PHP
1284 $client = new Client();
1285
1286 $increaseRequests = $client->beta->organization->spendLimits->increaseRequests->list(
1287 status: ['pending'],
1288 limit: 100,
1289 );
1290
1291 foreach ($increaseRequests->pagingEachItem() as $increaseRequest) {
1292 echo "{$increaseRequest->id}: {$increaseRequest->status}\n";
1293 }
1294 ```
1295
1296 ```ruby Ruby
1297 client = Anthropic::Client.new
1298
1299 page = client.beta.organization.spend_limits.increase_requests.list(status: [:pending], limit: 100)
1300
1301 page.auto_paging_each do |increase_request|
1302 puts "#{increase_request.id}: #{increase_request.status}"
1303 end
1304 ```
1305 </CodeGroup>
2731306
2741307 Each request carries the requester's `actor.user_id` and a live `spend_summary` with their current effective `amount` and `period_to_date_spend`, enough to decide without a separate lookup.
2751308
from line 1310
2771310
27813113. Resolve each request. To approve, supply the new cap:
2791312
280 ```bash cURL
281 curl --request POST "https://api.anthropic.com/v1/organizations/spend_limit_increase_requests/{id}/approve" \
282 --header "content-type: application/json" \
283 --header "x-api-key: $ANTHROPIC_ADMIN_KEY" \
284 --header "anthropic-version: 2023-06-01" \
285 --data '{"amount": "75000", "suppress_notification": true}'
286 ```
287
288 To deny, `POST` to `.../{id}/deny` instead. Pass `suppress_notification: true` when your own system notifies the requester.
1313 <CodeGroup>
1314 ```bash cURL
1315 curl -X POST "https://api.anthropic.com/v1/organizations/spend_limit_increase_requests/slir_01AbCdEfGhIjKlMnOpQrSt/approve" \
1316 -H "content-type: application/json" \
1317 -H "x-api-key: $ANTHROPIC_API_KEY" \
1318 -H "anthropic-version: 2023-06-01" \
1319 -d '{"amount": "75000", "suppress_notification": true}'
1320 ```
1321
1322 ```bash CLI
1323 ant beta:organization:spend-limits:increase-requests approve \
1324 --spend-limit-increase-request-id slir_01AbCdEfGhIjKlMnOpQrSt \
1325 --amount 75000 \
1326 --suppress-notification
1327 ```
1328
1329 ```python Python
1330 client = anthropic.Anthropic()
1331
1332 increase_request = client.beta.organization.spend_limits.increase_requests.approve(
1333 "slir_01AbCdEfGhIjKlMnOpQrSt", amount="75000", suppress_notification=True
1334 )
1335
1336 print(f"id: {increase_request.id}")
1337 print(f"status: {increase_request.status}")
1338 ```
1339
1340 ```typescript TypeScript
1341 const client = new Anthropic();
1342
1343 const increaseRequest = await client.beta.organization.spendLimits.increaseRequests.approve(
1344 "slir_01AbCdEfGhIjKlMnOpQrSt",
1345 {
1346 amount: "75000",
1347 suppress_notification: true
1348 }
1349 );
1350
1351 console.log(`id: ${increaseRequest.id}`);
1352 console.log(`status: ${increaseRequest.status}`);
1353 ```
1354
1355 ```csharp C#
1356 AnthropicClient client = new();
1357
1358 var increaseRequest = await client.Beta.Organization.SpendLimits.IncreaseRequests.Approve(
1359 "slir_01AbCdEfGhIjKlMnOpQrSt",
1360 new() { Amount = "75000", SuppressNotification = true }
1361 );
1362
1363 Console.WriteLine($"id: {increaseRequest.ID}");
1364 Console.WriteLine($"status: {increaseRequest.Status.Raw()}");
1365 ```
1366
1367 ```go Go
1368 client := anthropic.NewClient()
1369
1370 increaseRequest, err := client.Beta.Organization.SpendLimits.IncreaseRequests.Approve(
1371 context.Background(),
1372 "slir_01AbCdEfGhIjKlMnOpQrSt",
1373 anthropic.BetaOrganizationSpendLimitIncreaseRequestApproveParams{
1374 Amount: "75000",
1375 SuppressNotification: anthropic.Bool(true),
1376 },
1377 )
1378 if err != nil {
1379 log.Fatal(err)
1380 }
1381
1382 fmt.Printf("id: %s\n", increaseRequest.ID)
1383 fmt.Printf("status: %s\n", increaseRequest.Status)
1384 ```
1385
1386 ```java Java
1387 import com.anthropic.models.beta.organization.spendlimits.increaserequests.IncreaseRequestApproveParams;
1388
1389 void main() {
1390 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
1391
1392 var params = IncreaseRequestApproveParams.builder()
1393 .amount("75000")
1394 .suppressNotification(true)
1395 .build();
1396 var increaseRequest = client.beta().organization().spendLimits().increaseRequests()
1397 .approve("slir_01AbCdEfGhIjKlMnOpQrSt", params);
1398
1399 IO.println("id: " + increaseRequest.id());
1400 IO.println("status: " + increaseRequest.status().asString());
1401 }
1402 ```
1403
1404 ```php PHP
1405 $client = new Client();
1406
1407 $increaseRequest = $client->beta->organization->spendLimits->increaseRequests->approve(
1408 'slir_01AbCdEfGhIjKlMnOpQrSt',
1409 amount: '75000',
1410 suppressNotification: true,
1411 );
1412
1413 echo "id: {$increaseRequest->id}\n";
1414 echo "status: {$increaseRequest->status}\n";
1415 ```
1416
1417 ```ruby Ruby
1418 client = Anthropic::Client.new
1419
1420 increase_request = client.beta.organization.spend_limits.increase_requests.approve(
1421 "slir_01AbCdEfGhIjKlMnOpQrSt",
1422 amount: "75000",
1423 suppress_notification: true
1424 )
1425
1426 puts "id: #{increase_request.id}"
1427 puts "status: #{increase_request.status}"
1428 ```
1429 </CodeGroup>
1430
1431 To deny, call the [deny endpoint](https://platform.claude.com/docs/en/manage-claude/spend-limits-api#deny-an-increase-request) with the same ID instead. Pass `suppress_notification: true` when your own system notifies the requester.
2891432
2901433### Identify members close to their spend limit
2911434
from line 1436
2931436
29414371. Pull each member's month-to-date spend from the Analytics API (one row per member, highest spend first by default):
2951438
296 ```bash cURL
297 curl "https://api.anthropic.com/v1/organizations/analytics/user_cost_report?starting_at=2026-06-01T00:00:00Z&limit=1000" \
298 --header "x-api-key: $ANALYTICS_API_KEY" \
299 --header "anthropic-version: 2023-06-01"
300 ```
301
302 Each row carries `actor.user_id`, `actor.email`, and `amount` (the member's spend in cents). Page through `next_page` to cover the whole organization.
1439 <CodeGroup>
1440 ```bash cURL
1441 curl "https://api.anthropic.com/v1/organizations/analytics/user_cost_report?starting_at=2026-06-01T00:00:00Z&limit=1000" \
1442 -H "x-api-key: $ANTHROPIC_API_KEY" \
1443 -H "anthropic-version: 2023-06-01"
1444 ```
1445
1446 ```bash CLI
1447 ant beta:organization:analytics:user-cost-report list \
1448 --starting-at 2026-06-01T00:00:00Z \
1449 --limit 1000
1450 ```
1451
1452 ```python Python
1453 client = anthropic.Anthropic()
1454
1455 cost_rows = client.beta.organization.analytics.user_cost_report.list(
1456 starting_at="2026-06-01T00:00:00Z", limit=1000
1457 )
1458
1459 for cost_row in cost_rows:
1460 print(f"{cost_row.actor.user_id}: {cost_row.amount}")
1461 ```
1462
1463 ```typescript TypeScript
1464 const client = new Anthropic();
1465
1466 const costRows = await client.beta.organization.analytics.userCostReport.list({
1467 starting_at: "2026-06-01T00:00:00Z",
1468 limit: 1000
1469 });
1470
1471 for await (const costRow of costRows) {
1472 console.log(`${costRow.actor.user_id}: ${costRow.amount}`);
1473 }
1474 ```
1475
1476 ```csharp C#
1477 AnthropicClient client = new();
1478
1479 var page = await client.Beta.Organization.Analytics.UserCostReport.List(
1480 new()
1481 {
1482 StartingAt = DateTimeOffset.Parse("2026-06-01T00:00:00Z"),
1483 Limit = 1000,
1484 }
1485 );
1486
1487 await foreach (var costRow in page.Paginate())
1488 {
1489 Console.WriteLine($"{costRow.Actor.UserID}: {costRow.Amount}");
1490 }
1491 ```
1492
1493 ```go Go
1494 client := anthropic.NewClient()
1495
1496 costRows := client.Beta.Organization.Analytics.UserCostReport.ListAutoPaging(context.Background(), anthropic.BetaOrganizationAnalyticsUserCostReportListParams{
1497 StartingAt: time.Date(2026, time.June, 1, 0, 0, 0, 0, time.UTC),
1498 Limit: anthropic.Int(1000),
1499 })
1500
1501 for costRows.Next() {
1502 costRow := costRows.Current()
1503 fmt.Printf("%s: %s\n", costRow.Actor.UserID, costRow.Amount)
1504 }
1505 if err := costRows.Err(); err != nil {
1506 log.Fatal(err)
1507 }
1508 ```
1509
1510 ```java Java
1511 import com.anthropic.models.beta.organization.analytics.usercostreport.UserCostReportListParams;
1512 import java.time.OffsetDateTime;
1513
1514 void main() {
1515 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
1516
1517 var params = UserCostReportListParams.builder()
1518 .startingAt(OffsetDateTime.parse("2026-06-01T00:00:00Z"))
1519 .limit(1000)
1520 .build();
1521 var costRows = client.beta().organization().analytics().userCostReport().list(params);
1522
1523 for (var costRow : costRows.autoPager()) {
1524 IO.println(costRow.actor().userId() + ": " + costRow.amount());
1525 }
1526 }
1527 ```
1528
1529 ```php PHP
1530 $client = new Client();
1531
1532 $costRows = $client->beta->organization->analytics->userCostReport->list(
1533 startingAt: new \DateTimeImmutable('2026-06-01T00:00:00Z'),
1534 limit: 1000,
1535 );
1536
1537 foreach ($costRows->pagingEachItem() as $costRow) {
1538 echo "{$costRow->actor->userID}: {$costRow->amount}\n";
1539 }
1540 ```
1541
1542 ```ruby Ruby
1543 client = Anthropic::Client.new
1544
1545 page = client.beta.organization.analytics.user_cost_report.list(
1546 starting_at: Time.utc(2026, 6, 1),
1547 limit: 1000
1548 )
1549
1550 page.auto_paging_each do |cost_row|
1551 puts "#{cost_row.actor.user_id}: #{cost_row.amount}"
1552 end
1553 ```
1554 </CodeGroup>
1555
1556 Each row contains `actor.user_id`, `actor.email_address`, and `amount` (the member's spend in cents). Page through `next_page` to cover the whole organization.
3031557
30415582. For the top spenders (or everyone above a dollar threshold), fetch effective caps in batches:
3051559
306 ```bash cURL
307 curl --globoff "https://api.anthropic.com/v1/organizations/spend_limits/effective?user_ids[]=user_01Ab...&user_ids[]=user_01Cd...&limit=100" \
308 --header "x-api-key: $ANTHROPIC_ADMIN_KEY" \
309 --header "anthropic-version: 2023-06-01"
310 ```
1560 <CodeGroup>
1561 ```bash cURL
1562 curl -g "https://api.anthropic.com/v1/organizations/spend_limits/effective?user_ids[]=user_01AbCdEfGh&user_ids[]=user_01JkLmNoPq&limit=100" \
1563 -H "x-api-key: $ANTHROPIC_API_KEY" \
1564 -H "anthropic-version: 2023-06-01"
1565 ```
1566
1567 ```bash CLI
1568 ant beta:organization:spend-limits:effective list \
1569 --user-id user_01AbCdEfGh \
1570 --user-id user_01JkLmNoPq \
1571 --limit 100
1572 ```
1573
1574 ```python Python
1575 client = anthropic.Anthropic()
1576
1577 effective_limits = client.beta.organization.spend_limits.effective.list(
1578 user_ids=["user_01AbCdEfGh", "user_01JkLmNoPq"], limit=100
1579 )
1580
1581 for effective_limit in effective_limits:
1582 scope = effective_limit.scope
1583 if scope.type == "user":
1584 amount = effective_limit.amount or "unlimited"
1585 print(f"{scope.user_id}: {effective_limit.period_to_date_spend} of {amount}")
1586 ```
1587
1588 ```typescript TypeScript
1589 const client = new Anthropic();
1590
1591 const effectiveLimits = await client.beta.organization.spendLimits.effective.list({
1592 user_ids: ["user_01AbCdEfGh", "user_01JkLmNoPq"],
1593 limit: 100
1594 });
1595
1596 for await (const effectiveLimit of effectiveLimits) {
1597 const { scope } = effectiveLimit;
1598 if (scope.type === "user") {
1599 const amount = effectiveLimit.amount ?? "unlimited";
1600 console.log(`${scope.user_id}: ${effectiveLimit.period_to_date_spend} of ${amount}`);
1601 }
1602 }
1603 ```
1604
1605 ```csharp C#
1606 AnthropicClient client = new();
1607
1608 var page = await client.Beta.Organization.SpendLimits.Effective.List(
1609 new() { UserIds = ["user_01AbCdEfGh", "user_01JkLmNoPq"], Limit = 100 }
1610 );
1611
1612 await foreach (var effectiveLimit in page.Paginate())
1613 {
1614 if (effectiveLimit.Scope.TryPickBetaSpendLimitUser(out var userScope))
1615 {
1616 var amount = effectiveLimit.Amount ?? "unlimited";
1617 Console.WriteLine($"{userScope.UserID}: {effectiveLimit.PeriodToDateSpend} of {amount}");
1618 }
1619 }
1620 ```
1621
1622 ```go Go
1623 client := anthropic.NewClient()
1624
1625 effectiveLimits := client.Beta.Organization.SpendLimits.Effective.ListAutoPaging(context.Background(), anthropic.BetaOrganizationSpendLimitEffectiveListParams{
1626 UserIDs: []string{"user_01AbCdEfGh", "user_01JkLmNoPq"},
1627 Limit: anthropic.Int(100),
1628 })
1629
1630 for effectiveLimits.Next() {
1631 effectiveLimit := effectiveLimits.Current()
1632 if userScope, ok := effectiveLimit.Scope.AsAny().(anthropic.BetaSpendLimitUserScope); ok {
1633 amount := effectiveLimit.Amount
1634 if !effectiveLimit.JSON.Amount.Valid() {
1635 amount = "unlimited"
1636 }
1637 fmt.Printf("%s: %s of %s\n", userScope.UserID, effectiveLimit.PeriodToDateSpend, amount)
1638 }
1639 }
1640 if err := effectiveLimits.Err(); err != nil {
1641 log.Fatal(err)
1642 }
1643 ```
1644
1645 ```java Java
1646 import com.anthropic.models.beta.organization.spendlimits.effective.EffectiveListParams;
1647
1648 void main() {
1649 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
1650
1651 var params = EffectiveListParams.builder()
1652 .addUserId("user_01AbCdEfGh")
1653 .addUserId("user_01JkLmNoPq")
1654 .limit(100)
1655 .build();
1656 var effectiveLimits = client.beta().organization().spendLimits().effective().list(params);
1657
1658 for (var effectiveLimit : effectiveLimits.autoPager()) {
1659 var amount = effectiveLimit.amount().orElse("unlimited");
1660 effectiveLimit.scope().user().ifPresent(userScope ->
1661 IO.println(userScope.userId() + ": " + effectiveLimit.periodToDateSpend() + " of " + amount)
1662 );
1663 }
1664 }
1665 ```
1666
1667 ```php PHP
1668 use Anthropic\Beta\Organization\SpendLimits\SpendLimitUserScope;
1669 // ...
1670
1671 $client = new Client();
1672
1673 $effectiveLimits = $client->beta->organization->spendLimits->effective->list(
1674 userIDs: ['user_01AbCdEfGh', 'user_01JkLmNoPq'],
1675 limit: 100,
1676 );
1677
1678 foreach ($effectiveLimits->pagingEachItem() as $effectiveLimit) {
1679 $scope = $effectiveLimit->scope;
1680 if ($scope instanceof SpendLimitUserScope) {
1681 $amount = $effectiveLimit->amount ?? 'unlimited';
1682 echo "{$scope->userID}: {$effectiveLimit->periodToDateSpend} of {$amount}\n";
1683 }
1684 }
1685 ```
1686
1687 ```ruby Ruby
1688 client = Anthropic::Client.new
1689
1690 page = client.beta.organization.spend_limits.effective.list(
1691 user_ids: ["user_01AbCdEfGh", "user_01JkLmNoPq"],
1692 limit: 100
1693 )
1694
1695 page.auto_paging_each do |effective_limit|
1696 scope = effective_limit.scope
1697 if scope.is_a?(Anthropic::Models::Beta::Organization::BetaSpendLimitUserScope)
1698 amount = effective_limit.amount || "unlimited"
1699 puts "#{scope.user_id}: #{effective_limit.period_to_date_spend} of #{amount}"
1700 end
1701 end
1702 ```
1703 </CodeGroup>
3111704
3121705 Each row returns the cap as `amount` (`null` = unlimited, `"0"` = included usage only) alongside `period_to_date_spend`.
3131706
from line 1714
3211714
32217151. Pull per-member daily cost for the trailing two weeks from the Analytics API:
3231716
324 ```bash cURL
325 curl "https://api.anthropic.com/v1/organizations/analytics/user_cost_report?starting_at=2026-06-09T00:00:00Z&ending_at=2026-06-23T00:00:00Z&bucket_width=1d&limit=1000" \
326 --header "x-api-key: $ANALYTICS_API_KEY" \
327 --header "anthropic-version: 2023-06-01"
328 ```
329
330 With `bucket_width` set, each member spans one row per day with usage; page through `next_page` to collect every member's full series.
1717 <CodeGroup>
1718 ```bash cURL
1719 curl "https://api.anthropic.com/v1/organizations/analytics/user_cost_report?starting_at=2026-06-09T00:00:00Z&ending_at=2026-06-23T00:00:00Z&bucket_width=1d&limit=1000" \
1720 -H "x-api-key: $ANTHROPIC_API_KEY" \
1721 -H "anthropic-version: 2023-06-01"
1722 ```
1723
1724 ```bash CLI
1725 ant beta:organization:analytics:user-cost-report list \
1726 --starting-at 2026-06-09T00:00:00Z \
1727 --ending-at 2026-06-23T00:00:00Z \
1728 --bucket-width 1d \
1729 --limit 1000
1730 ```
1731
1732 ```python Python
1733 client = anthropic.Anthropic()
1734
1735 cost_rows = client.beta.organization.analytics.user_cost_report.list(
1736 starting_at="2026-06-09T00:00:00Z",
1737 ending_at="2026-06-23T00:00:00Z",
1738 bucket_width="1d",
1739 limit=1000,
1740 )
1741
1742 for cost_row in cost_rows:
1743 print(f"{cost_row.actor.user_id} {cost_row.starting_at}: {cost_row.amount}")
1744 ```
1745
1746 ```typescript TypeScript
1747 const client = new Anthropic();
1748
1749 const costRows = await client.beta.organization.analytics.userCostReport.list({
1750 starting_at: "2026-06-09T00:00:00Z",
1751 ending_at: "2026-06-23T00:00:00Z",
1752 bucket_width: "1d",
1753 limit: 1000
1754 });
1755
1756 for await (const costRow of costRows) {
1757 console.log(`${costRow.actor.user_id} ${costRow.starting_at}: ${costRow.amount}`);
1758 }
1759 ```
1760
1761 ```csharp C#
1762 using Anthropic.Models.Beta.Organization.Analytics.UserCostReport;
1763
1764 AnthropicClient client = new();
1765
1766 var page = await client.Beta.Organization.Analytics.UserCostReport.List(
1767 new()
1768 {
1769 StartingAt = DateTimeOffset.Parse("2026-06-09T00:00:00Z"),
1770 EndingAt = DateTimeOffset.Parse("2026-06-23T00:00:00Z"),
1771 BucketWidth = BucketWidth.Day,
1772 Limit = 1000,
1773 }
1774 );
1775
1776 await foreach (var costRow in page.Paginate())
1777 {
1778 Console.WriteLine($"{costRow.Actor.UserID} {costRow.StartingAt}: {costRow.Amount}");
1779 }
1780 ```
1781
1782 ```go Go
1783 client := anthropic.NewClient()
1784
1785 costRows := client.Beta.Organization.Analytics.UserCostReport.ListAutoPaging(context.Background(), anthropic.BetaOrganizationAnalyticsUserCostReportListParams{
1786 StartingAt: time.Date(2026, time.June, 9, 0, 0, 0, 0, time.UTC),
1787 EndingAt: anthropic.Time(time.Date(2026, time.June, 23, 0, 0, 0, 0, time.UTC)),
1788 BucketWidth: anthropic.BetaOrganizationAnalyticsUserCostReportListParamsBucketWidthDay,
1789 Limit: anthropic.Int(1000),
1790 })
1791
1792 for costRows.Next() {
1793 costRow := costRows.Current()
1794 fmt.Printf("%s %s: %s\n", costRow.Actor.UserID, costRow.StartingAt, costRow.Amount)
1795 }
1796 if err := costRows.Err(); err != nil {
1797 log.Fatal(err)
1798 }
1799 ```
1800
1801 ```java Java
1802 import com.anthropic.models.beta.organization.analytics.usercostreport.UserCostReportListParams;
1803 import java.time.OffsetDateTime;
1804
1805 void main() {
1806 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
1807
1808 var params = UserCostReportListParams.builder()
1809 .startingAt(OffsetDateTime.parse("2026-06-09T00:00:00Z"))
1810 .endingAt(OffsetDateTime.parse("2026-06-23T00:00:00Z"))
1811 .bucketWidth(UserCostReportListParams.BucketWidth.DAY)
1812 .limit(1000)
1813 .build();
1814 var costRows = client.beta().organization().analytics().userCostReport().list(params);
1815
1816 for (var costRow : costRows.autoPager()) {
1817 IO.println(costRow.actor().userId() + " " + costRow.startingAt().orElseThrow() + ": " + costRow.amount());
1818 }
1819 }
1820 ```
1821
1822 ```php PHP
1823 $client = new Client();
1824
1825 $costRows = $client->beta->organization->analytics->userCostReport->list(
1826 startingAt: new \DateTimeImmutable('2026-06-09T00:00:00Z'),
1827 endingAt: new \DateTimeImmutable('2026-06-23T00:00:00Z'),
1828 bucketWidth: '1d',
1829 limit: 1000,
1830 );
1831
1832 foreach ($costRows->pagingEachItem() as $costRow) {
1833 $startingAt = $costRow->startingAt?->format(\DateTimeInterface::ATOM);
1834 echo "{$costRow->actor->userID} {$startingAt}: {$costRow->amount}\n";
1835 }
1836 ```
1837
1838 ```ruby Ruby
1839 client = Anthropic::Client.new
1840
1841 page = client.beta.organization.analytics.user_cost_report.list(
1842 starting_at: Time.utc(2026, 6, 9),
1843 ending_at: Time.utc(2026, 6, 23),
1844 bucket_width: :"1d",
1845 limit: 1000
1846 )
1847
1848 page.auto_paging_each do |cost_row|
1849 puts "#{cost_row.actor.user_id} #{cost_row.starting_at}: #{cost_row.amount}"
1850 end
1851 ```
1852 </CodeGroup>
1853
1854 With `bucket_width` set, each member spans one row per day with usage. Page through `next_page` to collect every member's full series.
3311855
33218562. Group rows by `actor.user_id`. For each member, sum the most recent seven days and the prior seven days. Flag members whose recent week exceeds the prior week by your chosen multiple (for example, three). Recent-day cost is provisional and can be revised upward; for repeatable comparisons, set `ending_at` at or before a previously returned `data_refreshed_at` (see [Data availability and freshness](https://platform.claude.com/docs/en/manage-claude/analytics-api#data-availability-and-freshness)).
3331857
from line 1863
3391863
34018641. Read the member's current cap, and record it for the rollback:
3411865
342 ```bash cURL
343 curl --globoff "https://api.anthropic.com/v1/organizations/spend_limits/effective?user_ids[]=user_01AbCdEfGh&period[]=monthly" \
344 --header "x-api-key: $ANTHROPIC_ADMIN_KEY" \
345 --header "anthropic-version: 2023-06-01"
346 ```
1866 <CodeGroup>
1867 ```bash cURL
1868 curl -g "https://api.anthropic.com/v1/organizations/spend_limits/effective?user_ids[]=user_01AbCdEfGh&period[]=monthly" \
1869 -H "x-api-key: $ANTHROPIC_API_KEY" \
1870 -H "anthropic-version: 2023-06-01"
1871 ```
1872
1873 ```bash CLI
1874 ant beta:organization:spend-limits:effective list \
1875 --user-id user_01AbCdEfGh \
1876 --period monthly
1877 ```
1878
1879 ```python Python
1880 client = anthropic.Anthropic()
1881
1882 effective_limits = client.beta.organization.spend_limits.effective.list(
1883 user_ids=["user_01AbCdEfGh"], period=["monthly"]
1884 )
1885
1886 for effective_limit in effective_limits:
1887 scope = effective_limit.scope
1888 if scope.type == "user":
1889 amount = effective_limit.amount or "unlimited"
1890 print(f"{scope.user_id}: {effective_limit.period_to_date_spend} of {amount}")
1891 ```
1892
1893 ```typescript TypeScript
1894 const client = new Anthropic();
1895
1896 const effectiveLimits = await client.beta.organization.spendLimits.effective.list({
1897 user_ids: ["user_01AbCdEfGh"],
1898 period: ["monthly"]
1899 });
1900
1901 for await (const effectiveLimit of effectiveLimits) {
1902 const { scope } = effectiveLimit;
1903 if (scope.type === "user") {
1904 const amount = effectiveLimit.amount ?? "unlimited";
1905 console.log(`${scope.user_id}: ${effectiveLimit.period_to_date_spend} of ${amount}`);
1906 }
1907 }
1908 ```
1909
1910 ```csharp C#
1911 using Anthropic.Models.Beta.Organization.SpendLimits.Effective;
1912
1913 AnthropicClient client = new();
1914
1915 var page = await client.Beta.Organization.SpendLimits.Effective.List(
1916 new() { UserIds = ["user_01AbCdEfGh"], Period = [Period.Monthly] }
1917 );
1918
1919 await foreach (var effectiveLimit in page.Paginate())
1920 {
1921 if (effectiveLimit.Scope.TryPickBetaSpendLimitUser(out var userScope))
1922 {
1923 var amount = effectiveLimit.Amount ?? "unlimited";
1924 Console.WriteLine($"{userScope.UserID}: {effectiveLimit.PeriodToDateSpend} of {amount}");
1925 }
1926 }
1927 ```
1928
1929 ```go Go
1930 client := anthropic.NewClient()
1931
1932 effectiveLimits := client.Beta.Organization.SpendLimits.Effective.ListAutoPaging(context.Background(), anthropic.BetaOrganizationSpendLimitEffectiveListParams{
1933 UserIDs: []string{"user_01AbCdEfGh"},
1934 Period: []string{"monthly"},
1935 })
1936
1937 for effectiveLimits.Next() {
1938 effectiveLimit := effectiveLimits.Current()
1939 if userScope, ok := effectiveLimit.Scope.AsAny().(anthropic.BetaSpendLimitUserScope); ok {
1940 amount := effectiveLimit.Amount
1941 if !effectiveLimit.JSON.Amount.Valid() {
1942 amount = "unlimited"
1943 }
1944 fmt.Printf("%s: %s of %s\n", userScope.UserID, effectiveLimit.PeriodToDateSpend, amount)
1945 }
1946 }
1947 if err := effectiveLimits.Err(); err != nil {
1948 log.Fatal(err)
1949 }
1950 ```
1951
1952 ```java Java
1953 import com.anthropic.models.beta.organization.spendlimits.effective.EffectiveListParams;
1954
1955 void main() {
1956 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
1957
1958 var params = EffectiveListParams.builder()
1959 .addUserId("user_01AbCdEfGh")
1960 .addPeriod(EffectiveListParams.Period.MONTHLY)
1961 .build();
1962 var effectiveLimits = client.beta().organization().spendLimits().effective().list(params);
1963
1964 for (var effectiveLimit : effectiveLimits.autoPager()) {
1965 var amount = effectiveLimit.amount().orElse("unlimited");
1966 effectiveLimit.scope().user().ifPresent(userScope ->
1967 IO.println(userScope.userId() + ": " + effectiveLimit.periodToDateSpend() + " of " + amount)
1968 );
1969 }
1970 }
1971 ```
1972
1973 ```php PHP
1974 use Anthropic\Beta\Organization\SpendLimits\SpendLimitUserScope;
1975 // ...
1976
1977 $client = new Client();
1978
1979 $effectiveLimits = $client->beta->organization->spendLimits->effective->list(
1980 userIDs: ['user_01AbCdEfGh'],
1981 period: ['monthly'],
1982 );
1983
1984 foreach ($effectiveLimits->pagingEachItem() as $effectiveLimit) {
1985 $scope = $effectiveLimit->scope;
1986 if ($scope instanceof SpendLimitUserScope) {
1987 $amount = $effectiveLimit->amount ?? 'unlimited';
1988 echo "{$scope->userID}: {$effectiveLimit->periodToDateSpend} of {$amount}\n";
1989 }
1990 }
1991 ```
1992
1993 ```ruby Ruby
1994 client = Anthropic::Client.new
1995
1996 page = client.beta.organization.spend_limits.effective.list(
1997 user_ids: ["user_01AbCdEfGh"],
1998 period: [:monthly]
1999 )
2000
2001 page.auto_paging_each do |effective_limit|
2002 scope = effective_limit.scope
2003 if scope.is_a?(Anthropic::Models::Beta::Organization::BetaSpendLimitUserScope)
2004 amount = effective_limit.amount || "unlimited"
2005 puts "#{scope.user_id}: #{effective_limit.period_to_date_spend} of #{amount}"
2006 end
2007 end
2008 ```
2009 </CodeGroup>
3472010
34820112. Raise the cap:
3492012
350 ```bash cURL
351 curl --request POST "https://api.anthropic.com/v1/organizations/spend_limits" \
352 --header "content-type: application/json" \
353 --header "x-api-key: $ANTHROPIC_ADMIN_KEY" \
354 --header "anthropic-version: 2023-06-01" \
355 --data '{"scope": {"type": "user", "user_id": "user_01AbCdEfGh"}, "amount": "500000", "period": "monthly"}'
356 ```
2013 <CodeGroup>
2014 ```bash cURL
2015 curl -X POST "https://api.anthropic.com/v1/organizations/spend_limits" \
2016 -H "content-type: application/json" \
2017 -H "x-api-key: $ANTHROPIC_API_KEY" \
2018 -H "anthropic-version: 2023-06-01" \
2019 -d '{"scope": {"type": "user", "user_id": "user_01AbCdEfGh"}, "amount": "500000", "period": "monthly"}'
2020 ```
2021
2022 ```bash CLI
2023 ant beta:organization:spend-limits set \
2024 --scope '{type: user, user_id: user_01AbCdEfGh}' \
2025 --amount 500000 \
2026 --period monthly
2027 ```
2028
2029 ```python Python
2030 client = anthropic.Anthropic()
2031
2032 spend_limit = client.beta.organization.spend_limits.set(
2033 scope={"type": "user", "user_id": "user_01AbCdEfGh"},
2034 amount="500000",
2035 period="monthly",
2036 )
2037
2038 print(f"id: {spend_limit.id}")
2039 print(f"amount: {spend_limit.amount}")
2040 ```
2041
2042 ```typescript TypeScript
2043 const client = new Anthropic();
2044
2045 const spendLimit = await client.beta.organization.spendLimits.set({
2046 scope: { type: "user", user_id: "user_01AbCdEfGh" },
2047 amount: "500000",
2048 period: "monthly"
2049 });
2050
2051 console.log(`id: ${spendLimit.id}`);
2052 console.log(`amount: ${spendLimit.amount}`);
2053 ```
2054
2055 ```csharp C#
2056 using Anthropic.Models.Beta.Organization.SpendLimits;
2057
2058 AnthropicClient client = new();
2059
2060 var spendLimit = await client.Beta.Organization.SpendLimits.Set(
2061 new()
2062 {
2063 Scope = new BetaSpendLimitUserScope("user_01AbCdEfGh"),
2064 Amount = "500000",
2065 Period = BetaSpendLimitPeriod.Monthly,
2066 }
2067 );
2068
2069 Console.WriteLine($"id: {spendLimit.ID}");
2070 Console.WriteLine($"amount: {spendLimit.Amount}");
2071 ```
2072
2073 ```go Go
2074 client := anthropic.NewClient()
2075
2076 spendLimit, err := client.Beta.Organization.SpendLimits.Set(context.Background(), anthropic.BetaOrganizationSpendLimitSetParams{
2077 Scope: anthropic.BetaOrganizationSpendLimitSetParamsScopeUnion{
2078 OfUser: &anthropic.BetaSpendLimitUserScopeParam{UserID: "user_01AbCdEfGh"},
2079 },
2080 Amount: anthropic.String("500000"),
2081 Period: anthropic.BetaSpendLimitPeriodMonthly,
2082 })
2083 if err != nil {
2084 log.Fatal(err)
2085 }
2086
2087 fmt.Printf("id: %s\n", spendLimit.ID)
2088 fmt.Printf("amount: %s\n", spendLimit.Amount)
2089 ```
2090
2091 ```java Java
2092 import com.anthropic.models.beta.organization.spendlimits.BetaSpendLimitPeriod;
2093 import com.anthropic.models.beta.organization.spendlimits.SpendLimitSetParams;
2094
2095 void main() {
2096 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
2097
2098 var params = SpendLimitSetParams.builder()
2099 .userScope("user_01AbCdEfGh")
2100 .amount("500000")
2101 .period(BetaSpendLimitPeriod.MONTHLY)
2102 .build();
2103 var spendLimit = client.beta().organization().spendLimits().set(params);
2104
2105 IO.println("id: " + spendLimit.id());
2106 IO.println("amount: " + spendLimit.amount().orElseThrow());
2107 }
2108 ```
2109
2110 ```php PHP
2111 use Anthropic\Beta\Organization\SpendLimits\SpendLimitUserScope;
2112 // ...
2113
2114 $client = new Client();
2115
2116 $spendLimit = $client->beta->organization->spendLimits->set(
2117 scope: SpendLimitUserScope::with(userID: 'user_01AbCdEfGh'),
2118 amount: '500000',
2119 period: 'monthly',
2120 );
2121
2122 echo "id: {$spendLimit->id}\n";
2123 echo "amount: {$spendLimit->amount}\n";
2124 ```
2125
2126 ```ruby Ruby
2127 client = Anthropic::Client.new
2128
2129 spend_limit = client.beta.organization.spend_limits.set(
2130 scope: { type: :user, user_id: "user_01AbCdEfGh" },
2131 amount: "500000",
2132 period: :monthly
2133 )
2134
2135 puts "id: #{spend_limit.id}"
2136 puts "amount: #{spend_limit.amount}"
2137 ```
2138 </CodeGroup>
3572139
35821403. If responders need broader access during an incident, pre-provision an incident-responders group whose [custom role](https://platform.claude.com/docs/en/manage-claude/user-management#custom-roles) grants it, and add the member for the duration:
3592141
360 ```bash cURL
361 curl --request POST "https://api.anthropic.com/v1/organizations/rbac_groups/rbac_group_01UvWxYzAbCdEfGhIjKlMn/members" \
362 --header "content-type: application/json" \
363 --header "x-api-key: $ANTHROPIC_ADMIN_KEY" \
364 --header "anthropic-version: 2023-06-01" \
365 --data '{"user_id": "user_01AbCdEfGh"}'
366 ```
2142 <CodeGroup>
2143 ```bash cURL
2144 curl -X POST "https://api.anthropic.com/v1/organizations/rbac_groups/rbac_group_01UvWxYzAbCdEfGhIjKlMn/members" \
2145 -H "content-type: application/json" \
2146 -H "x-api-key: $ANTHROPIC_API_KEY" \
2147 -H "anthropic-version: 2023-06-01" \
2148 -d '{"user_id": "user_01AbCdEfGh"}'
2149 ```
2150
2151 ```bash CLI
2152 ant beta:organization:rbac-groups:members add \
2153 --rbac-group-id rbac_group_01UvWxYzAbCdEfGhIjKlMn \
2154 --user-id user_01AbCdEfGh
2155 ```
2156
2157 ```python Python
2158 client = anthropic.Anthropic()
2159
2160 member = client.beta.organization.rbac_groups.members.add(
2161 "rbac_group_01UvWxYzAbCdEfGhIjKlMn", user_id="user_01AbCdEfGh"
2162 )
2163
2164 print(f"user_id: {member.user_id}")
2165 print(f"rbac_group_id: {member.rbac_group_id}")
2166 ```
2167
2168 ```typescript TypeScript
2169 const client = new Anthropic();
2170
2171 const member = await client.beta.organization.rbacGroups.members.add(
2172 "rbac_group_01UvWxYzAbCdEfGhIjKlMn",
2173 {
2174 user_id: "user_01AbCdEfGh"
2175 }
2176 );
2177
2178 console.log(`user_id: ${member.user_id}`);
2179 console.log(`rbac_group_id: ${member.rbac_group_id}`);
2180 ```
2181
2182 ```csharp C#
2183 AnthropicClient client = new();
2184
2185 var member = await client.Beta.Organization.RbacGroups.Members.Add(
2186 "rbac_group_01UvWxYzAbCdEfGhIjKlMn",
2187 new() { UserID = "user_01AbCdEfGh" }
2188 );
2189
2190 Console.WriteLine($"user_id: {member.UserID}");
2191 Console.WriteLine($"rbac_group_id: {member.RbacGroupID}");
2192 ```
2193
2194 ```go Go
2195 client := anthropic.NewClient()
2196
2197 member, err := client.Beta.Organization.RBACGroups.Members.Add(
2198 context.Background(),
2199 "rbac_group_01UvWxYzAbCdEfGhIjKlMn",
2200 anthropic.BetaOrganizationRBACGroupMemberAddParams{
2201 UserID: "user_01AbCdEfGh",
2202 },
2203 )
2204 if err != nil {
2205 log.Fatal(err)
2206 }
2207
2208 fmt.Printf("user_id: %s\n", member.UserID)
2209 fmt.Printf("rbac_group_id: %s\n", member.RBACGroupID)
2210 ```
2211
2212 ```java Java
2213 import com.anthropic.models.beta.organization.rbacgroups.members.MemberAddParams;
2214
2215 void main() {
2216 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
2217
2218 var params = MemberAddParams.builder()
2219 .userId("user_01AbCdEfGh")
2220 .build();
2221 var member = client.beta().organization().rbacGroups().members()
2222 .add("rbac_group_01UvWxYzAbCdEfGhIjKlMn", params);
2223
2224 IO.println("user_id: " + member.userId());
2225 IO.println("rbac_group_id: " + member.rbacGroupId());
2226 }
2227 ```
2228
2229 ```php PHP
2230 $client = new Client();
2231
2232 $member = $client->beta->organization->rbacGroups->members->add(
2233 'rbac_group_01UvWxYzAbCdEfGhIjKlMn',
2234 userID: 'user_01AbCdEfGh',
2235 );
2236
2237 echo "user_id: {$member->userID}\n";
2238 echo "rbac_group_id: {$member->rbacGroupID}\n";
2239 ```
2240
2241 ```ruby Ruby
2242 client = Anthropic::Client.new
2243
2244 member = client.beta.organization.rbac_groups.members.add(
2245 "rbac_group_01UvWxYzAbCdEfGhIjKlMn",
2246 user_id: "user_01AbCdEfGh"
2247 )
2248
2249 puts "user_id: #{member.user_id}"
2250 puts "rbac_group_id: #{member.rbac_group_id}"
2251 ```
2252 </CodeGroup>
3672253
3682254 See [User management](https://platform.claude.com/docs/en/manage-claude/user-management#groups) for the group endpoints.
3692255
3702256
No line in this hunk matches that.