# org, project and env

These commands are thin wrappers over the `/v1` control API. They need a
signed-in CLI (see [login](https://docs.scribase.com/docs/cli/login.md)) or `SCRIBASE_API_URL` and
`SCRIBASE_ACCESS_TOKEN` in the environment. Every response is printed as JSON.

## Organizations and members

```sh
scribase org put <org> <display-name>        # create or rename
scribase org get <org>
scribase member put <org> <subject> <owner|admin|developer|viewer>
```

Ids (organization, project, environment) are 1 to 63 characters of letters,
digits, `-` and `_`, starting and ending with a letter or digit. On the single-box
layout, the first organization's id is `SCRIBASE_ORGANIZATION_ID`.

## Projects

```sh
scribase project put <org> <project> <region>
scribase project get <org> <project>
scribase project engine <org> <project>
scribase project move <org> <project> --engine neon-local|neon-cloud [--delete-source]
```

- `project put` creates the project on Postgres 17. Use a region id the
  provider honours, for example `aws-eu-central-1`, `aws-us-east-1` or
  `aws-ap-southeast-1` (the console lists them). Any other id is placed in the
  platform's default region.
- `project engine` shows the database engine the project runs on (managed Neon,
  self-hosted Neon, or the box's Postgres), any engine move in progress, and
  what the engine has provisioned for each environment.
- `project move` queues a move to another engine. The data is copied and the
  connection switched. The project's URL and API keys stay the same. Writes
  pause while the data is copied, and the source database is kept unless you
  pass `--delete-source`.

## Environments

```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>
scribase env renew   <org> <project> <env> <ttl-hours> <idempotency-key>
```

| Argument | Values |
|---|---|
| `kind` | `production`, `staging`, `preview` |
| `data-mode` | `snapshot` (copy of the parent's data), `sanitized` (copy, then anonymized), `schema_only` |
| `ttl-hours` | Optional. A preview is swept when it expires; `env renew` extends it from now |
| `idempotency-key` | Any unique string. Re-running a command with the same key returns the original result instead of repeating the change |

Example:

```sh
scribase env create acme my-app production production snapshot aws-eu-central-1 prod-create-1
scribase env create acme my-app pr-42 preview sanitized aws-eu-central-1 pr-42-create 72
```

## Operations and audit

Mutations return an operation id. Poll it until it finishes:

```sh
scribase operation get <org> <operation-id>
scribase audit list <org> [after limit]
```

## Not yet in the CLI

The CLI cannot list organizations, projects or environments yet, and cannot
delete a project. Use the console or the API
([Organizations](https://docs.scribase.com/docs/api/organizations.md), [Projects](https://docs.scribase.com/docs/api/projects.md),
[Environments](https://docs.scribase.com/docs/api/environments.md)) for those.
