Change a Postgres database's default schema
Stores the schema a data API request to this database uses when it names none. On a served database the bootstrap re-runs for the new schema (so default privileges cover it) before the answer, and the data API picks the change up at once. Objects already in the new schema get the data API grants only with grant_existing: true; that flag with an unchanged schema grants on its existing objects now.
Authorization
bearer In: header
Path Parameters
Database id
uuidBranch id
uuidThe Postgres database's name
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
A database's data API settings.
The schema a request to this database uses when it names none: ^[a-z_][a-z0-9_]{0,62}$.
Also grant the data API roles on the objects already in the schema (default false).
Without it, only objects created from now on get grants (through default privileges),
plus, once per database, the first schema's existing objects (a database whose first
enable ran while its schema was missing gets that full first grant once the schema
exists, flag or not). Grants only: it never revokes anything. Sent with an unchanged
default_schema it grants on that schema's existing objects now, and answers 409
data_api_disabled when the database isn't served.
Response Body
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
curl -X PATCH "https://example.com/v1/databases/497f6eca-6276-4993-bfeb-53cbbbba6f08/branches/497f6eca-6276-4993-bfeb-53cbbbba6f08/pg-databases/string" \ -H "Content-Type: application/json" \ -d '{ "default_schema": "string" }'{ "data_api": "off", "data_api_error": "string", "default_schema": "string", "main": true, "name": "string", "origin": "main", "owner": "string"}The branch's generated types for a secret key role GET
What `GET /data/v1/types` serves a secret key of `role` on this branch (with no database list), byte for byte: the TypeScript module `db.ts` (`Database` and the runtime `types` map for `@chelabase/client`), or with `format=json` the `types` map alone. Studio's Download types. You may call it when you pass `createKey`'s checks on the caller and the role: Developer access on the branch, not a personal login's role, and a role you may use. Its all-rows exposure check (`exposes_data_api`) does not apply, since types expose the schema and never rows. The `ETag` is the body's hash: send it back as `If-None-Match` for a 304 while the schema is unchanged. Not cached (`Cache-Control: no-store`).
Serve a Postgres database through the data API POST
Marks the database `enabling` and asks the worker to bootstrap it; the answer is 202 at once. Poll the branch's databases for `data_api`: `on`, or `error` with the reason. Pressing it again retries a failed or stuck enable. A database already `on` answers 200 and nothing runs. The branch serves at most `CHELABASE_BRANCH_DATA_API_DATABASE_CAP` databases (default 10, main included).