---
title: upsert-ai-gateway-budget
description: Learn about upsert-ai-gateway-budget on Vercel.
url: "https://vercel.com/docs/rest-api/ai-gateway/upsert-ai-gateway-budget"
last_updated: 2026-12-01
related:
  - /docs/rest-api
install_vercel_plugin: npx plugins add vercel/vercel-plugin
search_with_vercel_cli: npx vercel@latest docs search "<query>"
search_kb_with_vercel_cli: npx vercel@latest kb search "<query>"
---

# Upsert AI Gateway budget

```http
PUT /ai-gateway/budgets
```

Create or update a team-, project-, user-, or app-scope AI Gateway budget. Set a total with `limitAmount`, or raise the current budget with `increaseBy`.

## Authentication

**bearerToken**: HTTP bearer

## Query parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `teamId` | string | No | The Team identifier to perform the request on behalf of. |
| `slug` | string | No | The Team slug to perform the request on behalf of. |


## Request body

Required: No

Content-Type: `application/json`

```json
{
  "type": "object",
  "required": [
    "scopeType"
  ],
  "properties": {
    "scopeType": {
      "type": "string",
      "enum": [
        "team",
        "project",
        "user",
        "app"
      ]
    },
    "projectId": {
      "type": "string",
      "description": "Required when scopeType is \\\"project\\\"."
    },
    "userId": {
      "type": "string",
      "description": "Required when scopeType is \\\"user\\\"."
    },
    "appId": {
      "type": "string",
      "description": "Required when scopeType is \\\"app\\\". The id of a Vercel App (`cl_…`)."
    },
    "limitAmount": {
      "type": "number",
      "description": "Budget limit in dollars. Provide this or `increaseBy`, not both.",
      "minimum": 1
    },
    "increaseBy": {
      "type": "number",
      "description": "Dollars to add to the current budget, or to the scope's default when it has no budget of its own. Provide this or `limitAmount`, not both. Keeps the current refresh period and BYOK setting unless they are given.",
      "minimum": 1
    },
    "refreshPeriod": {
      "type": "string",
      "description": "Defaults to monthly with `limitAmount`; `increaseBy` keeps the current period. Ignored for a member's own change that lapses (`expiresAt`): it takes the user default's period.",
      "enum": [
        "daily",
        "weekly",
        "monthly",
        "none"
      ]
    },
    "includeByokInQuota": {
      "type": "boolean",
      "description": "Whether BYOK usage counts toward this budget."
    },
    "alertThresholds": {
      "type": "array",
      "items": {
        "type": "number",
        "enum": [
          50,
          75,
          100
        ]
      }
    },
    "justification": {
      "type": "string",
      "description": "Why the budget is being changed, up to 500 characters. Recorded in the activity log and audit log drains, and sent in the ai-gateway.budget.updated webhook."
    }
  }
}
```

## Example request

### TypeScript

```typescript
const response = await fetch('https://api.vercel.com/ai-gateway/budgets?teamId=string&slug=string', {
  method: 'PUT',
  headers: {
    'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "scopeType": "team",
    "projectId": "example_id",
    "userId": "example_id",
    "appId": "example_id",
    "limitAmount": "123",
    "increaseBy": "123",
    "refreshPeriod": "daily",
    "includeByokInQuota": "true",
    "alertThresholds": [],
    "justification": "string"
  }),
});

const data = await response.json();
console.log(data);
```

### Next.js

```typescript
'use server';

export async function callEndpoint() {
  const response = await fetch('https://api.vercel.com/ai-gateway/budgets?teamId=string&slug=string', {
    method: 'PUT',
    headers: {
      'Authorization': `Bearer ${process.env.VERCEL_ACCESS_TOKEN}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      "scopeType": "team",
      "projectId": "example_id",
      "userId": "example_id",
      "appId": "example_id",
      "limitAmount": "123",
      "increaseBy": "123",
      "refreshPeriod": "daily",
      "includeByokInQuota": "true",
      "alertThresholds": [],
      "justification": "string"
    }),
    next: { revalidate: 3600 }
  });

  if (!response.ok) {
    throw new Error('Request failed');
  }

  return response.json();
}
```

### cURL

```bash
curl -X PUT 'https://api.vercel.com/ai-gateway/budgets?teamId=string&slug=string' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d "{
    \"scopeType\": \"team\",
    \"projectId\": \"example_id\",
    \"userId\": \"example_id\",
    \"appId\": \"example_id\",
    \"limitAmount\": \"123\",
    \"increaseBy\": \"123\",
    \"refreshPeriod\": \"daily\",
    \"includeByokInQuota\": \"true\",
    \"alertThresholds\": [],
    \"justification\": \"string\"
  }"
