# Update AI quota — API reference

> Sets the Company's monthly AI call limit and budget, or removes either limit when its value is null.

Source: https://upfour.io/docs/api/organization/update-ai-quota

[Developers](https://upfour.io/docs/api.md)/[Organization](https://upfour.io/docs/api/organization.md)

Sets the Company's monthly AI call limit and budget, or removes either limit when its value is null.

PUT https://app.upfour.io/v1/organization/ai-quota

scope organization.write stable returns 200

## Body

`application/json` required 2 fields

All other fields2 fields

monthly_call_capinteger · nullable

Monthly AI call limit, at most platform_call_cap. null removes the Company's own limit so the default applies.

monthly_cap_centsinteger · nullable

Monthly AI budget in cents, at most platform_cap_cents of GET /organization/ai-usage. null removes the Company's own budget so the default applies.

## Returns

A successful request returns `200` with application/json.

Response fields 1 top-level fields

| Field | Type | Description |
| --- | --- | --- |
| `data` | AIUsageSummary | |
| AIUsageSummary · 8 fields FieldTypeDescription `call_cap` integer The monthly call limit in force: the Company's own value, never above platform_call_cap. `calls` integer `cap_cents` integer The monthly budget in force: the Company's own value, never above platform_cap_cents. `period_resets_at` string (date-time) `period_started_at` string (date-time) `platform_call_cap` integer `platform_cap_cents` integer `used_cents` integer This month's AI usage in cents, at the price the Company pays. | | |

## Errors

Only the errors this operation can return. Every error uses the [same envelope](https://upfour.io/docs/api/responses.md).

| Status | Code | Meaning |
| --- | --- | --- |
| 402 | [ai_billing_blocked](https://upfour.io/docs/api/errors#code-ai_billing_blocked) | AI features are switched off because the Company has no active credit. **When:** An AI summary or postmortem request while the Company has no active credit. **Fix:** Top up the credit, then retry. |
| 422 | [ai_budget_above_platform_limit](https://upfour.io/docs/api/errors#code-ai_budget_above_platform_limit) | The monthly AI budget exceeds the platform limit (`error.details.limit`). **When:** Saving an AI budget larger than the platform allows; details.limit gives the maximum. **Fix:** Set a budget at or below details.limit. `ai_budget_above_platform_limit` or `ai_call_cap_above_platform_limit`: the monthly AI budget or call cap is above the platform limit (`error.details.limit`). |
| 422 | [ai_call_cap_above_platform_limit](https://upfour.io/docs/api/errors#code-ai_call_cap_above_platform_limit) | The monthly AI call cap exceeds the platform limit (`error.details.limit`). **When:** Saving an AI call cap larger than the platform allows; details.limit gives the maximum. **Fix:** Set a cap at or below details.limit. |
| 400 | [bad_request](https://upfour.io/docs/api/errors#code-bad_request) | The request is malformed or fails validation. |
| 409 | [conflict](https://upfour.io/docs/api/errors#code-conflict) | The request conflicts with the current state. |
| 404 | [not_found](https://upfour.io/docs/api/errors#code-not_found) | The requested resource does not exist or is outside the caller's scope. |
| 403 | [permission_denied](https://upfour.io/docs/api/errors#code-permission_denied) | The credentials do not permit this action. |
| 503 | [service_unavailable](https://upfour.io/docs/api/errors#code-service_unavailable) | The service or a required dependency is temporarily unavailable. |

Every call can also return `unauthorized` (401), `rate_limit_exceeded` (429) or `internal_error` (500 / 502). See [Responses and errors](https://upfour.io/docs/api/responses.md).

[PreviousGet AI usage](https://upfour.io/docs/api/organization/get-ai-usage.md) [NextList audit logs](https://upfour.io/docs/api/organization/list-audit-logs.md)

## Request

### cURL

```bash
curl -s -X PUT "https://app.upfour.io/v1/organization/ai-quota" \
  -H "Authorization: Bearer $UP4_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "monthly_call_cap": 200,
    "monthly_cap_cents": 1000
  }'
```

### JavaScript

```javascript
const res = await fetch("https://app.upfour.io/v1/organization/ai-quota", {
  method: "PUT",
  headers: {
    Authorization: `Bearer ${process.env.UP4_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    monthly_call_cap: 200,
    monthly_cap_cents: 1000,
  }),
});
console.log(res.status, await res.json());
```

### Python

```python
import os
import requests

res = requests.put(
    "https://app.upfour.io/v1/organization/ai-quota",
    headers={"Authorization": f"Bearer {os.environ['UP4_API_KEY']}"},
    json={
        "monthly_call_cap": 200,
        "monthly_cap_cents": 1000,
    },
)
print(res.status_code, res.json())
```

### Go

```go
package main

import (
	"fmt"
	"io"
	"net/http"
	"os"
	"strings"
)

func main() {
	payload := strings.NewReader(`{
  "monthly_call_cap": 200,
  "monthly_cap_cents": 1000
}`)
	req, _ := http.NewRequest("PUT", "https://app.upfour.io/v1/organization/ai-quota", payload)
	req.Header.Set("Authorization", "Bearer "+os.Getenv("UP4_API_KEY"))
	req.Header.Set("Content-Type", "application/json")
	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()
	out, _ := io.ReadAll(res.Body)
	fmt.Println(res.StatusCode, string(out))
}
```

### PHP

```php
<?php
$payload = <<<'JSON'
{
  "monthly_call_cap": 200,
  "monthly_cap_cents": 1000
}
JSON;

$ch = curl_init("https://app.upfour.io/v1/organization/ai-quota");
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => "PUT",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("UP4_API_KEY"),
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => $payload,
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_RESPONSE_CODE), " ", $response, "\n";
curl_close($ch);
```

## Response

### 200

```json
{
  "data": {
    "call_cap": 200,
    "calls": 2,
    "cap_cents": 1000,
    "period_resets_at": "2026-10-31T16:55:00Z",
    "period_started_at": "2026-09-30T16:55:00Z",
    "platform_call_cap": 1000,
    "platform_cap_cents": 4000,
    "used_cents": 2
  }
}
```

### 400

```json
{
  "error": {
    "code": "bad_request",
    "message": "The request is malformed or fails validation.",
    "request_id": "req_…"
  }
}
```

### 402

```json
{
  "error": {
    "code": "ai_billing_blocked",
    "message": "AI features are switched off because the Company has no active credit.",
    "request_id": "req_…"
  }
}
```

### 403

```json
{
  "error": {
    "code": "permission_denied",
    "message": "The credentials do not permit this action.",
    "request_id": "req_…"
  }
}
```

### 404

```json
{
  "error": {
    "code": "not_found",
    "message": "The requested resource does not exist or is outside the caller's scope.",
    "request_id": "req_…"
  }
}
```

### 409

```json
{
  "error": {
    "code": "conflict",
    "message": "The request conflicts with the current state.",
    "request_id": "req_…"
  }
}
```

### 422

```json
{
  "error": {
    "code": "ai_budget_above_platform_limit",
    "message": "The monthly AI budget exceeds the platform limit (error.details.limit).",
    "request_id": "req_…"
  }
}
```

### 503

```json
{
  "error": {
    "code": "service_unavailable",
    "message": "The service or a required dependency is temporarily unavailable.",
    "request_id": "req_…"
  }
}
```
