PgBeam Docs
Databases

CreateDatabase

Add a database

Registers a new upstream PostgreSQL database for the project.

Usage

result, err := client.Databases.CreateDatabase(ctx, &pgbeam.CreateDatabaseRequest{
    Host: "...",
    Port: 5432,
    Name: "...",
    Username: "...",
    Password: "...",
  })

Parameters

ParameterTypeRequiredDescription
ctxcontext.ContextYesRequest context
req*pgbeam.CreateDatabaseRequestYesRequest body
req.HoststringYesPostgreSQL host.
req.PortintYesPostgreSQL port.
req.NamestringYesPostgreSQL database name.
req.UsernamestringYesPostgreSQL username.
req.PasswordstringYesPostgreSQL password. Stored encrypted at rest.
req.SSLMode*pgbeam.SSLModeNo
req.Role*pgbeam.DatabaseRoleNo
req.PoolRegion*stringNoRegion 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.
req.CacheConfig*pgbeam.CacheConfigNo
req.PoolConfig*pgbeam.PoolConfigNo

Response

(*pgbeam.Database, error) — database created.

Example

import pgbeam "github.com/pgbeam/pgbeam-go"

client := pgbeam.NewClient(&pgbeam.ClientOptions{
  APIKey: "pgb_your_api_key",
})

result, err := client.Databases.CreateDatabase(ctx, &pgbeam.CreateDatabaseRequest{
    Host: "...",
    Port: 5432,
    Name: "...",
    Username: "...",
    Password: "...",
    SSLMode: pgbeam.SSLMode{ /* ... */ },
  })
if err != nil {
  log.Fatal(err)
}
fmt.Println(result)

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