SmartFBX REST API — detailed reference

This page documents every REST endpoint of SmartFBX: parameters with type and default, response format, errors and an example. It complements chapter 10 of the user guide. The MCP tools are documented in the MCP reference.

The example responses use the demo database of the guide and are illustrative: they show the structure produced by the source code, not a captured response. Field names in rows returned "as from the catalog" are the uppercase column names of the underlying query.

General rules

Base URL and transport

Item Value
Base URL http://<API listen address>:<API port> — default http://127.0.0.1:6615
Encoding UTF-8, Content-Type: application/json; charset=utf-8
CORS Access-Control-Allow-Origin: *; methods GET, POST, PUT, DELETE, OPTIONS
Log Every request is listed in Tools > API log

Passing parameters

Authentication

When an access token is set in File > Settings > Access token, every request must carry it in one of these headers:

Authorization: Bearer <token>
X-Access-Token: <token>

Without the token (or with a wrong one) the answer is 403 {"ok":false,"error":"Access forbidden"}. With an empty token in the settings no check is made; in that case the write endpoints (crud/insert, crud/update, crud/delete, sp/execute) only accept requests from the same computer (127.0.0.1, ::1).

Response envelope

{ "ok": true,  "data": <result> }
{ "ok": false, "error": "message" }
HTTP status Meaning
200 Success
400 Missing or invalid parameter (message says which)
403 Access token missing or wrong; write request from another computer without token; ReadOnly violated
404 Script, object or connection not found
409, 422, 429 Agent endpoints: conflict, database error, too many pending changes (see agent endpoints)
500 Database or connection error; error contains the message of the engine

Rows

Endpoints that return rows produce an array of objects, one per row, with the column names as keys:

[ { "CUSTOMER_ID": 1, "COMPANY_NAME": "Northwind Traders", "CITY": "Milan" } ]

Database

GET /api/fb/db/connections

Names of the connections configured in SmartFBX. Does not open any database.

Parameters: none.

Response data: array of strings.

GET /api/fb/db/connections
{"ok":true,"data":["prova locale","prova locale - copy","prova2","prova3"]}

GET /api/fb/db/info

Opens the connection and returns its main properties.

Parameter Type Default Notes
ConnectionName string selected connection

Response data: object.

Field Type Content
connected boolean Connection opened
database string Database path or alias
server string Server (empty for embedded)
driver string FireDAC driver actually used
fb_version string Engine version
{"ok":true,"data":{"connected":true,"database":"C:\\Users\\me\\Documents\\prova.fdb","server":"","driver":"FB50Embedded","fb_version":"5.0.4"}}

Errors: 500 if the connection cannot be opened.

Metadata

GET /api/fb/meta/schema/summary

Overview of the database: call it first to get oriented.

Parameter Type Default
ConnectionName string selected connection

Response data:

Field Type Content
fb_version string Engine version
database, server string Connection target
default_charset string Default character set of the database
page_size integer Page size in bytes
dialect integer SQL dialect
counts object tables, views, procedures, functions, triggers, generators, domains, exceptions, fk_total
{"ok":true,"data":{"fb_version":"5.0.4","database":"C:\\...\\prova.fdb","server":"","default_charset":"UTF8","page_size":16384,"dialect":3,
 "counts":{"tables":4,"views":1,"procedures":2,"functions":1,"triggers":4,"generators":4,"domains":3,"exceptions":1,"fk_total":3}}}

GET /api/fb/meta/tables

User tables, optionally filtered.

Parameter Type Default Notes
ConnectionName string selected
Filter string — Substring of the name, case-insensitive
SystemTables boolean false Include RDB$/MON$ tables

Response data: array of { "name": string, "description": string }.

GET /api/fb/meta/tables?ConnectionName=prova%20locale&Filter=ORD
{"ok":true,"data":[{"name":"ORDERS","description":"Sales order headers"},{"name":"ORDER_LINES","description":"Sales order lines"}]}

GET /api/fb/meta/table

Complete structure of one table.

