# CLI Reference

The `scribase` CLI is the primary interface for both local development and the
production control-plane management API. It has no library dependencies beyond
the binary itself and `curl` for API calls.

## Configuration

```sh
export SCRIBASE_API_URL=https://api.scribase.com   # or your own cluster's gateway
export SCRIBASE_ACCESS_TOKEN=<token>               # see /docs/api/tokens
# Optional: override the curl binary
export SCRIBASE_CURL_BINARY=/usr/local/bin/curl
```

Or run [`scribase login`](https://docs.scribase.com/docs/cli/login.md) once, which stores the URL and a
token; the environment variables always win over the stored values.

Plain HTTP is only accepted for `localhost`, `127.0.0.1`, and `[::1]`. The
access token and request bodies are piped to `curl` through stdin configuration
and never appear in process arguments or debug output.

## Command groups

| Command | Description |
|---|---|
| [`doctor`](https://docs.scribase.com/docs/cli/doctor.md) | Check API connectivity and token configuration |
| [`login`, `logout`, `whoami`, `token`](https://docs.scribase.com/docs/cli/login.md) | Sign in with a token or the built-in password login; manage personal access tokens |
| [`admin`](https://docs.scribase.com/docs/admin-login.md) | Create the first built-in administrator, hash an admin password |
| [`org`, `project`, `env`, `member`](https://docs.scribase.com/docs/cli/resources.md) | Create and read organizations, projects and environments |
| [`backup`, `restore`](https://docs.scribase.com/docs/cli/backup.md) | Take, verify and restore backups |
| [`apps switch`](https://docs.scribase.com/docs/cli/apps.md) | Print the URL and public key an app needs |
| [`gen types`](https://docs.scribase.com/docs/cli/gen-types.md) | TypeScript `Database` types for supabase-js |
| [`vercel env push`](https://docs.scribase.com/docs/cli/vercel.md) | Set the URL and keys on the linked Vercel project |
| [`dev`](https://docs.scribase.com/docs/cli/dev.md) | Local database and service stack |
| [`migrate`](https://docs.scribase.com/docs/cli/migrate.md) | Run migrations against a remote environment |
| [`db pull`](https://docs.scribase.com/docs/cli/db-pull.md) | Capture a remote schema as a local migration file |
| [`branch`](https://docs.scribase.com/docs/cli/branch.md) | Manage branches (local and remote) |
| [`queue`](https://docs.scribase.com/docs/cli/queue.md) | Interact with environment queues |
| [`import`](https://docs.scribase.com/docs/cli/import.md) | Import a schema or migrate a Supabase project |
| [`export`](https://docs.scribase.com/docs/cli/export.md) | Export a runnable bundle for an environment, then list and download it |
| [`functions`](https://docs.scribase.com/docs/cli/functions.md) | Deploy, inspect, invoke and roll back edge functions |
| [`secrets`](https://docs.scribase.com/docs/cli/secrets.md) | Manage the secrets bound into an environment's functions |
| [`schema`](https://docs.scribase.com/docs/cli/schema.md) | Compile and test schema files |
| [`insights`](https://docs.scribase.com/docs/cli/insights.md) | Analyze a live environment for improvements |
| `operation` | Poll a running operation |
| `audit` | List audit events |
| `version` | Print CLI version |

## Resource commands

These follow the pattern `scribase <resource> <action> [args...]`.

### org

```sh
scribase org put <org-id> <display-name>
scribase org get <org-id>
```

### member

```sh
scribase member put <org-id> <subject> <owner|admin|developer|viewer>
```

### project

```sh
scribase project put <org-id> <project-id> <region>
scribase project get <org-id> <project-id>
```

### env

```sh
scribase env create <org> <project> <env> <kind> <data-mode> <region> <idempotency-key> [ttl-hours]
scribase env get <org> <project> <env>
scribase env suspend <org> <project> <env> <idempotency-key>
scribase env resume  <org> <project> <env> <idempotency-key>
scribase env delete  <org> <project> <env> <idempotency-key>
```

**Environment kinds:** `production`, `preview`, `development`

**Data modes:** `snapshot`, `schema-only`, `empty`

### operation

```sh
scribase operation get <org-id> <operation-id>
```

Operations are asynchronous. Poll until `state` is `succeeded` or `failed`.

### audit

```sh
scribase audit list <org-id>
scribase audit list <org-id> <after-cursor> <limit>
```

Limit must be between 1 and 200.
