Skip to main content
PATCH
/
organizations
/
{organization}
/
databases
/
{database}
/
branches
/
{branch}
/
traffic
/
budgets
/
{id}
Update a traffic budget
curl --request PATCH \
  --url https://api.planetscale.com/v1/organizations/{organization}/databases/{database}/branches/{branch}/traffic/budgets/{id} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "mode": "enforce",
  "capacity": 123,
  "rate": 123,
  "burst": 123,
  "concurrency": 123,
  "warning_threshold": 123,
  "rules": [
    "<string>"
  ]
}
'
{
  "id": "<string>",
  "name": "<string>",
  "mode": "enforce",
  "actor": {
    "id": "<string>",
    "display_name": "<string>",
    "avatar_url": "<string>"
  },
  "rules": [
    {
      "id": "<string>",
      "kind": "match",
      "tags": [
        {
          "key_id": "<string>",
          "key": "<string>",
          "value": "<string>",
          "source": "sql"
        }
      ],
      "actor": {
        "id": "<string>",
        "display_name": "<string>",
        "avatar_url": "<string>"
      },
      "syntax_highlighted_sql": "<string>",
      "created_at": "<string>",
      "updated_at": "<string>",
      "fingerprint": "<string>",
      "keyspace": "<string>"
    }
  ],
  "created_at": "<string>",
  "updated_at": "<string>",
  "capacity": 123,
  "rate": 123,
  "burst": 123,
  "concurrency": 123,
  "warning_threshold": 123
}

Authorizations

Authorization
string
header
required

The access token received from the authorization server in the OAuth 2.0 flow.

Path Parameters

organization
string
required

Organization name slug from list_organizations. Example: acme.

database
string
required

Database name slug from list_databases. Example: app-db.

branch
string
required

Branch name from list_branches. Example: main.

id
string
required

The ID of the traffic budget

Body

application/json
name
string

Name of the traffic budget

mode
enum<string>

The mode of the traffic budget

Available options:
enforce,
warn,
off
capacity
integer

The maximum capacity that can be banked, measured as a percentage of seconds of full server usage (0-6000). Unlimited when not set.

rate
integer

The rate at which capacity refills, as a percentage of server resources (0-100). Unlimited when not set.

burst
integer

The maximum capacity a single query can consume, measured as a percentage of seconds of full server usage (0-6000). Unlimited when not set.

concurrency
integer

The percentage of available worker processes this policy can use (0-100). Unlimited when not set.

warning_threshold
integer

A percentage of capacity, burst, or concurrency thresholds to emit warnings for enforced budgets (0-100).

rules
string[]

Array of traffic rules to apply to the budget

Response

Returns the updated traffic budget

id
string
required

The ID of the traffic budget

name
string
required

The name of the budget

mode
enum<string>
required

The mode of the budget

Available options:
enforce,
warn,
off
actor
object
required
rules
object[]
required
created_at
string
required

When the budget was created

updated_at
string
required

When the budget was updated

capacity
number

The maximum capacity that can be banked, measured as a percentage of seconds of full server usage (0-6000). Unlimited when not set.

rate
number

The rate at which capacity refills, as a percentage of server resources (0-100). Unlimited when not set.

burst
number

The maximum capacity a single query can consume, measured as a percentage of seconds of full server usage (0-6000). Unlimited when not set.

concurrency
number

The percentage of available worker processes this policy can use (0-100). Unlimited when not set.

warning_threshold
number

A percentage of capacity, burst, or concurrency thresholds to emit warnings for enforced budgets (0-100).