PgBeam Docs
Databases

createDatabase

Add a database

Registers a new upstream PostgreSQL database for the project.

Usage

const result = await api.databases.createDatabase({
  pathParams: { project_id: "prj_xxx" },
  body: {
    host: "db.example.com",
    port: 5432,
    name: "mydb",
    username: "pgbeam",
    password: "...",
  },
});

Parameters

ParameterTypeRequiredDescription
pathParams.project_idstringYesUnique project identifier (prefixed, e.g. prj_xxx).
body.hoststringYesPostgreSQL host.
body.portnumberYesPostgreSQL port.
body.namestringYesPostgreSQL database name.
body.usernamestringYesPostgreSQL username.
body.passwordstringYesPostgreSQL password. Stored encrypted at rest.
body.ssl_modeSSLModeNo
body.roleDatabaseRoleNo
body.pool_regionstringNoRegion where the connection pool is maintained (near the database). When set and different from the client's edge region, queries are relayed through the pool region's data plane. Empty means direct connection.
body.query_timeout_msnumberNoQuery timeout in milliseconds. 0 means disabled (default).
body.auto_read_routingbooleanNoAuto-route SELECT queries to read replicas.
body.cache_configCacheConfigNo
body.pool_configPoolConfigNo

Response

Promise<Database> — database created.

Example

import { PgBeamClient } from "pgbeam";

const client = new PgBeamClient({
  token: "pbk_...",
  baseUrl: "https://api.pgbeam.com",
});

const result = await client.api.databases.createDatabase({
  pathParams: { project_id: "prj_xxx" },
  body: {
    host: "db.example.com",
    port: 5432,
    name: "mydb",
    username: "pgbeam",
    password: "...",
  },
});

Errors

StatusDescription
400Invalid request parameters.
401Missing or invalid authentication.
403Operation not allowed by current plan limits.
404Resource not found.
429Rate limited. Try again later.

On this page