BWEZE Docs

Backends

A hosted Postgres stack per backend - database REST API, auth, storage, edge functions and realtime - behind one URL and two keys.

A backend is a Postgres database with the services an app usually builds around it, running in its own isolated space and reached at one URL:

PartWhat you get
DatabasePostgres 15 with pgvector, pg_cron, pgcrypto and http; a REST API over your tables (PostgREST filters), and Postgres functions as RPC
AuthEmail and password sign-up and sign-in, Google and GitHub sign-in, sessions with refresh tokens
StorageBuckets, public or private, for files your app stores
Edge functionsTypeScript functions on Deno, each at its own path, 60 seconds per call
RealtimeChannels over Socket.IO, and webhooks when a message is published
SchedulesCalls to a URL on a cron schedule, run by pg_cron

Create one

In BWEZE Platform, open Backends and click Create backend (or create one from a project's page), or call the API:

curl -X POST https://api.bweze.com/v1/backends \
  -H "authorization: Bearer bw_sk_..." -H "content-type: application/json" \
  -d '{ "name": "acme-db" }'

The name is 2-31 lowercase letters, digits and hyphens, unique in the workspace. The backend starts at once and answers at https://<name>-<id>.bweze.app.

GET /v1/backends/{id} reports its status: starting, running:healthy, degraded, exited:unhealthy or exited. POST /v1/backends/{id}/deploy starts or restarts it.

Keys

curl https://api.bweze.com/v1/backends/BACKEND_ID/keys \
  -H "authorization: Bearer bw_sk_..."
{ "url": "https://acme-db-1a2b3c4d.bweze.app", "anonKey": "anon_…", "serviceRoleKey": "ik_…", "postgresPassword": "…" }
  • anonKey (anon_…) is safe in browser and mobile code. Requests made with it act as an anonymous user, limited by your row-level security policies.
  • serviceRoleKey (ik_…) bypasses those policies. Keep it on your servers, never in client code.

Every key and password is generated for this backend alone. Reading them needs a token with backend:create. bweze secrets rotate api-key or anon-key replaces one, with a grace period for the old one.

No direct database connections

Postgres is not reachable from outside the backend: apps and tools talk to it through the backend's URL, not over the Postgres protocol. Use the REST API, bweze db query, or bweze db export and import.

Use it from your app

There is no client SDK to install: it is plain HTTP with a bearer token, the anon key until a user signs in and their access token after.

const BWEZE_URL = process.env.BWEZE_URL!; // https://acme-db-1a2b3c4d.bweze.app
let token = process.env.BWEZE_ANON_KEY!;

const api = (path: string, init: RequestInit = {}) =>
  fetch(`${BWEZE_URL}${path}`, {
    ...init,
    headers: { authorization: `Bearer ${token}`, "content-type": "application/json", ...init.headers },
  }).then((r) => r.json());

// Sign up, then sign in
await api("/api/auth/users", { method: "POST", body: JSON.stringify({ email, password }) });
const session = await api("/api/auth/sessions", { method: "POST", body: JSON.stringify({ email, password }) });
token = session.accessToken;

// Query a table with PostgREST filters
const posts = await api("/api/database/records/posts?status=eq.published&order=createdAt.desc&limit=10");

// Insert rows (the body is always an array)
await api("/api/database/records/posts", {
  method: "POST",
  headers: { Prefer: "return=representation" },
  body: JSON.stringify([{ title: "Hello", content: "World" }]),
});

// Call a Postgres function, and an edge function (no /api prefix)
await api("/api/database/rpc/get_user_stats", { method: "POST", body: JSON.stringify({ user_id: "…" }) });
await api("/functions/hello-world", { method: "POST", body: JSON.stringify({ name: "Ada" }) });

Errors come back as { error, message, statusCode, nextActions }.

  • Sessions: a browser sign-in sets the refresh token as an httpOnly cookie and returns a csrfToken; send it as X-CSRF-Token to POST /api/auth/refresh. Other clients add ?client_type=mobile|desktop|server and send refreshToken in the body.
  • Storage uploads take two or three calls: POST /api/storage/buckets/{bucket}/upload-strategy, upload the bytes to the URL it returns, then POST .../objects/{key}/confirm-upload when the strategy asks for it. Download with GET /api/storage/buckets/{bucket}/download-strategy/objects/{key}.
  • Realtime: connect with socket.io-client, passing the user's token or the anon key as auth.token.

The backend documents itself for agents: GET <url>/api/docs/instructions starts there, and /api/docs/{db|auth|storage|functions|realtime}/rest-api covers each part.

From the CLI

Link the directory to the backend's project, then:

bweze link --project-id <id>
bweze db tables
bweze db query "select id, email from users limit 10"
bweze db migrations new add_orders && bweze db migrations up
bweze functions deploy hello-world --file ./functions/hello-world.ts
bweze storage create-bucket avatars --public
bweze secrets add RESEND_API_KEY re_...
bweze logs postgres.logs

See the CLI for every command.

Limits

Database disk10 GiB
Storage disk10 GiB
Logs2 GiB
Memory1,664 MiB reserved across the four services (Postgres 768 MiB at most)
ReplicasOne of each service: no failover
Edge function call60 seconds

Memory and storage are billed while the backend exists; see Pricing. Disk sizes cannot be changed from the dashboard yet.

Backups and deletion

Keep your own backups

BWEZE runs in one data center during the beta, and the nightly backup job is not running yet. Export anything you cannot lose: bweze db export --format sql -o backup.sql.

Deleting a backend takes it off the internet at once. Its data is purged only after a backup newer than the deletion exists.

curl -X DELETE https://api.bweze.com/v1/backends/BACKEND_ID \
  -H "authorization: Bearer bw_sk_..." -H "content-type: application/json" \
  -d '{ "confirm": "acme-db" }'

confirm must be the backend's name (400 confirmation_required otherwise), and the token needs backend:delete.

On this page