agents.json is an extension of OpenAPI that adds agent-specific features like flows and links.
{
"version": "1.0.0",
"name": "My Agent API",
"description": "API for agent interactions",
"baseUrl": "http://localhost:3000",
"actions": [
{
"id": "action1",
"name": "Action Name",
"description": "Action description",
"endpoint": "/action",
"method": "POST",
"parameters": [
{
"name": "param1",
"type": "string",
"required": true
}
]
}
],
"flows": [
{
"id": "flow1",
"name": "Flow Name",
"description": "Flow description",
"steps": [
{
"actionId": "action1",
"onSuccess": ["action2"],
"onError": ["errorHandler"]
}
],
"triggers": ["event.triggered"]
}
],
"links": [
{
"from": "action1",
"to": "action2",
"relation": "creates",
"description": "Action1 creates resources for Action2"
}
]
}
Actions define individual API endpoints that agents can call.
id: Unique identifiername: Human-readable nameendpoint: API endpoint pathmethod: HTTP methoddescription: Action descriptionparameters: Array of parametersrequestBody: Request body schemaresponses: Response schemastags: Tags for categorizationFlows define sequences of actions that can be executed together.
Each step in a flow can specify:
actionId: The action to executecondition: Optional condition for executiononSuccess: Actions to execute on successonError: Actions to execute on errorparameters: Parameters to pass to the actionFlows can be triggered by events:
triggers: Array of event names that trigger the flowLinks define relationships between actions:
from: Source action IDto: Target action IDrelation: Type of relationshipdescription: Link descriptionimport { createServer } from '@programsmagic/toon-backend-node';
const server = await createServer({
schemaSource: './agents.json',
port: 3000,
});
await server.start();
Use the FlowDiagram component to visualize flows:
<AgentVisualizer
url="http://localhost:3000/events"
showFlowDiagram={true}
flows={flows}
/>
/.well-known/agents.json for discoverability