Skip to content

Managed database

Managed Postgres: provision projects, copy-on-write branches and point-in-time snapshots across Neon / Supabase / PlanetScale.

Overview

Base path: https://api.infrai.cc/v1/db
Auth header: Authorization: Bearer $INFRAI_API_KEY
bash
# Call any /v1/db capability over raw HTTP — no SDK to install.
# curl:
curl https://api.infrai.cc/v1/db/... \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json"

Methods

db.project.create

POST /v1/db/project/create

Provision a managed Postgres project on the selected vendor (Neon/Supabase/PlanetScale).

Parameters

NameTypeRequiredDescription
namestring
Required
Database project name.
vendorstringOptionalExplicit vendor pin; required when mode=byok.
regionstringOptionalRegion to provision in.
planstringOptionalProvisioning plan / size.
mode"managed" | "byok"OptionalProvisioning mode — managed or byok.
postgres_versionstringOptionalPostgres major version.
idempotency_keystringOptionalClient-supplied key to make the call idempotent.

Returns

Project { id, name, region, connection_uri, created_at }

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X POST https://api.infrai.cc/v1/db/project/create \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "..."}'

db.project.get

GET /v1/db/project/get/{id}

Fetch a managed database project by id, including its connection URI.

Parameters

NameTypeRequiredDescription
idstring
Required
The project id.

Returns

Project

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X GET https://api.infrai.cc/v1/db/project/get/ID \
  -H "Authorization: Bearer $INFRAI_API_KEY"

db.project.list

GET /v1/db/project/list

List the managed database projects for the account.

Parameters

NameTypeRequiredDescription
cursorstringOptionalOpaque pagination cursor.
limitnumberOptionalMaximum number of items to return.

Returns

{ items: Project[], next_cursor?: string }

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X GET https://api.infrai.cc/v1/db/project/list \
  -H "Authorization: Bearer $INFRAI_API_KEY"

db.project.delete

DELETE /v1/db/project/delete/{id}

Delete a managed database project and all its branches/snapshots.

Parameters

NameTypeRequiredDescription
idstring
Required
The project id.

Returns

{ ok: boolean }

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X DELETE https://api.infrai.cc/v1/db/project/delete/ID \
  -H "Authorization: Bearer $INFRAI_API_KEY"

db.branch.create

POST /v1/db/branch/create

Create a copy-on-write branch of a project for previews or testing.

Parameters

NameTypeRequiredDescription
project_idstring
Required
The project id.
branch_namestring
Required
Name for the new branch.
from_branchstringOptionalSource branch to clone from.
idempotency_keystringOptionalClient-supplied key to make the call idempotent.

Returns

Branch { id, branch_name, project_id, connection_uri }

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X POST https://api.infrai.cc/v1/db/branch/create \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"project_id": "...", "branch_name": "..."}'

db.branch.get

GET /v1/db/branch/get/{id}

Fetch a database branch by id, including its connection URI.

Parameters

NameTypeRequiredDescription
idstring
Required
The branch id.

Returns

Branch

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X GET https://api.infrai.cc/v1/db/branch/get/ID \
  -H "Authorization: Bearer $INFRAI_API_KEY"

db.branch.list

GET /v1/db/branch/list

List the branches of a managed database project.

Parameters

NameTypeRequiredDescription
project_idstringOptionalThe project id.
cursorstringOptionalOpaque pagination cursor.
limitnumberOptionalMaximum number of items to return.

Returns

{ items: Branch[], next_cursor?: string }

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X GET https://api.infrai.cc/v1/db/branch/list \
  -H "Authorization: Bearer $INFRAI_API_KEY"

db.branch.delete

DELETE /v1/db/branch/delete/{id}

Delete a database branch.

Parameters

NameTypeRequiredDescription
idstring
Required
The branch id.

Returns

{ ok: boolean }

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X DELETE https://api.infrai.cc/v1/db/branch/delete/ID \
  -H "Authorization: Bearer $INFRAI_API_KEY"

db.snapshot.create

POST /v1/db/snapshot/create

Take a point-in-time snapshot of a managed database project.

Parameters

NameTypeRequiredDescription
project_idstring
Required
The project id.
labelstringOptionalHuman-readable snapshot label.
idempotency_keystringOptionalClient-supplied key to make the call idempotent.

Returns

Snapshot { id, project_id, label?, created_at }

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X POST https://api.infrai.cc/v1/db/snapshot/create \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"project_id": "..."}'

db.snapshot.get

GET /v1/db/snapshot/get/{id}

Fetch a database snapshot by id.

Parameters

NameTypeRequiredDescription
idstring
Required
The snapshot id.

Returns

Snapshot

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X GET https://api.infrai.cc/v1/db/snapshot/get/ID \
  -H "Authorization: Bearer $INFRAI_API_KEY"

db.snapshot.list

GET /v1/db/snapshot/list

List the snapshots of a managed database project.

Parameters

NameTypeRequiredDescription
project_idstringOptionalThe project id.
cursorstringOptionalOpaque pagination cursor.
limitnumberOptionalMaximum number of items to return.

