canonical: https://jentic.com/apis/layerbase.com/layerbase

# Layerbase Cloud API

The Layerbase Cloud API provisions managed databases and runs queries against them over plain HTTPS, with no driver or open socket required. A single create call takes an engine such as postgresql, mysql, redis, valkey, mariadb, mongodb, or clickhouse, plus optional backupPolicy, storageBlocks, and ttlHours for transient databases that are destroyed at expiry. The same surface lists and inspects your databases, reports key identity and usage, and creates, rotates, and revokes the personal API keys that authenticate each call, including keys scoped to a single database.

## For AI agents

Provision Postgres, MySQL, Redis, MongoDB, ClickHouse, and other databases, run queries over HTTP without a driver, and create, rotate, or revoke database-scoped API keys.

## Scope

Does not handle file or object storage, user authentication, schema migrations, or analytics dashboards. Use for provisioning databases, querying them over HTTP, and managing their API keys only.

## Capabilities

- Provision a database on an engine from the public registry, with optional backupPolicy, storageBlocks, and keepAlive
- Spin up a transient database with ttlHours that is destroyed outright at expiry, suited to CI test runs
- Run a SQL query over HTTP against a database by id and read back columns, rows, and rowCount
- List the engines and versions available to provision before creating a database
- Mint an API key scoped to one database with scopeType 'database' and a ttlSeconds expiry
- Rotate or revoke a personal API key by id, and check which key is in use and its usage with the me endpoint

## Use cases

### Agent-run database queries through Jentic

An AI agent that answers questions about application data can call the Layerbase query operation with a SQL string and read the columns and rows straight from the JSON response, without installing a database driver. Through Jentic the agent finds the operation by intent, the bearer key is injected at execution time, and a rule can hold the agent to querying one database id.

Example prompt: Call POST `/v1/databases/{id}/query` with the reporting database id and query 'SELECT status, count(*) FROM orders GROUP BY status', then summarise the returned rows

### Ephemeral databases for CI pipelines

Integration tests need a clean database per run and nothing left behind afterwards. Layerbase provisions a database from an engine name in one call, and setting ttlHours between 1 and 72 makes it transient: an expiry is stamped and the database is destroyed with no final backup, so stale test databases do not pile up.

Example prompt: Call POST `/v1/databases` with engine 'postgresql', name 'ci-run-1842', and ttlHours 2, then poll GET `/v1/databases/{id}` until it is ready

### Least-privilege keys for each service

Rather than sharing one account-wide key, teams can create a key per service with scopeType set to 'database' and scopeId naming the database it may touch, plus a ttlSeconds expiry so it ages out. Keys are rotated or revoked by id when a deploy changes or a service is retired.

Example prompt: Call POST `/v1/api-keys` with name 'billing-worker', scopeType 'database', scopeId set to the billing database id, and ttlSeconds 86400

### Serverless and edge data access

Serverless functions and edge runtimes often cannot hold open database sockets. The Layerbase query operation accepts a query over HTTPS and wakes a hibernated database automatically, returning a 503 with retry_after while it starts, so a function can retry and then read results as JSON.

Example prompt: Call POST `/v1/databases/{id}/query` with query 'SELECT 1', and if the response is 503 wait for retry_after before calling again

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| POST | `/v1/databases` | Provision a database |
| GET | `/v1/databases` | List your databases |
| POST | `/v1/databases/{id}/query` | Run a query over HTTP |
| GET | `/v1/engines` | List available engines |
| POST | `/v1/api-keys` | Create an API key |
| POST | `/v1/api-keys/{id}/rotate` | Rotate an API key |
| DELETE | `/v1/api-keys/{id}` | Revoke an API key |

## Key resources

- **Databases** — Provision, list, and fetch databases, and run queries against one over HTTP
- **Engines** — Public registry of database engines and versions available to provision
- **API keys** — Create account or database-scoped keys, list active keys, rotate and revoke by id
- **Me** — Identify the calling key and report its usage

## AI readiness

This API is usable in Jentic One now. Its AI-readiness score against Jentic's framework shows where it stands today and where improvements would make it even easier for agents to use.

- **Score:** 68 / 100
- **Maturity:** AI-Aware
- **Dimensions:**
  - Foundational Compliance: 93 / 100
  - Developer Experience & Jentic Compatibility: 67 / 100
  - AI-Readiness & Agent Experience: 48 / 100
  - Agent Usability: 94 / 100
  - Security: 60 / 100
  - AI Discoverability: 83 / 100