Parameter Type Default Notes
ConnectionName string selected
TableName string required
WithFields boolean see notes If all four With* are false or missing, all four are treated as true
WithIndexes boolean see notes
WithFK boolean see notes
WithTriggers boolean see notes

Response data:

Field Type Content
table string Name in uppercase
description string Table comment
fields array Rows from the catalog: name (OBJECT_NAME), type (DTYPE), domain (FIELD_DOMAIN), RDB$NULL_FLAG, IN_PK (1 = primary key, 2 = no), DEFAULT_SOURCE, ...
indexes array Rows from the catalog: index name, fields, unique, inactive
fk array { "constraint": string, "field": string }
triggers array Rows from the catalog: trigger name, type, position, active

Errors: 400 TableName required; 500 database error.

GET /api/fb/meta/views

Views of the database. Parameters: ConnectionName. Response data: rows from the catalog (view name, source).

GET /api/fb/meta/procedures

Parameter Type Default Notes
ConnectionName string selected
Filter string — Substring of the name
WithParams boolean false Adds params to each item

Response data: array of { "name": string, "params": [rows] } (params only with WithParams; rows from RDB$PROCEDURE_PARAMETERS with name, RDB$PARAMETER_TYPE 0 = input / 1 = output, type).

GET /api/fb/meta/functions

Parameter Type Default Notes
ConnectionName string selected
Filter string —
WithParams boolean false Adds the arguments
ExcludeUDF boolean false Excludes legacy UDFs (DECLARE EXTERNAL FUNCTION)

Response data: array of { "name": string, "params": [rows] }.

GET /api/fb/meta/generators

Parameter Type Default Notes
ConnectionName string selected
Filter string —
WithValue boolean false Reads the current value with GEN_ID(name, 0)

Response data: array of { "name": string, "current_value": integer }.

{"ok":true,"data":[{"name":"GEN_ORDERS_ID","current_value":7}]}

GET /api/fb/meta/domains

Parameter Type Default Notes
ConnectionName string selected
Filter string — Substring of the name
UserDefinedOnly boolean false in REST (true in MCP) true excludes names starting with RDB$, MON$, SEC$; false excludes only RDB$ (implicit field domains are never listed)

Response data: array of objects:

Field Type
name, type, default_value, check_expr, charset string
size, precision, scale integer
not_null boolean
{"ok":true,"data":[{"name":"DM_MONEY","type":"NUMERIC","size":8,"precision":15,"scale":-2,"not_null":false,"default_value":"DEFAULT 0","check_expr":"","charset":""}]}

GET /api/fb/meta/ddl

DDL of an object.

Parameter Type Default Values
ConnectionName string selected
ObjectName string required
ObjectType string table table, view, procedure, function, trigger

Response data: string with the DDL.

{"ok":true,"data":"create or alter procedure SP_ADD_ORDER_LINE (A_ORDER_ID BIGINT, ...)\nreturns (NEW_TOTAL NUMERIC(15,2))\nas\n..."}

Errors: 400 ObjectName required.

GET /api/fb/meta/dependencies

Parameter Type Default Values
ConnectionName string selected
ObjectName string required
Direction string both uses (what the object uses), used_by (who uses it), both

Response data: rows with OBJECT_NAME, DEPENDS_ON, RDB$DEPENDENT_TYPE, RDB$DEPENDED_ON_TYPE. Type codes: 0 table, 1 view, 2 trigger, 3 computed field, 4 check, 5 procedure, 6 index expression, 7 exception, 8 user, 9 field, 10 index, 14 generator, 15 function/UDF, 17 collation, 18 package, 19 package body.

{"ok":true,"data":[{"OBJECT_NAME":"V_ORDER_SUMMARY","DEPENDS_ON":"ORDERS","RDB$DEPENDENT_TYPE":1,"RDB$DEPENDED_ON_TYPE":0}]}

GET /api/fb/meta/fk-graph

Foreign-key graph of the whole database or around one table.

Parameter Type Default Values
ConnectionName string selected
TableName string — Pivot table (empty = whole database)
Direction string — from (keys going out of the table), to (keys pointing to it), empty = both

