Tutorials
Start small, then add the guardrails your team needs.
The fastest path is to send one clear question, inspect the SQL and
validation metadata, then decide whether to execute, format, optimize,
or visualize the result. These examples use production-shaped requests
so you can copy the pattern into a real integration.
- 01 Create a project and connect schema context.
- 02 Send a natural-language question to the search endpoint.
- 03 Review the generated SQL, warnings, and validation status.
-
04 Add policy checks, formatting, optimization, or charts as needed.
Guide 01
Make your first text-to-SQL request
Ask one business question and let TTSQL return SQL plus validation metadata. Start here when you want the shortest working integration.
Generate SQL
curl
curl -X POST https://ttsql.com/api/v1/search \
-H "Authorization: Bearer $TTSQL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"project_id": "proj_live",
"question": "Revenue by plan this month",
"dialect": "postgres"
}'
Guide 02
Validate SQL before anyone runs it
Use validation when you already have SQL and want TTSQL to catch syntax issues, risky patterns, or policy mismatches before execution.
Validate generated SQL
curl
curl -X POST https://ttsql.com/api/v1/format/validate \
-H "Authorization: Bearer $TTSQL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"dialect": "postgres",
"sql": "SELECT plan, SUM(amount) FROM invoices GROUP BY plan"
}'
Guide 03
Turn a query result into a chart
After a query is generated or approved, send the result shape to the visualization endpoint and ask for the chart your user needs.
Create visualization
curl
curl -X POST https://ttsql.com/api/v1/visualize/query \
-H "Authorization: Bearer $TTSQL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query_id": "qry_revenue_by_plan",
"chart": "bar",
"x": "plan",
"y": "revenue"
}'