Skip to main content
POST
/
organizations
/
{organization}
/
databases
/
{database}
/
branches
/
{branch}
/
traffic
/
budgets
/
{budget_id}
/
rules
Create a traffic rule
curl --request POST \
  --url https://api.planetscale.com/v1/organizations/{organization}/databases/{database}/branches/{branch}/traffic/budgets/{budget_id}/rules \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "keyspace": "<string>",
  "fingerprint": "<string>",
  "tags": [
    "<string>"
  ]
}
'
{
  "id": "<string>",
  "tags": [
    {
      "key_id": "<string>",
      "key": "<string>",
      "value": "<string>"
    }
  ],
  "actor": {
    "id": "<string>",
    "display_name": "<string>",
    "avatar_url": "<string>"
  },
  "syntax_highlighted_sql": "<string>",
  "created_at": "<string>",
  "updated_at": "<string>",
  "fingerprint": "<string>",
  "keyspace": "<string>"
}

Documentation Index

Fetch the complete documentation index at: https://planetscale.com/docs/llms.txt

Use this file to discover all available pages before exploring further.

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.

budget_id
string
required

The ID of the traffic budget

Body

application/json
kind
enum<string>

Kind of rule

Available options:
match
keyspace
string

The keyspace to apply a query pattern rule to

fingerprint
string

Query pattern fingerprint to apply rule to

tags
string[]

Optional array of tags for this rule

Response

Returns the created traffic rule

id
string
required

The ID of the traffic rule

kind
enum<string>
required

The kind of rule

Available options:
match
tags
object[]
required
actor
object
required
syntax_highlighted_sql
string
required

Syntax highlighted SQL for rules with SQL keys

created_at
string
required

When the rule was created

updated_at
string
required

When the rule was updated

fingerprint
string | null

The query fingerprint targeted by this rule

keyspace
string | null

The keyspace of the fingerprint