The sqlApiDBQuery extension sends a SQL query to a backend SQL API endpoint from inside a Virtuoso journey.
This is useful when your test needs to fetch database values through an API and reuse the returned response in later journey steps.
Parameters:
-
urlrequired, the base URL of the backend service that handles SQL database requests. The extension appends/SQLInterfaceto this value before sending the request; -
queryrequired, the SQL query that should be sent to the backend SQL interface.
Note: The url value should be the base API URL only. Do not include /SQLInterface in the input because the extension adds it automatically.
NLP usage
Use the extension in a journey by calling sqlApiDBQuery with the execute command. Pass each value to the matching extension input using as inputName.
Note: The SQL query is sent to the backend as text. Make sure the backend service validates and sanitizes the query before executing it to reduce SQL injection risk.
To run a SQL query through the API:
execute "sqlApiDBQuery" using "https://api.example.com/v1/query" as url, "SELECT * FROM Users WHERE Age > 30" as query returning $responseTo run the same query using Virtuoso variables:
execute "sqlApiDBQuery" using "$Url" as url, "$query" as query returning $responseExample setup using variables before calling the extension:
store value "https://api.example.com/v1/query" in $Url
store value "SELECT * FROM Users WHERE Age > 30" in $query
execute "sqlApiDBQuery" using "$Url" as url, "$query" as query returning $responseFor example, the final request URL used by the extension will be:
https://api.example.com/v1/query/SQLInterfaceWhen the request is successful, the extension returns the API response as a JSON string in the output variable.
This extension requires the following resource:
The extension should be configured as:
- Run asynchronously: Yes
- Scope: Global
Limitation: This extension depends on the backend /SQLInterface endpoint. The extension does not execute SQL directly in Virtuoso; it only sends the query to the configured API endpoint. If the backend returns an error field, the extension fails using doneError.
Add the extension to your Virtuoso instance
Select the domain that matches your Virtuoso account.
View source
Last updated: 22/05/2026
Resources:
const makeRequest = async (url, query) => {
try {
const { data } = await axios.post(
url,
'"' + query + '"',
{
headers: {
'Content-Type': 'application/json'
}
}
);
if (data.error) {
console.log(data.error);
doneError(JSON.stringify(data));
}
done(JSON.stringify(data));
} catch (e) {
console.log(e.message);
doneError(e);
}
};
if (!url) {
throw new Error('URL parameter is missing');
}
url += "/SQLInterface";
if (!query) {
throw new Error('Query parameter is missing');
}
makeRequest(url, query);
Comments
0 comments
Please sign in to leave a comment.