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

# MySQL REST Service (MRS) API

Jentic publishes the only available OpenAPI specification for MySQL REST Service (MRS) API, keeping it validated and agent-ready. The MySQL REST Service exposes MySQL database tables, views, and stored procedures as REST endpoints, with CRUD operations on /{schema}/{object}, stored procedure execution on /{schema}/{procedure}, JWT authentication on `/authentication/login` and `/authentication/logout`, and static content serving on /{contentPath}. It supports filtering, pagination, sorting, and optimistic concurrency control via ETags, and accepts MySQL Internal, SCRAM, and OAuth2 authentication. The base URL is templated by host, port, and serviceName so each MRS deployment self-configures.

## For AI agents

Read, write, and update MySQL data through the REST Service using a JWT bearer token or session cookie obtained via `/authentication/login.`

## Scope

Does not handle database provisioning, schema migrations, or replication topology - use for REST CRUD, stored procedure execution, and authentication against an existing MRS deployment only.

## Capabilities

- List documents from a MySQL table or view via GET /{schema}/{object} with filtering, pagination, and sorting
- Create new rows via POST /{schema}/{object} with JSON document payloads
- Retrieve a row by primary key via GET /{schema}/{object}/{id}
- Update a row by primary key via PUT /{schema}/{object}/{id} with optimistic concurrency via ETags
- Delete a row by primary key via DELETE /{schema}/{object}/{id}
- Execute a stored procedure via POST /{schema}/{procedure}
- Authenticate via POST `/authentication/login` to mint a JWT and POST `/authentication/logout` to invalidate it

## Use cases

### Headless MySQL Backend for Agents

Expose a MySQL database to AI agents and external services through MRS without writing a custom backend. The integration authenticates via POST `/authentication/login`, then performs CRUD on /{schema}/{object} and /{schema}/{object}/{id}. Filtering and pagination query parameters mean an agent can read scoped data without DBA-level access.

Example prompt: Authenticate with POST `/authentication/login`, then GET `/sales/orders`?status=open to retrieve open orders, and POST `/sales/orders` to insert a new one.

### Stored Procedure Execution

Trigger MySQL stored procedures from a workflow, agent, or scheduled job via POST /{schema}/{procedure}. The integration sends the procedure inputs as JSON, MRS executes the procedure inside the database, and returns the result set or output parameters. This keeps complex business logic inside MySQL while exposing it as a normal REST call.

Example prompt: Call POST `/finance/calculate_discount` with the order ID and customer tier as JSON input, and return the calculated discount value.

### Optimistic Concurrency on Updates

Update a MySQL row safely under concurrent edits using PUT /{schema}/{object}/{id} with the ETag from the prior GET. MRS rejects the update if the underlying row changed since the GET, eliminating lost-update bugs in shared-write environments. This pattern is essential for inventory, ticketing, and ledger workloads.

Example prompt: GET `/inventory/items/4421` to capture the ETag, then PUT `/inventory/items/4421` with the new payload and `If-Match: {etag}` header.

### Authenticated Static Content Delivery

Serve documents, blobs, or static assets from MRS via GET /{contentPath}, gated by the same authentication used for data endpoints. The integration uses a single JWT to access both API and content paths, simplifying credential management for apps that need both data and files from MySQL-managed sources.

Example prompt: After login, GET `/docs/contracts/4421.pdf` with the JWT in the Authorization header to retrieve the contract document.

### AI Agent Database Operator

An AI agent acts as a database operator for an internal team. It searches Jentic for MRS operations, loads the authentication and CRUD schemas, and chains POST `/authentication/login` with GET /{schema}/{object} and POST /{schema}/{procedure} to answer natural-language data questions. Jentic isolates the JWT and login credentials so the agent never sees raw database secrets.

Example prompt: Search Jentic for 'query the MySQL orders table', authenticate via POST `/authentication/login`, then GET `/sales/orders` filtered by the date range in the request.

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| POST | `/authentication/login` | Authenticate and mint a JWT |
| POST | `/authentication/logout` | Logout and invalidate the session |
| GET | `/{schema}/{object}` | List documents from a table or view |
| POST | `/{schema}/{object}` | Create a new document |
| GET | `/{schema}/{object}/{id}` | Retrieve a document by ID |
| PUT | `/{schema}/{object}/{id}` | Update a document with ETag concurrency |
| DELETE | `/{schema}/{object}/{id}` | Delete a document by ID |
| POST | `/{schema}/{procedure}` | Execute a stored procedure |

