Skip to main content

API Reference

Overview

The Mastra Agent Framework provides REST APIs for managing agents, workflows, and administrative operations. Each domain exposes endpoints for invoking agents, executing tools, and running workflows.

Domain APIs

Common Endpoint Patterns

The generated OpenAPI artifacts under docs/openapi/ are the source-backed contract for the current runtime. In testing, APIM may publish these runtime paths under an /ai prefix; for example, direct /sdac/tools/validate-fringe is commonly called as /ai/sdac/tools/validate-fringe through APIM.

Agent Endpoints

MethodPathDescription
GET/agents.jsonList registered agents for UI discovery
GET/api/agents/{agentId}Get Mastra SDK agent metadata
POST/api/agents/{agentId}/generateInvoke agent (non-streaming)
POST/api/agents/{agentId}/streamInvoke agent (streaming SSE)
POST/{domain}/agents/{slug}/generateInvoke a domain-friendly agent route
POST/{domain}/agents/{slug}/streamStream a domain-friendly agent route

Tool Endpoints

MethodPathDescription
GET/tools.jsonList registered tools for UI discovery
POST/api/tools/{toolId}/executeExecute a tool
POST/{domain}/tools/{slug}Execute a domain-friendly tool route with flat JSON input

Workflow Endpoints

MethodPathDescription
GET/workflows.jsonList registered workflows for UI discovery
POST/{domain}/workflows/{slug}/create-runCreate a workflow run
POST/{domain}/workflows/{slug}/startStart a workflow run
GET/{domain}/workflows/{slug}/runs/{runId}Get workflow run status

Domain Discovery

MethodPathDescription
GET/{domain}/routes.jsonLists source-backed tool, agent, and workflow routes for one domain
GET/mcp-servers.jsonLists registered MCP servers when runtime directory routes are enabled

Authentication

API endpoints use different authentication methods depending on the environment:

Production (Azure):

  • Managed Identity authentication for Azure-hosted services
  • API keys for external integrations via Azure API Management (APIM)

Development:

  • Bearer tokens for local testing
  • API keys for integration tests

Refer to each domain's documentation for specific authentication requirements and APIM gateway details.