```

## Example response

```json
{
  "active": "false",
  "alertThresholds": [],
  "archived": "false",
  "createdAt": "123",
  "currentByokSpend": "123",
  "currentSpend": "123",
  "expiresAt": "123",
  "includeByokInQuota": "false",
  "limitAmount": "123",
  "name": "Example Name",
  "quotaEntityId": "example_id",
  "refreshPeriod": "daily",
  "scopeId": "example_id",
  "scopeType": "api-key",
  "source": "default",
  "updatedAt": "123"
}
```

## Responses

### 200: No description

Content-Type: `application/json`

```json
{
  "type": "object",
  "required": [
    "active",
    "archived",
    "createdAt",
    "currentByokSpend",
    "currentSpend",
    "includeByokInQuota",
    "limitAmount",
    "quotaEntityId",
    "refreshPeriod",
    "scopeId",
    "scopeType",
    "updatedAt"
  ],
  "properties": {
    "active": {
      "type": "boolean",
      "enum": [
        false,
        true
      ]
    },
    "alertThresholds": {
      "type": "array",
      "items": {
        "type": "number"
      }
    },
    "archived": {
      "type": "boolean",
      "enum": [
        false,
        true
      ]
    },
    "createdAt": {
      "type": "number"
    },
    "currentByokSpend": {
      "type": "number"
    },
    "currentSpend": {
      "type": "number"
    },
    "expiresAt": {
      "type": "number",
      "description": "When a member's own budget change lapses and the user default applies again, in ms since the epoch. Absent means the budget is permanent."
    },
    "includeByokInQuota": {
      "type": "boolean",
      "enum": [
        false,
        true
      ]
    },
    "limitAmount": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "quotaEntityId": {
      "type": "string"
    },
    "refreshPeriod": {
      "type": "string",
      "enum": [
        "daily",
        "monthly",
        "none",
        "weekly"
      ]
    },
    "scopeId": {
      "type": "string",
      "description": "The native Vercel id of the scoped entity. Team/project ids already carry their prefix, so this equals `quotaEntityId` (`team_…` / `prj_…`); user and app scopes also use the quota entity id (`usr_<userId>` / `app_<appId>`); for the api-key scope it is the api key id (the `api_key_id_` prefix stripped)."
    },
    "scopeType": {
      "type": "string",
      "enum": [
        "api-key",
        "app",
        "project",
        "team",
        "user"
      ]
    },
    "source": {
      "type": "string",
      "description": "Set when the row is inherited from the team's budget default.",
      "enum": [
        "default"
      ]
    },
    "updatedAt": {
      "type": "number"
    }
  }
}
```

### 400: One of the provided values in the request body is invalid.

### 401: The request is not authorized.

### 403: You do not have permission to access this resource.

### 404: No description

### 410: No description

### 500: No description

---

## Related

- [ai-gateway endpoints](/docs/rest-api#ai-gateway)

- [REST API overview](/docs/rest-api)

- [OpenAPI spec](https://vercel.com/openapi.json) (machine-readable, all endpoints)

## Search the docs from your terminal

Search the Vercel docs and read pages as Markdown with the Vercel CLI. No login required.

```bash
# Find docs pages by keyword
npx vercel@latest docs search "environment variables"
npx vercel@latest docs search "function timeout"

# Print a docs page as Markdown, by path or URL
npx vercel@latest docs inspect <page>
```

## Search guides from your terminal

Search the Knowledge Base and read guides as Markdown with the Vercel CLI. No login required.

```bash
# Find guides by keyword
npx vercel@latest kb search "rewrites and redirects"
npx vercel@latest kb search "AI SDK streaming"

# Show the latest guides
npx vercel@latest kb

# Print a guide as Markdown, by slug or URL
npx vercel@latest kb inspect <guide>
```

---

[View full sitemap](/docs/sitemap)


If you encounter incorrect information, can’t find what you need, need a capability Vercel doesn’t currently offer, or have any other feedback to report, please do it by following the instructions at https://vercel.com/feedback.md.
