Skip to main content
POST
/
organizations
/
{organization}
/
service-tokens
Create a service token
curl --request POST \
  --url https://api.planetscale.com/v1/organizations/{organization}/service-tokens \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "ttl": 123
}
'
{
  "id": "<string>",
  "name": "<string>",
  "display_name": "<string>",
  "avatar_url": "<string>",
  "created_at": "<string>",
  "updated_at": "<string>",
  "expires_at": "<string>",
  "last_used_at": "<string>",
  "actor_id": "<string>",
  "actor_display_name": "<string>",
  "actor_type": "<string>",
  "token": "<string>",
  "plain_text_refresh_token": "<string>",
  "service_token_accesses": [
    {
      "id": "<string>",
      "access": "<string>",
      "description": "<string>",
      "resource_name": "<string>",
      "resource_id": "<string>",
      "resource_type": "<string>",
      "resource": {
        "id": "<string>",
        "name": "<string>",
        "created_at": "<string>",
        "updated_at": "<string>",
        "deleted_at": "<string>"
      }
    }
  ],
  "oauth_accesses_by_resource": {
    "database": {
      "databases": [
        {
          "name": "<string>",
          "id": "<string>",
          "organization": "<string>",
          "url": "<string>"
        }
      ],
      "accesses": [
        {
          "name": "<string>",
          "description": "<string>"
        }
      ]
    },
    "organization": {
      "organizations": [
        {
          "name": "<string>",
          "id": "<string>",
          "url": "<string>"
        }
      ],
      "accesses": [
        {
          "name": "<string>",
          "description": "<string>"
        }
      ]
    },
    "branch": {
      "branches": [
        {
          "name": "<string>",
          "id": "<string>",
          "database": "<string>",
          "organization": "<string>",
          "url": "<string>"
        }
      ],
      "accesses": [
        {
          "name": "<string>",
          "description": "<string>"
        }
      ]
    },
    "user": {
      "users": [
        {
          "name": "<string>",
          "id": "<string>"
        }
      ],
      "accesses": [
        {
          "name": "<string>",
          "description": "<string>"
        }
      ]
    }
  }
}

Documentation Index

Fetch the complete documentation index at: https://planetscale.com/docs/llms.txt

Use this file to discover all available pages before exploring further.

Authorizations

Authorization
string
header
required

The access token received from the authorization server in the OAuth 2.0 flow.

Path Parameters

organization
string
required

The name of the organization

Body

application/json
name
string

The name of the service token

ttl
integer

Time to live (in seconds) for the service token. The token will be invalid when TTL has passed

Response

Returns the created service token with the plaintext token

id
string
required

The ID of the service token

name
string | null
required

The name of the service token

display_name
string
required

The display name of the service token

avatar_url
string
required

The image source for the avatar of the service token

created_at
string
required

When the service token was created

updated_at
string
required

When the service token was last updated

expires_at
string | null
required

When the service token will expire

last_used_at
string | null
required

When the service token was last used

actor_id
string | null
required

The ID of the actor on whose behalf the service token was created

actor_display_name
string | null
required

The name of the actor on whose behalf the service token was created

actor_type
string | null
required

The type of the actor on whose behalf the service token was created

token
string | null

The plaintext token. Available only after create.

plain_text_refresh_token
string | null

The plaintext refresh token. Available only after create.

service_token_accesses
object[] | null
oauth_accesses_by_resource
object