API referenceConsole
Cloud provider
Polylane links PlanetScale branches to the services that query them, pulls Query Insights to find slow and failing queries, and writes the fix in your code.

Connect

Connect PlanetScale from the terminal. Pass --help for the flags PlanetScale accepts, plus --no-browser for headless environments.

Terminal
polylane cloud connect --provider planetscale

How it works

Access

The OAuth grant gives Polylane read access to the organization, its members, databases, branches, backups, deploy requests and comments. The grant also includes permission to restore backups. A service token gets only the permissions that you give it.

Infrastructure graph

Polylane syncs the organization every 15 minutes. Each database and each branch becomes a node, with its state, kind, region, production flag, parent branch and schema activity. A database contains its branches. Polylane reads the connection hosts of each branch, so a service that connects to a branch, for example through a Cloudflare Hyperdrive configuration, links to that branch on the topology.

Query Insights and checks

Polylane reads Query Insights for each database and branch. The charts show queries, query errors, p99 latency, rows read, rows returned and query time. PlanetScale has no logs API, so Polylane reads failing queries from Query Insights as the error lines of the branch.

Polylane monitors production branches only. By default, it runs these checks every 30 minutes:

  • Latency anomalies that PlanetScale itself detects. One anomaly opens an issue.
  • Query errors, compared with the history of the account.
  • Worst p99 latency of a query pattern, compared with the history of the account.
  • Query volume. A drop to zero queries on a busy branch can mean that an application lost its connection.
  • Credentials. A revoked grant or a deleted token stops the sync, so Polylane checks the credential on each run.

Investigations

During an investigation, agents read Query Insights for one branch: top query patterns, error groups and latency anomaly windows. Agents can also read other PlanetScale API endpoints, such as backups and deploy requests.

Writes

The PlanetScale API tool can create branches, promote branches and restore backups. Connections start in read-only mode, so Polylane refuses each write until a workspace admin turns read-only mode off. After that, each write needs safety review and your approval before it runs.

Service token

Use a service token for a long-lived credential, or to connect from a script.

  1. In PlanetScale, open your organization's Settings → Service tokens.
  2. Click Create service token. Copy the token ID and the token.
  3. Grant the token read_organization and read_databases.
  4. Paste the token ID and the token into Polylane. If the token can open more than one organization, also enter the name of the organization to connect.
  5. Polylane checks the token and starts the first sync.

Troubleshooting

"PlanetScale does not recognize this service token" error

  • You must give the token ID and the token. The token alone cannot authenticate.
  • Make sure that the token is not deleted in PlanetScale.

"This PlanetScale service token cannot read your organization" error

  • In PlanetScale, open Settings → Service tokens, select the token, and grant read_organization and read_databases.

"Multiple PlanetScale organizations are reachable" error

  • The credential can open more than one organization. Name the organization to connect.
  • With OAuth in the console, pick the organization when Polylane asks.
  • With the API, set the organization field to the organization name.

"PlanetScale no longer accepts this authorization" error

  • PlanetScale revoked the OAuth grant. Connect PlanetScale again to authorize Polylane.

Missing resources

  • The first sync can take a few minutes.
  • Click Sync in the account header to start a sync immediately.

Disconnecting

Disconnecting stops every sync and check, and deletes the credential that Polylane stored. The OAuth grant stays in PlanetScale until you revoke it there. If you connected with a service token, delete the token in your PlanetScale organization settings.

Disconnect

Disconnecting stops every sync and check and deletes the credentials Polylane held. Polylane removes what PlanetScale's API lets it remove. The following stays until you remove it yourself:

  • OAuth grant
Terminal
polylane cloud disconnect <id>

Tools

2

Operations agents can perform in threads.

planetscaleApi
Call any PlanetScale REST API endpoint that lacks a dedicated tool
planetscaleGetQueryInsights
Get PlanetScale Query Insights for a database branch: top queries, query errors, or latency anomalies

Supported resources

2

Resource types that show up in your infrastructure graph.

Database
Database Branch