Search API
Where: Settings › Agents › API Agent for the token. Your application calls Tursio over HTTPS.
Who can use it: Admins and Owners create the token.
The search API brings Tursio's answers into your own application. Your backend sends a question in plain language with an API token, and gets back the SQL, the result table, and a summary to show in your UI. Tursio applies the same access control as in the portal when you tell it who is asking.
Get a token
The search API accepts tokens from the API agent named default. It's the same token the MCP server uses.
- Open Settings › Agents and find the API Agent section.
- Open the agent named
default. If there isn't one, add an API agent with the namedefault. - Create a token and copy it. Tokens are valid for two years.
For the full steps, see API Agent.
Tokens from other API agents
The search API rejects tokens from API agents with any other name. Those calls get 401 Unauthorized.
Asking questions
- Send the question from your backend to
/nlp-searchon your Tursio host. Put the token in theSmartApps-Licenseheader. - Pass the dataset ID and the question. The dataset ID is the
dataset_idin the database's MCP package configuration file. - Pass the user's email in
userso Tursio applies that user's access. See Access control below. - Show the answer in your UI: the
summary, thetable, and, if you want, thesql.
Search request and response
curl -X POST https://<your-tursio-hostname>/nlp-search \
-H "Content-Type: application/json" \
-H "SmartApps-License: <token>" \
-d '{
"dataset": "<dataset ID>",
"question": "How many orders shipped last month?",
"user": "user@example.com",
"generate_summary": true
}'
| Field | Required | Meaning |
|---|---|---|
dataset |
Yes | The dataset ID. |
question |
Yes | The question in plain language. |
user |
No | The email of the Tursio user who is asking. |
generate_summary |
No | true by default. Set false to skip the summary and get only the SQL and table. |
A successful call returns 200 with:
| Field | Meaning |
|---|---|
tursio_search_id |
The ID of this search. Use it to send feedback. |
sql |
The SQL Tursio ran. |
table |
The result as a Markdown table. Empty when no rows match. |
summary |
A plain-language summary of the result. Present when generate_summary is on. |
budget_warning |
Present only when this search took the AI agent over its daily budget. The search itself still returns. |
Errors return JSON with an error message:
| Status | When |
|---|---|
400 |
dataset or question is missing. |
401 |
The token is missing, expired, or not from the default API agent. |
402 |
The AI agent's daily budget is used up. |
403 |
The user doesn't have access to this dataset. |
404 |
No dataset with that ID. |
Send feedback
- Keep the
tursio_search_idfrom the search response. - Post it to
/nlp-feedbackwithpositiveornegative, and an optional comment.
Feedback request
curl -X POST https://<your-tursio-hostname>/nlp-feedback \
-H "Content-Type: application/json" \
-H "SmartApps-License: <token>" \
-d '{
"tursio_search_id": "<id from the search response>",
"feedback": "negative",
"feedback_details": "Wrong date range"
}'
The call returns {"status": "ok"}. Tursio ignores feedback with a value other than positive or negative, or for a search ID it doesn't recognize, and still returns ok.
Get context
Your application can read the dataset's semantic context: the description of its tables and columns that helps phrase questions well. Post the dataset ID to /nlp-context. Tursio returns the context as plain text.
Context request
curl -X POST https://<your-tursio-hostname>/nlp-context \
-H "Content-Type: application/json" \
-H "SmartApps-License: <token>" \
-d '{"dataset": "<dataset ID>", "user": "user@example.com"}'
The context includes your edits on the MCP tab of the Context page. See MCP.
Access control
Tursio matches the user email to a Tursio user. When it finds one, that user's access applies: the databases they can see, and the table, column, and row rules on the Access Control tab.
Calls without a matching user
A call with no user, or with an email that doesn't match a Tursio user, isn't tied to anyone. It isn't limited by access control and can query any dataset. Always pass the signed-in user's email.
Tips and limits
- Call Tursio from your backend, not the browser. The token is a secret, and Tursio doesn't accept cross-origin browser requests.
- Use HTTPS so the token isn't sent in clear text. See Upgrade and maintain to turn on HTTPS.
- Searches count toward the AI agent's daily budget. When it runs out, calls get
402until midnight. See Set a daily budget. - Large results are cut. The
tableholds the first rows only, up to a row limit and a size cap. - Deleting the
defaultAPI agent removes its tokens. Your application and the MCP server stop working until you add a new token. - Use the MCP server for AI assistants. Use it when an AI assistant, such as Claude, ChatGPT, or Copilot, should query Tursio. Use the search API when your own code shows the answer. See MCP server.
- People can also use Tursio in Microsoft Teams. See Use Tursio in Teams.