# Management API reference

The routes behind the [command-line tool](https://rezincore.com/docs/tools/cli.md). They act as *you*, with a [personal access token](https://rezincore.com/docs/tools/access-tokens.md):

```
Authorization: Bearer rzt_…
```

The address is `https://api.rezincore.com`. `<id>` is a project ID: twenty lowercase letters.

A look-only token can call every `GET` and read-only SQL. Anything that changes something needs a read-write token *and* a role in the workspace that may change things.

## Routes

| Route | What it does | Token |
|---|---|---|
| `GET /v1/manage/me` | Which account and token this is | look |
| `GET /v1/manage/projects` | The projects the token reaches | look |
| `GET /v1/manage/projects/<id>/tables` | Tables, columns, row-level security | look |
| `POST /v1/manage/projects/<id>/sql` | Run SQL | look; change with `"write": true` |
| `GET /v1/manage/projects/<id>/migrations` | Migrations already applied | look |
| `POST /v1/manage/projects/<id>/migrations` | Apply one migration | change |
| `GET /v1/manage/projects/<id>/secrets` | Names of secrets, never values | look |
| `PUT /v1/manage/projects/<id>/secrets/<NAME>` | Store or replace a secret | change |
| `GET /v1/manage/projects/<id>/logs?limit=100` | Newest audit entries (1 to 500) | look |
| `GET /v1/manage/projects/<id>/organizations` | The project's organizations | look |
| `GET /v1/manage/projects/<id>/storage/<bucket>?prefix=&org=` | Files in a bucket | look |
| `PUT /v1/manage/projects/<id>/storage/<bucket>/<path>?org=` | Upload a file (the file as the body) | change |
| `GET /v1/manage/projects/<id>/functions` | The project's functions | look |
| `GET /v1/manage/projects/<id>/functions/<name>` | One function's code and settings | look |
| `PUT /v1/manage/projects/<id>/functions/<name>` | Deploy: `{"code": "…"}` becomes the next version and goes live | change |
| `PATCH /v1/manage/projects/<id>/functions/<name>` | Change settings: `enabled`, `requireUser`, `timeoutSeconds`, `everyMinutes`, `secrets`, `version` | change |
| `POST /v1/manage/projects/<id>/functions/<name>/invoke` | Run once as a test: `{"body": "…", "method": "POST"}` | change |
| `GET /v1/manage/projects/<id>/functions/<name>/logs` | How recent runs ended and what they printed | look |
| `DELETE /v1/manage/projects/<id>/functions/<name>` | Remove a function with its versions and logs | change |

### Moving out and in

| Route | |
|---|---|
| `GET /v1/manage/projects/<id>/exports` | Exports made of the project and whether each is ready |
| `POST /v1/manage/projects/<id>/exports` | Start one. Body `{ "passphrase": "..." }` is optional (12 characters or more) |
| `GET /v1/manage/projects/<id>/exports/<export id>/download` | The archive |
| `GET /v1/manage/companies/<company id>/imports` | Imports open in a company |
| `POST /v1/manage/companies/<company id>/imports` | Start one: `{ "source": "supabase", "name": "Orchard" }` (`supabase`, `firebase`, `sql`, `csv`, `rezin`) |
| `PUT /v1/manage/companies/<company id>/imports/<id>/files/<kind>` | Upload a file as the request body (`dump`, `csv`, `archive`, `users`, `firestore`, `storage`, `rules`) |
| `POST /v1/manage/companies/<company id>/imports/<id>/source` | What is typed and never stored: `connectionString`, `projectUrl` with `serviceKey`, `passphrase`, `firebase` |
| `POST /v1/manage/companies/<company id>/imports/<id>/check` | The dry run. Writes nothing |
| `POST /v1/manage/companies/<company id>/imports/<id>/run` | Go ahead: `{ "confirm": "<the new project's name>" }`. Answers with the new project's keys, once |
| `GET /v1/manage/companies/<company id>/imports/<id>` | Status, the dry run's plan, the report |
| `POST /v1/manage/companies/<company id>/imports/<id>/rules` | Put translated access rules in force: `{ "rules": "all" }` |
| `POST /v1/manage/companies/<company id>/imports/<id>/resync` | Bring the data over again |
| `DELETE /v1/manage/companies/<company id>/imports/<id>` | Cancel or close; removes what was uploaded |

Exports need a read-write token given **Database** and **Files**, held by an owner. Imports need a read-write token for the whole company given **Your account and companies**, **Database** and **Files**, held by an owner.

## Examples

### Who am I

```
curl -s https://api.rezincore.com/v1/manage/me -H "authorization: Bearer $REZIN_TOKEN"
```

```json
{ "email": "dev@example.test", "name": "Dev Example", "token": { "level": "read", "expiresAt": "2026-12-26T15:04:05.000Z", "allWorkspaces": false } }
```

### Projects

```json
{ "projects": [ { "id": "…", "ref": "abcdefghijklmnopqrst", "name": "Notes app", "app": "p_abcdefghijklmnopqrst", "workspace": "Example Co", "role": "owner", "defaultOrg": "0d9c8b7a-…" } ] }
```

`ref` is the project ID to use in the other routes. `app` is the project's database schema; the role its application runs as is that name followed by `_app`.

### Run SQL

```
curl -s https://api.rezincore.com/v1/manage/projects/abcdefghijklmnopqrst/sql \
  -H "authorization: Bearer $REZIN_TOKEN" -H "content-type: application/json" \
  -d '{"sql":"select id, title from notes order by created_at desc limit 5"}'
```

```json
{
  "ms": 4,
  "results": [
    { "command": "SELECT", "rowCount": 5, "fields": ["id", "title"], "rows": [["…", "Hello"]], "truncated": false }
  ]
}
```

Rows come back as lists in the order of `fields`. At most 1,000 rows per statement; `truncated` says when there were more. Add `"write": true` to change data or structure.

### Apply a migration

```
curl -s https://api.rezincore.com/v1/manage/projects/abcdefghijklmnopqrst/migrations \
  -H "authorization: Bearer $REZIN_TOKEN" -H "content-type: application/json" \
  -d '{"name":"0002_add_pinned.sql","sql":"alter table notes add column pinned boolean not null default false;"}'
```

```json
{ "name": "0002_add_pinned.sql", "applied": true }
```

Applied again, it answers `{ "name": "…", "applied": false, "note": "Already applied." }`.

### Set a secret

```
curl -s -X PUT https://api.rezincore.com/v1/manage/projects/abcdefghijklmnopqrst/secrets/PAYMENT_KEY \
  -H "authorization: Bearer $REZIN_TOKEN" -H "content-type: application/json" \
  -d '{"value":"…","description":"Payment provider, test mode"}'
```

```json
{ "name": "PAYMENT_KEY", "saved": true }
```

### Logs

```json
{ "events": [ { "seq": 4821, "at": "2026-11-26T15:04:05.000Z", "action": "api.data.insert", "outcome": "success", "resourceType": "table", "organization": "…" } ] }
```

## Errors

| Status | Code | When |
|---|---|---|
| 401 | `bad_token` | Missing, wrong, revoked or expired token. The answer carries `WWW-Authenticate: Bearer`. |
| 403 | `read_only` | The token is look-only, or your role in the workspace is read-only |
| 404 | `not_found` | No such project for this token, or no such organization in it |
| 400 | `bad_request` | Missing or malformed input: a migration name, a secret name, a bucket or path |
| 400 | `sql_error` | The database refused the statement; the message is the database's own |
| 409 | `no_organization` | The project has no organization yet, and files belong to one |
| 503 | `sql_not_ready` | The project's SQL role is not available |

Every call is on the project's audit record as `token.<operation>`, with which token was used.
