Query example
Client request
POST /index.php
{
"op": "query",
"payload": {
"queries": [{
"ref": "items",
"sql": "itemsByOrderId",
"params": {"order_id": 42},
"options": {
"orderby": [{"field": "id", "dir": "desc"}],
"top": 25,
"count": true
}
}]
}
}
Server response
{
"results": [{
"ref": "items",
"meta": {"columns": ["id", "product_id"], "rows": 25},
"rows": [[91, 77], [90, 61]],
"count": 25,
"total_count": 63
}]
}
Client behavior
Render the current page, show total count for pagination, and sort indicator in the table header.
Use case
Order detail screen loading item rows with paging and sorting.
Validation example
Client request
POST /index.php
{
"op": "mutation",
"payload": {
"transaction": false,
"mutations": [{
"table": "products",
"action": "update",
"ref": "bad_price",
"filter": {"id": 42},
"data": {"price": -15}
}]
}
}
Server response
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Price must be positive"
}
}
Client behavior
Keep the form open, highlight the price field, and show the validation message inline without reloading data.
Use case
Back-office product editor preventing invalid pricing before save.
Hook example
Client request
POST /index.php
{
"op": "mutation",
"payload": {
"transaction": false,
"mutations": [{
"table": "products",
"action": "update",
"ref": "hooked_update",
"filter": {"id": 42},
"data": {"price": 109.99, "stock": 12}
}]
}
}
Server response
{
"results": [{
"ref": "hooked_update",
"action": "update",
"table": "products",
"affected": 1
}]
}
Server behavior
Configured before-hook can check policy; after-hook can write logs, invalidate cache, or notify another system.
Client behavior
Show success toast and refetch product detail if hooks can affect derived data shown on screen.
Transaction example
Client request
POST /index.php
{
"op": "mutation",
"payload": {
"transaction": true,
"mutations": [
{
"table": "orders",
"action": "insert",
"ref": "new_order",
"data": {"user_id": 1, "total": 199.99, "status": "pending"}
},
{
"table": "order_items",
"action": "insert",
"data": {"order_id": 1, "product_id": 42, "quantity": 2, "price": 99.99}
}
]
}
}
Server response
{
"results": [
{"ref": "new_order", "action": "insert", "table": "orders", "affected": 1},
{"ref": null, "action": "insert", "table": "order_items", "affected": 1}
]
}
Client behavior
Treat success as one atomic operation. If the request fails, show one checkout error and do not partially update UI state.
Use case
Create order header and items together during checkout.
Command example
Client request
POST /index.php
{
"op": "command",
"payload": {
"name": "order.process",
"params": {
"order_id": 42,
"payment_method": "credit_card"
}
}
}
Server response
{
"status": 200,
"order_id": 42,
"new_status": "processing",
"mutations_applied": 2
}
Client behavior
Advance the order UI to the next step, refresh status badges, and show a workflow-specific success message.
Use case
Checkout, billing, onboarding, batch shipping, or other domain workflow that is bigger than plain CRUD.
Analytics dashboard query
{
"op": "query",
"payload": {
"queries": [{
"ref": "sales",
"sql": "salesByDay",
"options": {
"groupby": ["day"],
"aggregate": [{"field":"amount","fn":"sum","as":"total_amount"}],
"orderby": [{"field":"day","dir":"asc"}]
}
}]
}
}
Client renders chart series from grouped totals.
Admin provisioning
{
"op": "auth.admin.create-user",
"payload": {
"email": "agent@example.com",
"password": "StrongPass123",
"role": "user"
}
}
Client updates user management table after 201 response.
Workflow command button
{
"op": "command",
"payload": {
"name": "orders.ship_batch",
"params": {
"order_ids": [101, 102, 103],
"carrier": "dhl"
}
}
}
Client shows one progress action for a multi-step backend workflow.