# Replace usage budgets

Replaces usage budgets.

```http
PUT https://api.pozy.ai/v1/accounts/{accountId}/business-agent/budget
```

- Area: WhatsApp / Business Agent
- Auth: Authorization: Bearer pz_live_...

## Path parameters

- `accountId` (string, required)

## Request body

Content type: `application/json`

- `budgets`, array of object, required
  - `budget_id`, string
  - `unit_type`, string, required: One of `token`, `ai_turn`
  - `time_window`, string, required: One of `one_day`, `seven_days`, `fourteen_days`, `thirty_days`
  - `max_budget`, integer, required: At least 1

## Example request

```bash
curl -X PUT "https://api.pozy.ai/v1/accounts/696e0b682d0a31188e7a2ba9/business-agent/budget" \
  -H "Authorization: Bearer $POZY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "budgets": [
    {
      "unit_type": "token",
      "time_window": "one_day",
      "max_budget": 1
    }
  ]
}'
```

```ts
const res = await fetch("https://api.pozy.ai/v1/accounts/696e0b682d0a31188e7a2ba9/business-agent/budget", {
  method: "PUT",
  headers: {
    Authorization: `Bearer ${process.env.POZY_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    budgets: [
      {
        unit_type: "token",
        time_window: "one_day",
        max_budget: 1
      }
    ]
  }),
});
const data = await res.json();
if (!res.ok) throw new Error(data?.error ?? `Request failed with status ${res.status}`);
console.log(data);
```

```python
import os
import requests

resp = requests.put(
    "https://api.pozy.ai/v1/accounts/696e0b682d0a31188e7a2ba9/business-agent/budget",
    headers={"Authorization": f"Bearer {os.environ['POZY_API_KEY']}"},
    json={
        "budgets": [
            {
                "unit_type": "token",
                "time_window": "one_day",
                "max_budget": 1,
            },
        ],
    },
    timeout=30,
)
resp.raise_for_status()
print(resp.json())
```

## Response 200

- `budgets`, array of object, required
  - `budget_id`, string
  - `unit_type`, string, required: One of `token`, `ai_turn`
  - `time_window`, string, required: One of `one_day`, `seven_days`, `fourteen_days`, `thirty_days`
  - `max_budget`, integer, required: At least 1

```json
{
  "budgets": [
    {
      "budget_id": "6ffaacfb1f32166ecd79b13e",
      "unit_type": "token",
      "time_window": "one_day",
      "max_budget": 1
    }
  ]
}
```
