Neki, sharded Postgres, is now available. Learn more
Navigation

Service tokens now require an expiration date

New service tokens are now required to set an expiration date. Token expiration help ensure that if a token is leaked it cannot be used indefinitely.

Existing service tokens continue working, including tokens that never expire. When a token that has no expiration date is edited, you'll now be required to set one.

If you create service tokens from scripts using the CLI or API, they need to be updated to pass a TTL.

Dashboard

When you create, duplicate, or edit a service token in the PlanetScale dashboard, the "No expiration" option is no longer available and the expiration defaults to 30 days.

API

Creating or duplicating a service token without a ttl (in seconds) now returns a 422 with the message Expiration date is required. Set ttl to a number of seconds. Updating a service token with "ttl": null to remove its expiration is no longer allowed.

curl --request POST \
     --url 'https://api.planetscale.com/v1/organizations/{organization}/service-tokens' \
     --header 'Authorization: <SERVICE_TOKEN_ID>:<SERVICE_TOKEN>' \
     --header 'Content-Type: application/json' \
     --data '{"name": "My Token", "ttl": 2592000}'

CLI

Pass --ttl with a number of seconds when you create or duplicate a service token:

pscale service-token create --name "My Token" --ttl 2592000

pscale service-token update --ttl never no longer removes a token's expiration.

Read more about service tokens