Response data:

Field Content
nodes [{ "name": table, "description": comment }]
edges [{ "from_table", "to_table", "constraint", "update_rule", "delete_rule", "from_fields", "to_fields" }]
{"ok":true,"data":{"nodes":[{"name":"ORDERS","description":""},{"name":"CUSTOMERS","description":""}],
 "edges":[{"from_table":"ORDERS","to_table":"CUSTOMERS","constraint":"INTEG_12","update_rule":"RESTRICT","delete_rule":"RESTRICT","from_fields":["CUSTOMER_ID"],"to_fields":["CUSTOMER_ID"]}]}}

SQL and DDL

POST /api/fb/sql/execute

Runs a statement.

Parameter Type Default Notes
ConnectionName string selected
SQL string required One statement
MaxRows integer 0 → 500 Maximum rows returned for a SELECT
ReadOnly boolean false in REST (true in MCP) true = only statements starting with SELECT

Always send "ReadOnly": true for queries: in REST a missing value allows INSERT, UPDATE, DELETE.

Response data: for SELECT, array of rows; otherwise { "rows_affected": integer }. DML runs in its own transaction and is committed.

POST /api/fb/sql/execute
{"ConnectionName":"prova locale","SQL":"select ORDER_ID, STATUS, TOTAL from ORDERS where STATUS = 'NEW'","ReadOnly":true}
{"ok":true,"data":[{"ORDER_ID":4,"STATUS":"NEW","TOTAL":447},{"ORDER_ID":6,"STATUS":"NEW","TOTAL":354}]}

Errors: 400 SQL required; 403 ReadOnly: only SELECT allowed; 500 database error.

POST /api/fb/sql/explain

Parameter Type Default
ConnectionName string selected
SQL string required

Response data: { "plan": string }.

{"ok":true,"data":{"plan":"PLAN SORT (JOIN (S C NATURAL, S O INDEX (RDB$FOREIGN5)))"}}

POST /api/fb/ddl/execute

Runs one DDL statement (CREATE, ALTER, DROP, RECREATE, COMMENT, ...).

Parameter Type Default Notes
ConnectionName string selected
SQL string required One DDL statement
DryRun boolean false in REST (true in MCP) true = runs it in a transaction and rolls back

Send "DryRun": true first: in REST a missing value applies the statement.

Response data:

Field Type Content
executed boolean Statement applied
dry_run boolean
ddl_type string First two words, e.g. ALTER TABLE
statement string Statement executed
rows_affected integer
message string Result text
{"ok":true,"data":{"executed":false,"dry_run":true,"ddl_type":"ALTER TABLE","statement":"ALTER TABLE CUSTOMERS ADD PHONE VARCHAR(30)","rows_affected":0,"message":"..."}}

Errors: 400 SQL required or Only DDL statements are accepted; 500 [ALTER TABLE] <engine message>.

POST /api/fb/sp/execute

Runs a selectable stored procedure (SELECT * FROM proc(...)) and returns its rows. For executable procedures use the agent endpoint procedure/execute.

Parameter Type Default Notes
ConnectionName string selected
ProcName string required Checked against the catalog
Params JSON text {} By name ({"A_LIMIT":100}); if no key is a parameter name, the values are taken in order. JSON types are kept (null, number, boolean, string)
MaxRows integer 0 → 200

Response data: array of rows.

POST /api/fb/sp/execute
{"ConnectionName":"prova locale","ProcName":"SP_LOW_STOCK","Params":"{\"A_LIMIT\":100}"}
{"ok":true,"data":[{"SKU":"MN-270","DESCRIPTION":"27\" 4K monitor","STOCK_QTY":88}]}

Errors: 400 ProcName required, Procedure "X" not found, Parameter "X" not found, Too many parameters; 403 from another computer without access token.

Table rows (CRUD)

Table and field names are checked against the catalog and quoted; values are passed as typed parameters. Where and OrderBy are rejected if they contain ; or comments.

GET /api/fb/crud/list

Parameter Type Default Notes
ConnectionName string selected
TableName string required
Where string — Condition without WHERE
OrderBy string — Without ORDER BY
MaxRows integer 0 → 200