- **View full report:** https://jentic.com/apis/layerbase.com/layerbase/scorecard
- **How the score is calculated:** https://docs.jentic.com/reference/api-readiness-framework/overview/
- **More about the dimensions:** https://docs.jentic.com/reference/api-readiness-framework/specification/#dimensional-model-overview

### Score it yourself

Every API in the directory is allowlisted, so you can re-score it with no key required.

- **Score your own API:** https://jentic.com/scorecard.md
- **Scoring CLI agent skill:** https://github.com/jentic/jentic-api-scorecard/blob/main/skills/jentic-api-scorecard/SKILL.md

```sh
npx @jentic/api-scorecard-cli score <openapi-url>
```

## Why Jentic

- **Setup:** Wiring Layerbase by hand means managing a bearer key, overriding the server URL with the host from each database's Connect panel, and handling 503 retry_after responses while hibernated databases wake. Through Jentic you install once, import Layerbase from the API Directory, store the key once, and your agent calls it.
- **Permission scoping:** Layerbase puts the database id in the URL path (`/v1/databases/{id}/query`), so a rule can pin your agent to one database and the operations you pick. You choose the operations it may call, so sensitive ones like key revocation or key rotation are not included unless you add them.
- **Credential handling:** Your Layerbase API key is stored once, encrypted, by your own Jentic One instance and injected at execution time. It never enters the agent's prompt, logs, or context.
- **Discovery method:** Agents search Jentic by intent such as 'run a SQL query' or 'provision a temporary database', and Jentic returns the matching Layerbase operation with its input schema so the agent calls the right endpoint without browsing the reference docs.

## Related APIs

- **Neon API** — Serverless Postgres with branching and autosuspend
- **PlanetScale API** — Managed MySQL-compatible databases with deploy requests for schema changes
- **Upstash API** — Serverless Redis and Kafka billed per request
- **Supabase API** — Postgres platform with auth, storage, and edge functions around the database

## FAQ

### Is there a Layerbase MCP server?

You don't need an MCP server to give your agent the Layerbase Cloud API. Jentic connects it directly from the API Directory: import it, store your API key once, and your agent calls it. Operations are discovered on demand, so your agent's context carries no tool definitions it will not use.

### What authentication does the Layerbase Cloud API use?

Per its OpenAPI spec, Layerbase uses HTTP bearer authentication with a personal API key sent as `Authorization: Bearer sk_<your-key>`. An account-scoped key can reach every authenticated endpoint, while a database-scoped key may only call its own database. The health check and engine registry are open. Through Jentic, the key is stored encrypted by your own Jentic One instance and injected at execution time.

### Can I run SQL against a Layerbase database without a driver?

Yes. POST `/v1/databases/{id}/query` takes a JSON body such as { "query": "SELECT 1" } for SQL engines and returns columns, rows, and rowCount. A hibernated database wakes automatically, answering 503 with retry_after while it starts, and a locked database returns 423.

### What are the rate limits for the Layerbase Cloud API?

The OpenAPI spec does not specify rate limits. Check https://layerbase.com/docs/api for current limits and plan quotas.

### How do I create a temporary database through Jentic?

Install Jentic One with `curl -fsSL https://raw.githubusercontent.com/jentic/jentic-one/main/tools/install.sh | sh`, import the Layerbase Cloud API from the directory, and store your API key. Your agent then searches for 'provision a database' and Jentic returns POST `/v1/databases`, which needs only engine and accepts ttlHours to make the database transient. To run it on your own infrastructure, install Jentic One from its GitHub repo.

### Which database engines can Layerbase provision?

Call GET `/v1/engines`, which needs no key, to read the current registry. The spec gives postgresql, mysql, redis, valkey, mariadb, mongodb, and clickhouse as examples of the engine value POST `/v1/databases` accepts, with version defaulting to the engine default from that registry.

### Can I limit what my agent is allowed to do with the Layerbase Cloud API?

Yes. Write a rule that allows only POST `/v1/databases/{id}/query` and GET `/v1/databases/{id}` for your reporting database id: the agent can read that database and run queries against it, while provisioning, other databases, and the API key operations stay out of reach, and every call it makes is logged.