Returns

{ items: Snapshot[], next_cursor?: string }

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X GET https://api.infrai.cc/v1/db/snapshot/list \
  -H "Authorization: Bearer $INFRAI_API_KEY"

db.snapshot.restore

POST /v1/db/snapshot/restore/{id}

Restore a snapshot into a new managed database project.

Parameters

NameTypeRequiredDescription
snapshot_idstring
Required
The snapshot id.
new_namestringOptionalName for the restored project (defaults to the source name with a -restored suffix).
idempotency_keystringOptionalClient-supplied key to make the call idempotent.

Returns

Project { id, name, connection_uri }

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X POST https://api.infrai.cc/v1/db/snapshot/restore/ID \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"snapshot_id": "..."}'
Advanced: pin a vendor

By default infrai routes each call to the best available provider — you do not pick a vendor. As an escape hatch, this capability accepts an optional vendor parameter to pin one specific provider. Every live vendor for this capability is available in real time from the discovery endpoint for the capability id — see the discovery API.

GET /v1/discovery/{capability}

db.project.create

All capabilities

Every routed capability in this module — the complete public REST contract. The methods above are the guided walkthrough; this index is the full reference.

CapabilityEndpointDescription
db.branch.createPOST /v1/db/branch/createdb branch create — managed database (Neon/Supabase/PlanetScale).
db.branch.deleteDELETE /v1/db/branch/delete/{id}db branch delete — managed database (Neon/Supabase/PlanetScale).
db.branch.getGET /v1/db/branch/get/{id}db branch get — managed database (Neon/Supabase/PlanetScale).
db.branch.listGET /v1/db/branch/listdb branch list — managed database (Neon/Supabase/PlanetScale).
db.project.createPOST /v1/db/project/createdb project create — managed database (Neon/Supabase/PlanetScale).
db.project.deleteDELETE /v1/db/project/delete/{id}db project delete — managed database (Neon/Supabase/PlanetScale).
db.project.getGET /v1/db/project/get/{id}db project get — managed database (Neon/Supabase/PlanetScale).
db.project.listGET /v1/db/project/listdb project list — managed database (Neon/Supabase/PlanetScale).
db.snapshot.createPOST /v1/db/snapshot/createdb snapshot create — managed database (Neon/Supabase/PlanetScale).
db.snapshot.getGET /v1/db/snapshot/get/{id}db snapshot get — managed database (Neon/Supabase/PlanetScale).
db.snapshot.listGET /v1/db/snapshot/listdb snapshot list — managed database (Neon/Supabase/PlanetScale).
db.snapshot.restorePOST /v1/db/snapshot/restore/{id}db snapshot restore — managed database (Neon/Supabase/PlanetScale).

End-to-end example

A production-style walkthrough of this module: configure once, then run the flow. It exercises most of the module's APIs.

A copy-paste-runnable single-file Python program (stdlib only, no SDK): set your INFRAI_API_KEY, run it, and walk this module's core flow with REAL billed calls — later steps reuse real fields returned by earlier ones. The 12-line helper is the entire integration.

python
#!/usr/bin/env python3
"""Infrai · db — runnable real-app example (single file, zero deps).

Copy this file, set your key, run it: every step is a REAL call to
api.infrai.cc, billed at the real (tiny) per-call price, printing the
live JSON response. Get a key at https://console.infrai.cc (Google/
GitHub sign-in grants $2 free credit). No SDK — the 12-line helper
below is the entire integration."""
import json
import os
from urllib import error, request

KEY = os.environ.get("INFRAI_API_KEY") or "ifr_pk_proj_..."  # <- your key
BASE = "https://api.infrai.cc"


# Same raw HTTPS POST/GET as every per-method example on this page —
# wrapped once for reuse. There is nothing else to it: no SDK.
def infrai(method, path, body=None):
    req = request.Request(
        BASE + path, method=method,
        data=json.dumps(body).encode() if body is not None else None,
        headers={"Authorization": f"Bearer {KEY}",
                 "Content-Type": "application/json"})
    try:
        with request.urlopen(req, timeout=60) as r:
            return json.loads(r.read())
    except error.HTTPError as e:
        return json.loads(e.read())


def show(label, resp):
    print(f"\n== {label} ==")
    print(json.dumps(resp, indent=2, ensure_ascii=False))
    return resp


# 1) db.project.create — POST /v1/db/project/create · db project create — managed database (Neon/Supabase/PlanetScale).
r1 = show("db.project.create", infrai("POST", "/v1/db/project/create", {"name":"..."}))

# 2) db.branch.create — POST /v1/db/branch/create · db branch create — managed database (Neon/Supabase/PlanetScale).
r2 = show("db.branch.create", infrai("POST", "/v1/db/branch/create", {"project_id":"...","branch_name":"..."}))

# 3) db.project.list — GET /v1/db/project/list · db project list — managed database (Neon/Supabase/PlanetScale).
r3 = show("db.project.list", infrai("GET", "/v1/db/project/list"))