Skip to content

Commit d507cd1

Browse files
committed
docs: update CloudSync management API database registration
Document the required projectId field for database registration and clarify how SQLite Cloud hosts, API keys, and databaseName are used in the quickstart. Also document filtered database lookup with projectId and database query parameters, and note that SQLite Cloud operations switch to databaseName while Postgres requires the connection string to target the database.
1 parent eb0fe99 commit d507cd1

1 file changed

Lines changed: 24 additions & 3 deletions

File tree

‎sqlite-cloud/sqlite-ai/sqlite-sync/cloudsync-management-api.md‎

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ Start with an API key from your project's **CloudSync** > **API Keys** page in t
4949
```bash
5050
export BASE_URL="https://cloudsync.sqlite.ai"
5151
export APIKEY="<workspace-admin-management-api-key>"
52+
export PROJECT_ID="<project-id>"
53+
export DATABASE_NAME="appdb"
54+
export SQLITECLOUD_HOST="<sqlitecloud-host>"
55+
export SQLITECLOUD_API_KEY="<sqlitecloud-api-key>"
5256
```
5357

5458
### 1. Register a Database
@@ -61,10 +65,11 @@ curl --request POST "$BASE_URL/v1/databases" \
6165
--header "Content-Type: application/json" \
6266
--data '{
6367
"label": "Primary DB",
64-
"connectionString": "sqlitecloud://project.sqlite.cloud:8860?apikey=xxxx",
68+
"connectionString": "sqlitecloud://'"$SQLITECLOUD_HOST"':8860?apikey='"$SQLITECLOUD_API_KEY"'",
6569
"provider": "sqlitecloud",
6670
"flavor": "sqlitecloud",
67-
"databaseName": "appdb"
71+
"projectId": "'"$PROJECT_ID"'",
72+
"databaseName": "'"$DATABASE_NAME"'"
6873
}'
6974
```
7075

@@ -78,7 +83,7 @@ Response:
7883
}
7984
```
8085

81-
Use that value as `MGMT_DB_ID` in the next calls.
86+
Use `managedDatabaseId` as `MGMT_DB_ID` in the next calls. The response also includes additional database metadata, such as `projectId`, `databaseName`, auth settings, and timestamps.
8287

8388
```bash
8489
export MGMT_DB_ID="db_xxxxxxxxxxxxxxxxxxxxxxxx"
@@ -155,10 +160,12 @@ Required fields:
155160
- `connectionString`
156161
- `provider` — `postgres` or `sqlitecloud`
157162
- `flavor` — for example `vanilla`, `supabase`, or `sqlitecloud`
163+
- `projectId` — SQLite Cloud project identifier for the managed database. For SQLite Cloud connection strings, this must match the project ID parsed from the connection string.
158164
- `databaseName`
159165

160166
Optional fields:
161167

168+
- `workspaceId` — not supported with workspace-scoped keys; the workspace is derived from the key
162169
- `schemaName` — Postgres only
163170
- `jwtAllowedIssuers`
164171
- `jwtExpectedAudiences`
@@ -172,19 +179,33 @@ Important behavior for workspace-scoped keys:
172179

173180
CloudSync verifies the tenant database connection before registration is persisted. If verification fails, the database is not registered.
174181

182+
For SQLite Cloud databases, `databaseName` identifies the target database and CloudSync switches to it when running CloudSync operations. For Postgres databases, the `connectionString` must point to the target database.
183+
175184
Common database failure codes include `database_paused`, `database_auth_failed`, `database_unreachable`, `database_permission_denied`, `database_cloudsync_not_ready`, and `database_error`.
176185

177186
### `GET /v1/databases`
178187

179188
Lists managed databases visible to the key.
180189

190+
Query parameters:
191+
192+
- `projectId` — filter by project ID
193+
- `database` — filter by database name; requires `projectId`
194+
181195
Example:
182196

183197
```bash
184198
curl "$BASE_URL/v1/databases" \
185199
--header "Authorization: Bearer $APIKEY"
186200
```
187201

202+
Filtered example:
203+
204+
```bash
205+
curl "$BASE_URL/v1/databases?projectId=$PROJECT_ID&database=$DATABASE_NAME" \
206+
--header "Authorization: Bearer $APIKEY"
207+
```
208+
188209
### `GET /v1/databases/:databaseID`
189210

190211
Fetches a single managed database in the workspace.

0 commit comments

Comments
 (0)