Structured Endpoints: The Missing Layer Between Data and AI Agents
APIs are too rigid, databases are too risky. We believe structured endpoints—governed views that agents can query safely—are the missing piece that makes AI agents actually work in production.
The Problem We Keep Hitting
Every time I talk to teams building AI agents, they hit the same wall: how do you give agents access to data?
Option 1: Direct database access. Fast, flexible, powerful. Also: security nightmare, governance impossible, performance unpredictable. Agents can query anything, see everything, and bring down your database with a single bad query.
Option 2: APIs. Secure, controlled, documented. Also: rigid, limited, slow. APIs expose predefined endpoints with fixed schemas. Agents can only do what the API designer thought of. New questions require new endpoints. It's like trying to have a conversation through a menu.
Neither works well for agents. Databases are too risky. APIs are too rigid.
There's a third option that most teams haven't discovered yet: structured endpoints.
What Are Structured Endpoints?
Structured endpoints are governed SQL views that agents can query safely. They're not APIs (too rigid) and they're not raw databases (too risky). They're the middle layer that makes agents actually work.
Think of them as:
- Like APIs: Controlled, secure, documented
- Like databases: Flexible, powerful, queryable
- Unlike APIs: Not rigid, not limited to predefined operations
- Unlike databases: Not risky, not ungoverned, not performance-unpredictable
Structured endpoints give agents the flexibility of databases with the safety of APIs.
Why APIs Are Too Rigid for Agents
APIs work great for applications. They don't work well for agents.
The "I Need Different Data" Problem
APIs expose predefined endpoints. Each endpoint returns a fixed schema. If you need data that's not in the schema, you're stuck.
Example: You have a customer API endpoint that returns:
- Customer ID
- Name
- Plan
Your agent needs to know: "Which customers have open support tickets?" The API doesn't return support ticket data. You need a new endpoint. You need to:
- Design the endpoint
- Build it
- Deploy it
- Document it
- Update your agent to use it
This takes days or weeks. Agents need answers in seconds.
The "I Need to Join Data" Problem
APIs are siloed. Each API exposes one system. If you need data from multiple systems, you need to:
- Call multiple APIs
- Join the data yourself
- Handle different schemas
- Deal with rate limits
- Manage errors across systems
Example: Your agent needs customer context. It calls:
- Customer API (returns customer data)
- Product usage API (returns usage data)
- Support API (returns ticket data)
- Billing API (returns payment data)
Then it manually joins four different responses with different schemas. This is slow, error-prone, and complex.
The "I Need to Filter Differently" Problem
APIs have fixed filters. Each endpoint supports specific query parameters. If you need to filter by something the API doesn't support, you're stuck.
Example: Your customer API supports filtering by:
-
status(active/inactive) -
plan(pro/enterprise) -
created_date(date range)
Your agent needs: "Customers with usage > 100 and revenue > $10K and open tickets < 3." The API doesn't support this filter. You need to:
- Get all customers
- Filter in memory
- Handle pagination
- Deal with performance issues
This is inefficient and doesn't scale.
The "I Need Real-Time Data" Problem
APIs often cache data. They return data that was synced hours or days ago. For some use cases, this is fine. For agents that need real-time context, it's a problem.
Example: Your agent is asked "What's the current status of customer X's subscription?" The API returns data from 3 hours ago. The customer canceled 2 hours ago, but the agent doesn't know.
The "I Need to Query, Not Call" Problem
APIs are call-based. You call an endpoint, you get a response. You can't ask questions. You can't explore. You can't drill down.
Example: Your agent asks "Which customers are at risk?" The API doesn't have an "at-risk customers" endpoint. You need to:
- Call the customer list endpoint
- Call the usage endpoint for each customer
- Call the support endpoint for each customer
- Calculate risk scores yourself
- Filter and sort
This is what agents should do, not what you should build.
Why Databases Are Too Risky for Agents
Databases are powerful. They're also dangerous when agents have direct access.
The Security Problem
Agents with database access can see everything. They can query any table, any column, any row. You can't easily restrict access to specific data.
Example: You give an agent database access to answer customer questions. The agent can also query:
- Employee salaries
- Credit card numbers
- Internal notes
- Compliance data
You need fine-grained access control, but databases don't make this easy. You'd need to:
- Create separate database users for each agent
- Grant specific table/column permissions
- Maintain these permissions as schemas change
- Audit access constantly
This is complex and error-prone.
The Governance Problem
Databases don't enforce governance. Agents can query anything, anytime, any way. You can't:
- Control what data agents see
- Limit data retention
- Enforce compliance requirements
- Track what agents access
Example: You need to comply with GDPR. Customer data older than 2 years shouldn't be accessible. With direct database access, agents can query all historical data. You'd need to:
- Add filters to every query
- Remember to include them
- Hope agents don't forget
- Audit constantly
This is fragile and risky.
The Performance Problem
Agents can write inefficient queries. They can:
- Query millions of rows
- Join 10 tables
- Forget to add indexes
- Create N+1 query problems
Example: An agent queries "all customers" and gets 2 million rows. The query takes 45 seconds and times out. The agent retries 3 times, creating 3 slow queries that lock tables and slow down your application.
The Schema Problem
Databases have complex schemas. Different systems use different naming conventions, data types, and structures. Agents need to understand:
- Which table has customer data?
- Which column is the email?
- How do you join customers to orders?
- What's the difference between
usersandcustomers?
Example: An agent queries customers.email but the actual column is users.email_address. The query fails. The agent doesn't know why.
The Change Problem
Database schemas change. Tables get added, columns get renamed, relationships change. Agents that query databases directly break when schemas change.
Example: You rename customers.email to customers.email_address. All agent queries break. You need to update every query, test them, and redeploy.
Structured Endpoints: The Solution
Structured endpoints solve both problems. They give agents the flexibility of databases with the safety of APIs.
What They Are
Structured endpoints are governed SQL views that agents can query safely. They:
- Define access: Agents can only query through views, not raw tables
- Control scope: You decide exactly what data agents can access
- Normalize schemas: Views map different schemas to consistent interfaces
- Optimize performance: Views can be pre-aggregated and indexed
- Enforce governance: Views can filter, limit, and control data access
How They Work
Step 1: Create Views
You create SQL views that define what data agents can access:
-- Customer Context View
SELECT
c.customer_id,
c.customer_name,
c.email,
c.plan_name,
c.mrr,
o.order_count,
o.total_revenue,
t.open_tickets,
u.active_users,
u.feature_adoption
FROM customers c
LEFT JOIN order_summary o ON c.customer_id = o.customer_id
LEFT JOIN ticket_summary t ON c.customer_id = t.customer_id
LEFT JOIN usage_summary u ON c.customer_id = u.customer_id
WHERE c.is_active = true
AND c.signup_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 2 YEAR); -- GDPR compliance
This view:
- Joins data from multiple systems (customers, orders, tickets, usage)
- Normalizes schemas (maps different column names to consistent names)
- Filters data (only active customers, only last 2 years)
- Excludes sensitive data (no credit cards, no internal notes)
Step 2: Expose as Endpoints
Views are exposed as queryable endpoints. Agents can query them with SQL:
SELECT * FROM customer_context_view
WHERE email = 'customer@example.com';
Or through tools that translate natural language to queries:
Agent asks: "What's the context for customer@example.com?"
Tool queries: SELECT * FROM customer_context_view WHERE email = 'customer@example.com'
Agent gets: Complete customer context with orders, tickets, usage, and revenue.
Step 3: Agents Query Safely
Agents query through views, not raw tables. They get:
- Unified access to all systems
- Consistent schemas
- Filtered, governed data
- Optimized performance
How Structured Endpoints Solve Each Problem
Let me show you how structured endpoints solve the problems with APIs and databases.
Solving the "I Need Different Data" Problem
With APIs: You need a new endpoint for each question. Takes days or weeks.
With Structured Endpoints: You query the view with different filters. Takes seconds.
Example: Your agent needs "customers with open support tickets." With an API, you'd need a new endpoint. With structured endpoints, you query:
SELECT * FROM customer_context_view
WHERE open_tickets > 0;
The view already includes ticket data. You just filter it.
Solving the "I Need to Join Data" Problem
With APIs: You call multiple APIs and join manually. Slow, error-prone.
With Structured Endpoints: Views pre-join data. Fast, reliable.
Example: Your agent needs customer context. With APIs, you'd call 4 APIs and join manually. With structured endpoints, you query one view that already joins all the data:
SELECT * FROM customer_context_view
WHERE email = 'customer@example.com';
The view joins customers, orders, tickets, and usage automatically.
Solving the "I Need to Filter Differently" Problem
With APIs: Fixed filters. Can't filter by unsupported fields.
With Structured Endpoints: Query any field. Filter however you need.
Example: Your agent needs "customers with usage > 100 and revenue > $10K and open tickets < 3." With an API, you'd need a new endpoint. With structured endpoints, you query:
SELECT * FROM customer_context_view
WHERE active_users > 100
AND total_revenue > 10000
AND open_tickets < 3;
The view includes all these fields. You just filter them.
Solving the "I Need Real-Time Data" Problem
With APIs: Often cached. Data can be stale.
With Structured Endpoints: Views can query real-time or cached. You choose.
Example: For critical data (subscription status), use real-time queries:
-- Real-Time Subscription View
SELECT
customer_id,
subscription_status, -- Queried directly from Stripe API
last_updated
FROM stripe_subscriptions_realtime;
For less critical data (historical reports), use cached views:
-- Cached Customer Analytics View
SELECT * FROM customer_analytics_cached
WHERE last_updated >= DATE_SUB(NOW(), INTERVAL 1 HOUR);
Solving the Security Problem
With Databases: Agents can see everything. Hard to restrict access.
With Structured Endpoints: Views define exactly what agents can access. Easy to restrict.
Example: You create a view that excludes sensitive data:
-- Agent-Accessible Customer View
SELECT
customer_id,
customer_name,
email,
plan_name,
mrr
-- Excludes: credit_card_number, internal_notes, ssn, etc.
FROM customers
WHERE is_active = true;
Agents can only query this view. They never see sensitive data.
Solving the Governance Problem
With Databases: No governance enforcement. Agents can query anything.
With Structured Endpoints: Views enforce governance. Agents can only query governed data.
Example: You create a view that enforces GDPR compliance:
-- GDPR-Compliant Customer View
SELECT * FROM customers
WHERE signup_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 2 YEAR) -- Only last 2 years
AND consent_status = 'granted'; -- Only consented customers
Agents can only query this view. They can't access data older than 2 years or without consent.
Solving the Performance Problem
With Databases: Agents can write inefficient queries. Performance unpredictable.
With Structured Endpoints: Views are optimized. Performance predictable.
Example: You create an optimized view:
-- Optimized Customer Analytics View
SELECT
customer_id,
customer_name,
COUNT(order_id) as order_count,
SUM(order_total) as total_revenue,
AVG(order_total) as avg_order_value
FROM orders
WHERE order_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 1 YEAR)
AND order_status != 'cancelled'
GROUP BY customer_id, customer_name
HAVING order_count > 0;
This view is pre-aggregated and filtered. Agents query fast, optimized data instead of slow, raw tables.
Solving the Schema Problem
With Databases: Complex, inconsistent schemas. Agents need to understand each system.
With Structured Endpoints: Views normalize schemas. Agents query consistent interfaces.
Example: You create a normalized view:
-- Normalized Customer View
SELECT
COALESCE(c.id, u.user_id) as customer_id,
COALESCE(c.email, u.email_address) as email,
COALESCE(c.state, u.region) as state
FROM postgres.customers c
FULL OUTER JOIN snowflake.users u ON c.email = u.email_address;
This view normalizes different schemas. Agents query a consistent interface, not fragmented systems.
Solving the Change Problem
With Databases: Schema changes break agent queries. Need to update every query.
With Structured Endpoints: Views abstract schemas. Schema changes only require view updates.
Example: You rename customers.email to customers.email_address. Instead of updating every agent query, you update the view:
-- Updated Customer View
SELECT
customer_id,
customer_name,
email_address as email -- Maps new column to old name
FROM customers;
Agents continue querying email. The view handles the mapping.
Real Examples: Structured Endpoints in Action
Let me show you how teams are using structured endpoints:
Example 1: Customer Support Agent
Problem: Support agents need customer context, but data is in 4 different systems (CRM, product analytics, billing, support).
Solution: Create a customer context view that joins all systems:
-- Customer Context View
SELECT
h.customer_id,
h.customer_name,
h.email,
h.plan_name,
s.order_count,
s.total_revenue,
z.open_tickets,
z.last_ticket_date,
u.active_users,
u.feature_adoption,
st.subscription_status,
st.mrr
FROM hubspot.customers h
LEFT JOIN snowflake.order_summary s ON h.email = s.customer_email
LEFT JOIN zendesk.ticket_summary z ON h.email = z.customer_email
LEFT JOIN product_analytics.users u ON h.email = u.user_email
LEFT JOIN stripe.subscriptions st ON h.email = st.customer_email
WHERE h.is_active = true;
Agent queries: "What's the context for customer@example.com?"
Agent gets: Complete customer context from all systems in one query.
Benefits:
- No need to call 4 APIs
- No need to join data manually
- Consistent schema
- Fast, optimized queries
Example 2: Revenue Forecasting Agent
Problem: Revenue forecasting needs data from pipeline, historical revenue, expansion, and seasonality. Each system has different schemas and APIs.
Solution: Create a revenue forecast view that unifies all data:
-- Revenue Forecast View
SELECT
forecast_quarter,
pipeline_revenue,
historical_revenue,
expansion_revenue,
seasonality_adjustment,
forecast_revenue,
confidence_level
FROM revenue_forecast_aggregated
WHERE forecast_quarter = 'Q2 2025';
Agent queries: "What's our revenue forecast for Q2?"
Agent gets: Complete forecast with all factors in one query.
Benefits:
- No need to call multiple APIs
- No need to calculate forecasts manually
- Pre-aggregated, fast queries
- Consistent interface
Example 3: Pipeline Health Agent
Problem: Pipeline monitoring needs data from CRM, revenue, and product usage. APIs are siloed and don't support complex filters.
Solution: Create a pipeline health view that joins all systems:
-- Pipeline Health View
SELECT
d.deal_id,
d.deal_name,
d.deal_value,
d.deal_stage,
d.probability,
c.customer_name,
c.mrr,
u.active_users,
u.feature_adoption,
s.order_count,
s.total_revenue
FROM hubspot.deals d
LEFT JOIN hubspot.customers c ON d.customer_id = c.customer_id
LEFT JOIN product_analytics.users u ON c.email = u.user_email
LEFT JOIN snowflake.order_summary s ON c.email = s.customer_email
WHERE d.is_active = true
AND d.deal_stage NOT IN ('closed-won', 'closed-lost');
Agent queries: "Which deals are at risk?"
Agent gets: Deals with complete context (customer, usage, revenue) in one query.
Benefits:
- No need to call multiple APIs
- No need to filter manually
- Complete context in one query
- Fast, optimized performance
Building Structured Endpoints
Here's how to build structured endpoints:
Step 1: Identify What Agents Need
Start with questions agents need to answer:
- "What's the context for customer X?"
- "Which customers are at risk?"
- "What's our pipeline health?"
- "What's the revenue forecast?"
These questions tell you what data agents need.
Step 2: Create Views That Provide It
Create SQL views that join data from all relevant systems:
-- Customer Health View
SELECT
c.customer_id,
c.customer_name,
c.email,
c.plan_name,
c.mrr,
u.active_users,
u.login_frequency,
u.feature_adoption_score,
t.open_tickets,
t.satisfaction_score,
p.payment_status,
p.days_overdue,
CASE
WHEN u.login_frequency < 0.5 THEN 'high_risk'
WHEN t.open_tickets > 5 THEN 'high_risk'
WHEN p.days_overdue > 30 THEN 'high_risk'
ELSE 'healthy'
END as health_status
FROM customers c
LEFT JOIN product_usage u ON c.customer_id = u.customer_id
LEFT JOIN support_tickets t ON c.customer_id = t.customer_id
LEFT JOIN payments p ON c.customer_id = p.customer_id
WHERE c.is_active = true;
This view provides everything agents need to answer customer health questions.
Step 3: Govern Access
Add filters and limits to enforce governance:
-- Governed Customer View
SELECT * FROM customer_health_view
WHERE signup_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 2 YEAR) -- GDPR: only last 2 years
AND consent_status = 'granted' -- Only consented customers
-- Excludes: credit_card_number, ssn, internal_notes
LIMIT 1000; -- Prevent unbounded queries
This view enforces governance while still being flexible.
Step 4: Optimize Performance
Pre-aggregate and index for performance:
-- Optimized Pipeline Health View
CREATE VIEW pipeline_health_optimized AS
SELECT
quarter,
target_revenue,
pipeline_revenue,
deal_count,
win_rate,
at_risk_deal_count,
at_risk_revenue
FROM pipeline_health_aggregated
WHERE quarter = 'Q1 2025'
AND is_active = true;
This view is pre-aggregated, so queries are fast.
Step 5: Expose as Queryable Endpoints
Expose views as endpoints that agents can query:
Option 1: SQL Queries
Agents query views directly with SQL:
SELECT * FROM customer_health_view
WHERE email = 'customer@example.com';
Option 2: MCP Tools
Create MCP tools that query views:
-
get_customer_health(customer_email: string)→ Queries customer health view -
get_at_risk_customers(risk_level: string)→ Queries customer health view with filters -
get_pipeline_health(quarter: string)→ Queries pipeline health view
Tools translate natural language to SQL queries.
The Architecture: How It All Fits Together
Here's how structured endpoints fit into the agent architecture:
Data Layer
Your raw data sources:
- Databases (Postgres, MySQL)
- Data warehouses (Snowflake, BigQuery)
- SaaS tools (HubSpot, Stripe, Zendesk)
Views Layer (Structured Endpoints)
Governed SQL views that define what agents can access:
- Unified views that join data across systems
- Normalized schemas
- Filtered, governed data
- Optimized for performance
Tools Layer
MCP tools that agents use to query views:
- Tools that answer specific questions
- Tools that provide context
- Tools that surface insights
Agents Layer
AI agents that use tools to answer questions:
- Agents that monitor metrics
- Agents that answer ad-hoc questions
- Agents that provide recommendations
Flow: Agent → Tool → View → Data
The view (structured endpoint) is the critical layer that makes this work.
Why This Matters
Structured endpoints are the missing piece that makes AI agents work in production.
Without structured endpoints:
- Agents need direct database access (risky)
- Or agents need APIs (rigid)
- Neither works well
With structured endpoints:
- Agents get flexible, queryable access
- With the safety and governance of APIs
- And the power and performance of databases
This is what makes agents actually usable in production.
Frequently Asked Questions
How do structured endpoints differ from APIs?
APIs expose predefined endpoints with fixed schemas. Structured endpoints expose queryable views that agents can query flexibly. APIs are rigid; structured endpoints are flexible.
How do structured endpoints differ from database views?
Traditional database views are limited to one database. Structured endpoints can join data across multiple systems—databases, warehouses, and SaaS tools—in a single query. They also enforce governance, control access, and optimize performance.
Can agents write arbitrary SQL against structured endpoints?
It depends on your setup. Some platforms allow agents to write SQL directly against views. Others require agents to use tools that translate natural language to SQL. The key is that agents query through views, not raw tables.
How do I ensure structured endpoints don't expose sensitive data?
Views define exactly what data agents can access. Exclude sensitive columns, filter sensitive rows, and limit data retention. Agents can only query through views, so you have complete control.
What if I need real-time data?
Views can query real-time data or cached data. For critical metrics (subscription status, payment processing), use real-time queries. For less critical data (historical reports), use cached views. You choose the right approach for each use case.
How do I build views that span multiple systems?
Use a platform that supports cross-database joins. You can join data from HubSpot, Snowflake, Postgres, Zendesk, and more in a single SQL query. The view becomes your unified interface.
Can I use structured endpoints with my existing APIs?
Yes. Structured endpoints complement APIs. Use APIs for applications that need predefined operations. Use structured endpoints for agents that need flexible querying. They serve different purposes.
How do I know if my structured endpoints are working?
Monitor how agents use your views. High usage and low error rates indicate endpoints are working. Low usage might indicate views don't answer the right questions. High error rates might indicate views need optimization.
APIs are too rigid. Databases are too risky. Structured endpoints—governed views that agents can query safely—are the missing piece that makes AI agents actually work in production.
If you're building AI agents, start with structured endpoints. Give agents flexible, queryable access to your data, with the safety and governance they need to work in production.
Top comments (0)