## Key resources

- **Documents (table/view CRUD)** — List, create, get, update, and delete rows on /{schema}/{object} and /{schema}/{object}/{id}.
- **Stored procedures** — Execute MySQL stored procedures via POST /{schema}/{procedure}.
- **Authentication** — Login and logout to obtain or revoke JWTs and session cookies.
- **Static content** — Serve files and assets from MRS via /{contentPath}.

## Why Jentic

- **Setup:** Wiring the MySQL REST Service by hand means calling its authentication login, holding the minted JWT or session cookie, and setting the host, port, and service name for your own MRS deployment yourself. Through Jentic you install once, import the MySQL REST Service from the API Directory, store the login secret once, and your agent calls it.
- **Permission scoping:** MRS puts the schema, object, and row id in the URL path (/{schema}/{object}/{id}), so a rule can pin your agent to one table. You choose the operations it may call, so destructive ones like DELETE on a row are not included unless you add them.
- **Credential handling:** Your MRS login secret and minted JWT are stored once, encrypted, by your own Jentic One instance and injected at execution time. They never enter the agent's prompt, logs, or context.
- **Discovery method:** Agents search Jentic by intent such as 'query the MySQL orders table' or 'run a stored procedure', and Jentic returns the matching MRS operation with its JSON Schema so the agent calls the right endpoint without browsing the reference docs.

## Related APIs

- **Supabase API** — Supabase exposes a Postgres database over a REST + Realtime layer, the closest direct alternative to MRS for Postgres workloads.
- **PlanetScale API** — PlanetScale offers a managed MySQL-compatible database with a control-plane API.
- **MongoDB Atlas API** — MongoDB Atlas covers document-store workloads alongside MRS's relational coverage.

## FAQ

### Why is there no official OpenAPI spec for MySQL REST Service (MRS) API?

Oracle / MySQL does not publish an OpenAPI specification. Jentic generates and maintains this spec so that AI agents and developers can call MySQL REST Service (MRS) API via structured tooling. It is validated against the live API and kept up to date. Get started with Jentic One, the self-hosted execution layer.

### What authentication does the MySQL REST Service use?

MRS supports two schemes: a JWT bearer token (preferred) obtained via POST `/authentication/login`, and a session cookie set during OAuth2 login with sessionType=cookie. Through Jentic, login credentials are stored in the encrypted vault and the JWT or cookie is injected at execution time.

### Can I run a stored procedure with the MySQL REST Service?

Yes. Call POST /{schema}/{procedure} with the procedure inputs as JSON. MRS executes the procedure inside MySQL and returns the result set or output parameters in the response body. This works for both side-effect procedures (like calculate_discount) and read-only procedures.

### How do I avoid lost updates with concurrent edits?

Use the ETag returned from GET /{schema}/{object}/{id} on the subsequent PUT by sending an `If-Match: {etag}` header. MRS rejects the update with a 412 Precondition Failed if the row has changed since the GET, giving you optimistic concurrency without database-level locks.

### How do I query data through Jentic?

Search Jentic for 'list documents from MySQL', load the GET /{schema}/{object} schema, and execute it with the schema, object, and any filter parameters. Chain POST `/authentication/login` first if no token has been minted, then reuse the JWT for subsequent calls.

### What are the rate limits for the MySQL REST Service API?

MRS rate limits are governed by the host MySQL Router and database configuration rather than the spec itself. Treat connection and query throughput as your effective limit, batch reads with pagination, and prefer stored procedures over chatty per-row updates for large jobs.

### Can I limit what my agent is allowed to do with the MySQL REST Service (MRS) API?

Yes. Because you run Jentic One self-hosted, your own rules decide which MRS operations the agent may call and which credentials it may use. Since MRS puts the schema, object, and row id in the URL path (/{schema}/{object}/{id}), you can pin the agent to a single table and grant only the operations it needs, such as GET /{schema}/{object} for reads while withholding DELETE /{schema}/{object}/{id} and POST /{schema}/{procedure}. The MRS login secret and minted JWT stay under your control and are injected at execution time, so the agent never handles the raw database credentials.
