How to Configure PlanetScale Service Account

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a planetscale service account by creating a machine token in your account settings. Next, you attach branch and database permissions to that token for your scripts or apps. Many engineering teams share one broad token across multiple build pipelines. This habit creates big risks if a token leaks or runs a bad command. How a planetscale service account works A planetscale service account lets automated tools manage databases without a human login. You do not tie these credentials to

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You set up a planetscale service account by creating a machine token in your account settings. Next, you attach branch and database permissions to that token for your scripts or apps. Many engineering teams share one broad token across multiple build pipelines. This habit creates big risks if a token leaks or runs a bad command.

How a planetscale service account works

A planetscale service account lets automated tools manage databases without a human login. You do not tie these credentials to one developer on your team. Instead, the account belongs to the workspace as a standalone machine identity. If an engineer leaves the company, your automated pipelines keep running without failing.

When you create the account, the platform gives you an ID and a secret token. You save these two values inside your secret store or build tool. Next, you pick the exact permissions that the machine identity needs for its job. You can let the token create branches, read schema data, or approve deploy requests.

You can scope these rules to one database or apply them across your whole account. For direct data queries, the service token can also generate database branch passwords. Your app then uses those passwords to open a standard MySQL session. This setup separates platform management tasks from raw SQL data queries.

Why you should scope branch permissions

Many teams give every machine token full admin rights just to save time. That choice makes setup fast, but it opens the door to bad mistakes. A test script with admin rights can drop a production branch by accident. It can also read sensitive tables that it has no business touching.

You should split your tokens by the exact job each tool performs. Give your schema migration tool permission to open and merge deploy requests. Give your backup runner read access to specific database branches only. When you isolate tokens this way, you shrink the blast radius of any leak.

Rotating these secrets on a set schedule also keeps your data safe. Because service tokens are static strings, anyone who copies one can use it from anywhere. Regular rotation ensures that old keys found in old build logs cannot work. Teams often automate key rotation using their cloud secret manager and the platform API.

Service-to-Service Authentication + Service Account Governance: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native service tokens solve and what they miss

Native service tokens solve the problem of tying automation to human user accounts. They give platform teams a clear way to grant API permissions to machines. You can revoke a compromised token in seconds without locking out a real person. They also help you track which pipeline created a branch or changed a schema.

Still, a service account only checks who logs in at the start. Once a token generates a database password and opens a session, native controls step back. The database role permits all queries that fit its broad read or write level. It cannot inspect individual SQL statements in flight to block a dangerous query.

Native tokens also cannot rewrite sensitive fields in query results on the fly. If a support tool queries a customer table, the database returns raw emails and card numbers. To redact phone numbers or national IDs, you must change your app code. Plus, shared tokens make it hard to see which person triggered a specific query.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev sits inline in the wire protocol beside those services as an open-source proxy, a sidecar for your Postgres or API. On every query an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run, and hoop.dev data masking rewrites matched sensitive values in responses in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

What is the difference between a service token and a database password?

A service token authenticates with the platform API to manage branches and deploy requests. A database password lets an app or user run SQL queries against a specific branch.

Can I restrict a planetscale service account to a single database?

Yes, you can assign permissions to one specific database instead of the whole account. This keeps a project pipeline from touching other databases in your workspace.

What happens to a service account when its creator leaves the team?

Nothing happens to the service account when the person who made it leaves. It stays active at the workspace level until an admin deletes or rotates it.

The query runs. The emails stay hidden.