Response data: array of rows.

GET /api/fb/crud/list?ConnectionName=prova%20locale&TableName=CUSTOMERS&Where=COUNTRY%3D'Italy'&OrderBy=COMPANY_NAME

POST /api/fb/crud/insert

Parameter Type Default Notes
ConnectionName string selected
TableName string required
Row JSON text required {"FIELD": value}; null writes NULL

Response data: { "rows_affected": 1 }.

POST /api/fb/crud/insert
{"ConnectionName":"prova locale","TableName":"CUSTOMERS","Row":"{\"COMPANY_NAME\":\"O'Brien & Sons\",\"CITY\":\"Dublin\",\"COUNTRY\":\"Ireland\"}"}

PUT /api/fb/crud/update

Parameter Type Default Notes
ConnectionName string selected
TableName string required
Row JSON text required Fields to change
Key JSON text — {"PK_FIELD": value}: rows to update (preferred)
Where string — Alternative to Key

One of Key or Where is required. Response data: { "rows_affected": n }.

PUT /api/fb/crud/update
{"ConnectionName":"prova locale","TableName":"ORDERS","Key":"{\"ORDER_ID\":4}","Row":"{\"STATUS\":\"PAID\"}"}

DELETE /api/fb/crud/delete

Parameter Type Default Notes
ConnectionName string selected
TableName string required
Key JSON text — Preferred
Where string — Alternative to Key

Response data: { "rows_affected": n }.

Errors (all CRUD): 400 missing parameters, table or field not in the catalog, invalid JSON, Where/OrderBy with ; or comments; 403 write from another computer without access token; 500 database error.

Scripts

Scripts are stored as <id>.sql + <id>.json in the scripts folder of the SmartFBX data folder. Workflow: upload → review (also in the /scripts page) → execute.

POST /api/fb/script/upload

Parameter Where Type Notes
ConnectionName query string Target stored in the metadata
Title query string
Author query string
SQL body text The whole request body is the script. Alternatively the SQL query parameter

Response data: { "script_id", "title", "author", "created_at", "status": "pending", "size_bytes" }.

POST /api/fb/script/upload?ConnectionName=prova%20locale&Title=Add%20phone&Author=Ivan
Content-Type: text/plain

ALTER TABLE CUSTOMERS ADD PHONE VARCHAR(30);
COMMENT ON COLUMN CUSTOMERS.PHONE IS 'Main phone number';
{"ok":true,"data":{"script_id":"4F1C0E9A2B7D4E8F9A0B1C2D3E4F5A6B","title":"Add phone","author":"Ivan","created_at":"2026-11-15 18:02:11","status":"pending","size_bytes":96}}

Errors: 400 empty body.

GET /api/fb/script/list

Parameter Type Default Values
Status string — (all) pending, executed, failed

Response data: array of metadata objects: script_id, title, author, connection_name, created_at, status, executed_at, error, size_bytes.

GET /api/fb/script/get

Parameter Type
ScriptId string, required

Response data: the metadata plus sql (script text). Errors: 400 ScriptId required; 404 Script not found.

POST /api/fb/script/execute

Parameter Type Default
ScriptId string required
ConnectionName string selected

Runs the statements one by one and updates the metadata (status = executed or failed, executed_at, error).

Response data:

Field Content
script_id, status
statements [{ "index", "sql" (first 500 characters), "ok", "error" }]
executed_count, failed_count integers

Errors: 400, 404 as above.

DELETE /api/fb/script/delete

Parameter Type
ScriptId string, required

Response data: { "deleted": true, "script_id": "..." }.

Xtumble named queries

For databases with the Xtumble schema only (table CUSTOM_FR_DYN_DATASET). EntityGroups is a comma-separated list of group IDs (1,2,5); empty = global queries (group 500000000).

GET /api/fb/nq/groups

Parameters: ConnectionName. Response data: [{ "id", "name", "nq_count" }].

GET /api/fb/nq/list

