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 '
{
  "kind": "<string>",
  "keyspace": "<string>",
  "fingerprint": "<string>",
  "tags": [
    "<string>"
  ]
}
'
{
  "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>"
}

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
string

Kind of rule

keyspace
string

Keyspace to apply rule to

fingerprint
string

Query 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

The query fingerprint targeted by this rule

keyspace
string

The keyspace of the fingerprint