Quick Start: REST

Stable

The minimum API v2 scenario: create tenant -> create db -> get DSN -> connect.

Updated: March 5, 2026

Below is the minimum user path through REST without using Console.

1. Prepare variables

export CP_URL="https://<cp-host>"
export SPG99_TOKEN="<api-key>"

2. Create a tenant

curl -sS -X POST "$CP_URL/v2/tenants"       -H "Authorization: Bearer $SPG99_TOKEN"       -H "Content-Type: application/json"       -d '{"name":"t1"}'

Save pg_user, pg_password, and dsn_template from the response.

3. Create a database

curl -sS -X POST "$CP_URL/v2/tenants/t1/dbs"       -H "Authorization: Bearer $SPG99_TOKEN"       -H "Content-Type: application/json"       -d '{"name":"d1","size":"L1"}'

In the current managed scenario, do not use start_immediately or initial_scale: the database starts automatically on the first connection through Gateway.

4. Re-read credentials if needed

curl -sS "$CP_URL/v2/tenants/t1/credentials"       -H "Authorization: Bearer $SPG99_TOKEN"

5. Connect to PostgreSQL through Gateway

Build the DSN from the template:

postgres://<pg_user>:<pg_password>@<gateway-host>:5432/d1?sslmode=require

Example:

psql "postgres://tnt_xxxxx:secret@pg.spg99.ru:5432/d1?sslmode=require"

If the database is in stopped, the first connection may take a little longer: the platform will perform a cold start automatically.

6. Check the database state

curl -sS "$CP_URL/v2/tenants/t1/dbs/d1"       -H "Authorization: Bearer $SPG99_TOKEN"

This is useful to inspect state, current_scale, target_scale, worker_id, and other runtime fields.

Main rule

For the managed SPG99 scenario, it is enough to remember one simple workflow:

create tenant -> save credentials -> create db -> connect through Gateway