Parameter Type Default
ConnectionName string selected
EntityGroups string — (global)
Filter string —
WithSQL boolean false

Response data: [{ "name", "description", "group_id", "read_only", "generator", "has_count_query", "sql" (withWithSQL) }].

GET /api/fb/nq/detail

Parameter Type Default
ConnectionName string selected
EntityGroups string —
Name string required

Response data: { "name", "description", "read_only", "generator", "sql", "sql_count", "fields": [{name,type,size}], "params": [{name,type}] }.

POST /api/fb/nq/execute

Parameter Type Default
ConnectionName string selected
EntityGroups string —
Name string required
Params JSON text {} — e.g. {"ID_CLIENTE":"42"}
MaxRows integer 0 → 500

Response data: { "rows": [rows], "count": integer }.

POST /api/fb/nq/validate

Dry run of a definition; writes nothing.

Parameter Type Notes
ConnectionName string
Name string Optional: also checks that the name exists
SQL string required, with :NAME parameters
SQLCount string Optional count query

Response data: { "valid", "name", "kind", "fields", "params", "exists", "existing", "errors": [{code,message}], "warnings": [{code,message}] }.

POST /api/fb/nq/register

Parameter Type Default Notes
ConnectionName string selected
Name string required Letters, digits, _, max 50
GroupId string 500000000 Group (FK_CUSTOM_REPORT)
SQL string required
SQLCount string —
Description string — Max 255
ReadOnly string S S / N
GeneratorName string — Writable queries only

Response data: { "registered": true, "group_id", "pk_id", "read_only", "validation" }, or { "registered": false, "name", "validation" } when a check fails.

POST /api/fb/nq/update

Same parameters as register; empty values are left unchanged. SetSQLCount / SetDescription = true write the value even when empty (empty = NULL).

Response data: { "updated": true, "group_id", "pk_id", "changed", "previous": {sql, sql_count, description, read_only, generator}, "validation" }.

Agent endpoints

POST /api/fb/agent/<group>/<action> runs the agent tool sfb_<group>_<action> with the same arguments as the MCP tool (snake_case, JSON body). Rules:

Endpoint MCP tool Reference
/api/fb/agent/source/get sfb_source_get link
/api/fb/agent/source/search sfb_source_search link
/api/fb/agent/source/patch sfb_source_patch link
/api/fb/agent/change/validate sfb_change_validate link
/api/fb/agent/change/apply sfb_change_apply link
/api/fb/agent/change/discard sfb_change_discard link
/api/fb/agent/sql/query sfb_sql_query link
/api/fb/agent/procedure/execute sfb_procedure_execute link
/api/fb/agent/row/get sfb_row_get link
/api/fb/agent/row/update sfb_row_update link
/api/fb/agent/row/delete sfb_row_delete link
Status Error codes
400 connection_name is required, invalid JSON body, invalid argument
404 database not found, procedure_not_found, row_not_found, change_not_found, unknown_tool
409 ambiguous connection name, source_conflict, patch_conflict, ambiguous_patch, change_expired, target_conflict, row_conflict, row_count, procedure_truncated
422 database_error (engine message, diagnostics with engine_code, line, column)
429 plan_limit (too many pending changes)
500 operation_failed (message without details; passwords are never included)

POST /api/fb/agent/procedure/execute

Example of an agent call (the other endpoints follow the same pattern):

POST /api/fb/agent/procedure/execute
{"connection_name":"prova locale","procedure_name":"SP_ADD_ORDER_LINE",
 "params":{"A_ORDER_ID":6,"A_PRODUCT_ID":4,"A_QTY":1},"dry_run":true}
{"ok":true,"data":{"rows":[{"NEW_TOTAL":503}],"dry_run":true,"committed":false}}

Web pages

Served by the API when the web folder is installed next to SmartFBX. They use the same access token (taken from the link or asked once and kept in the browser session).

Path Page
/ui Web client: connections, tables, procedures, views, DDL, SQL. Database > Open Web Client opens it on the selected connection
/scripts Review of uploaded scripts: list, content, execute, delete
/ep Test page with ready-made calls for every endpoint