supabase-admin

Supabase Management API bindings for Hot. Manage projects, organizations, databases, edge functions, preview branches, and custom domains programmatically.

Installation

Add this to the deps in your hot.hot file:

"hot.dev/supabase-admin": "1.0.0"

Configuration

Set the supabase.access.token context variable to a Personal Access Token (PAT) via the Hot app.

Generate a PAT at supabase.com/dashboard/account/tokens.

The package also supports explicit PAT overrides through the low-level ::supabase::admin::api/request arity that accepts an access-token; this is useful for scripts and tests that should not mutate context.

Usage

List Projects

::projects ::supabase::admin::projects

projects ::projects/list-projects()
// => [{id: "abc", name: "My App", region: "us-east-1", ...}, ...]

Get Project API Keys

::projects ::supabase::admin::projects

keys ::projects/get-api-keys("my-project-ref")
// => [{name: "anon", api_key: "eyJ..."}, {name: "service_role", api_key: "eyJ..."}]

Create a Project

::projects ::supabase::admin::projects

project ::projects/create-project(::projects/CreateProjectRequest({
  name: "My New App",
  organization_id: "org-abc-123",
  region: "us-east-1",
  db_pass: "secureDbPassword123!"
}))

Pause / Restore a Project

::projects ::supabase::admin::projects

::projects/pause-project("my-project-ref")
::projects/restore-project("my-project-ref")

List Organizations

::orgs ::supabase::admin::organizations

orgs ::orgs/list-organizations()
members ::orgs/list-members("my-org-slug")

Run a SQL Query

::databases ::supabase::admin::databases

result ::databases/run-query(::databases/RunQueryRequest({
  project_ref: "my-project-ref",
  query: "SELECT count(*) FROM auth.users"
}))

Manage Edge Functions

::functions ::supabase::admin::functions

// List functions
fns ::functions/list-functions("my-project-ref")

// Deploy a function
::functions/create-function(::functions/CreateFunctionRequest({
  project_ref: "my-project-ref",
  slug: "hello-world",
  name: "hello-world",
  body: "Deno.serve(() => new Response('Hello!'))",
  verify_jwt: true
}))

// Delete a function
::functions/delete-function("my-project-ref", "hello-world")

Preview Branches

::branches ::supabase::admin::branches

// List branches
branches ::branches/list-branches("my-project-ref")

// Create a branch
::branches/create-branch(::branches/CreateBranchRequest({
  project_ref: "my-project-ref",
  branch_name: "feat-auth",
  git_branch: "feat/auth"
}))

// Merge back to parent
::branches/merge-branch("branch-id")

Custom Domains

::domains ::supabase::admin::domains

// Configure custom hostname
::domains/update-custom-hostname(::domains/UpdateCustomHostnameRequest({
  project_ref: "my-project-ref",
  custom_hostname: "api.myapp.com"
}))

// Verify DNS and activate
::domains/verify-custom-hostname("my-project-ref")
::domains/activate-custom-hostname("my-project-ref")

API Base URL

https://api.supabase.com/v1

Modules

ModuleDescription
::supabase::admin::projectsProject CRUD, pause/restore, API keys, config, health, usage
::supabase::admin::organizationsOrganization CRUD, members, org projects
::supabase::admin::databasesPostgres config, backups, migrations, SQL query, replicas, upgrades
::supabase::admin::functionsEdge function CRUD, deploy, get source
::supabase::admin::branchesPreview branch CRUD, push, reset, merge
::supabase::admin::domainsCustom hostnames, vanity subdomains
::supabase::admin::apiLow-level Management API client
::supabase::admin::coreShared configuration (BASE_URL)

Integration Tests

Offline unit tests cover known Management API path builders:

cd hot/pkg/supabase-admin
hot test --conf hot.test.hot

1. Generate a Personal Access Token

  1. Go to supabase.com/dashboard/account/tokens
  2. Click Generate new token
  3. Give it a name and copy the token

2. Set Context Variables

supabase.access.token=sbp_your_personal_access_token

3. Run the Tests

hot test hot/pkg/supabase-admin/integration-test/

The tests are read-only -- they list projects, organizations, members, API keys, and health checks. No projects or resources are created or modified.

What the Tests Do

Test FileWhat It TestsSide Effects
projects.hotList projects, get project, API keys, healthRead-only
organizations.hotList orgs, get org, list membersRead-only

Documentation

License

Apache-2.0 - see LICENSE