Skip to main content
POST
/
organizations
/
{organization}
/
databases
/
{database}
/
branches
/
{branch}
/
traffic
/
budgets
Create a traffic budget
curl --request POST \
  --url https://api.planetscale.com/v1/organizations/{organization}/databases/{database}/branches/{branch}/traffic/budgets \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "mode": "enforce",
  "capacity": 123,
  "rate": 123,
  "burst": 123,
  "concurrency": 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
}

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.

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

Maximum percentage of capacity (0-100)

rate
integer

Rate limit percentage (0-100)

burst
integer

Burst limit percentage (0-100)

concurrency
integer

Concurrency limit percentage (0-100)

rules
string[]

Array of traffic rules to apply to the budget

Response

Returns the created 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

Capacity value

rate
number

Rate value

burst
number

Burst value

concurrency
number

Concurrency value