Overview
You can use the PlanetScale API to manage your PlanetScale databases programmatically. The PlanetScale API does not include direct access to the data in the database. Some endpoints will consist of database schema information or connection information.Base URL
Every endpoint is underhttps://api.planetscale.com/v1. Requests and responses are JSON.
Authentication
Before making your first API call, set up the proper authentication for the PlanetScale API using theAuthorization header. There are two API authentication types: Service tokens and OAuth.
Service tokens
Send a service token as a Bearer token:Authorization: <SERVICE_TOKEN_ID>:<SERVICE_TOKEN>. Older service tokens only work in this form. Sending the token on its own, without Bearer or the ID, returns 401.
Most endpoints only need a service token for authentication, but some organization-specific endpoints also need OAuth. Each endpoint will state what types of authentication are allowed. See the Service tokens documentation for creating a service token and granting it permissions.
OAuth applications
All OAuth applications have a comprehensive list of scopes that the application can request from the PlanetScale user. See the OAuth documentation for more info.Finding endpoints
The sidebar lists every endpoint, grouped by product. The same reference is available as one text file athttps://planetscale.com/docs/_llms/api-reference.txt, and the OpenAPI specification is served at https://api.planetscale.com/v1/openapi-spec. See OpenAPI specification for details.
Waiting for new resources
Creating a database, branch, or backup returns before the resource is ready. Poll it until it is ready before you connect to it or use it:- Databases: poll Get a database until
stateisready. - Branches: poll Get a branch until
readyistrue. - Backups: poll Get a backup until
stateissuccess.

