Skip to main content
POST
/
organizations
/
{organization}
/
databases
/
{database}
/
backup-policies
Create a backup policy
curl --request POST \
  --url https://api.planetscale.com/v1/organizations/{organization}/databases/{database}/backup-policies \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "target": "production",
  "retention_value": 123,
  "retention_unit": "hour",
  "frequency_value": 123,
  "frequency_unit": "hour",
  "schedule_time": "<string>",
  "schedule_day": 123,
  "schedule_week": 123
}
'
{
  "id": "<string>",
  "display_name": "<string>",
  "name": "<string>",
  "target": "production",
  "retention_value": 123,
  "retention_unit": "<string>",
  "frequency_value": 123,
  "frequency_unit": "<string>",
  "schedule_time": "<string>",
  "schedule_day": 123,
  "schedule_week": 123,
  "created_at": "<string>",
  "updated_at": "<string>",
  "last_ran_at": "<string>",
  "next_run_at": "<string>",
  "required": true
}

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.

Body

application/json
name
string

The name of the backup policy

target
enum<string>

Whether the policy is for production or development branches

Available options:
production,
development
retention_value
integer

A number value for the retention period of the backup policy

retention_unit
enum<string>

The unit for the retention period of the backup policy

Available options:
hour,
day,
week,
month,
year
frequency_value
integer

A number value for the frequency of the backup policy

frequency_unit
enum<string>

The unit for the frequency of the backup policy

Available options:
hour,
day,
week,
month
schedule_time
string

The time of day that the backup is scheduled, in HH:MM format

schedule_day
integer

Day of the week that the backup is scheduled. 0 is Sunday, 6 is Saturday

schedule_week
integer

Week of the month that the backup is scheduled. 0 is the first week, 3 is the fourth week

Response

Returns the created backup policy

id
string
required

The ID of the backup policy

display_name
string
required

The display name of the backup policy

name
string
required

The name of the backup policy

target
enum<string>
required

Whether the policy is for production or development branches

Available options:
production,
development
retention_value
integer
required

A number value for the retention period of the backup policy

retention_unit
string
required

The unit for the retention period of the backup policy

frequency_value
integer
required

A number value for the frequency of the backup policy

frequency_unit
string
required

The unit for the frequency of the backup policy

schedule_time
string
required

The time of day that the backup is scheduled, in HH:MM format

schedule_day
integer
required

Day of the week that the backup is scheduled. 0 is Sunday, 6 is Saturday

schedule_week
integer
required

Week of the month that the backup is scheduled. 0 is the first week, 3 is the fourth week

created_at
string
required

When the backup policy was created

updated_at
string
required

When the backup policy was last updated

last_ran_at
string
required

When the backup was last run

next_run_at
string
required

When the backup will next run

required
boolean
required

Whether the policy is a required system backup