Using the Managed API
pgEdge Starfleet Managed Database exposes a REST API for databases, backups, and other resources. Every request authenticates with a bearer token in JSON Web Token (JWT) format, issued by a dedicated token endpoint. The sections below cover generating that token and making an authenticated request.
Generating an Access Token
An API client has an ID and a secret; a token endpoint exchanges them for an access token.
- Select
Settingsin the navigation pane, then select theAPI Clientstab. - Select
Create API Client. - Type a name for the client in the
API Client Namefield, then selectCreate. - Copy the
Auth IDandAuth Secretvalues displayed on screen. TheAuth Secretvalue does not appear again after you selectClose. -
Run this command to exchange the ID and secret for an access token:
curl -X POST https://api.pgedge.com/account/v1/oauth/token \ -H "Content-Type: application/json" \ -d '{ "client_id": "<auth-id>", "client_secret": "<auth-secret>", "grant_type": "client_credentials" }'The response returns the new token in
access_token, the token's lifetime in seconds asexpires_in, and its type astoken_type.
Making a Request
Send each request to the Managed API base URL, https://api.pgedge.com,
using the access token as a bearer token. Run this command to list every
database the token's client can reach:
curl https://api.pgedge.com/managed/v1/databases \
-H "Authorization: Bearer <access-token>"
A working request returns a JSON array of database objects.