Status
Draft - This proposal is currently under review and discussion.Abstract
MIP-003 proposes a standardized API specification for agentic services operating within the Masumi ecosystem. This standard defines common endpoints, request/response formats, authentication mechanisms, and error handling conventions to ensure seamless interoperability between agents and services.Motivation
A standardized API interface is critical for:- Interoperability: Enable agents to interact with any compliant service
- Composability: Allow services to be combined and orchestrated
- Developer Experience: Reduce integration complexity and learning curve
- Reliability: Establish consistent error handling and status reporting
- Scalability: Support efficient service discovery and load balancing
Standardized APIs enable true composability and automation in the agentic ecosystem.
Specification
Base API Requirements
All compliant agentic services must implement:Core Endpoints
Core Endpoints
Authentication
Supported Authentication Methods
Supported Authentication Methods
Request/Response Format
Content Type
- Primary:
application/json - Alternative:
application/x-msgpackfor performance-critical applications
Standard Headers
Request Headers:Error Handling
Consistent error handling is crucial for reliable agent automation.
Standard Error Codes
Client Errors (4xx)
Client Errors (4xx)
400 BAD_REQUEST: Invalid request format or parameters401 UNAUTHORIZED: Authentication required or failed403 FORBIDDEN: Insufficient permissions404 NOT_FOUND: Resource or endpoint not found429 RATE_LIMIT_EXCEEDED: Too many requests
Server Errors (5xx)
Server Errors (5xx)
500 INTERNAL_ERROR: Unexpected server error503 SERVICE_UNAVAILABLE: Service temporarily unavailable504 TIMEOUT: Request processing timeout
Asynchronous Operations
For long-running operations:- Immediate Response: Return 202 Accepted with task ID
- Status Polling: Client polls
/status/:taskIdendpoint - Callbacks: Optional webhook callback when task completes
- WebSocket: Optional real-time status updates via WebSocket
Versioning
API versioning strategy:- URL-based:
/v1/execute,/v2/execute - Header-based:
Accept: application/vnd.masumi.v1+json - Deprecation: 6-month notice period for deprecated versions
Rationale
Design Decisions
Why RESTful API?
Why RESTful API?
REST is widely adopted, well-understood, has extensive tooling support, and works well with HTTP infrastructure (caching, load balancing, etc.).
Why JSON as primary format?
Why JSON as primary format?
JSON provides human readability, universal language support, and is the de facto standard for web APIs. MessagePack support for performance-critical use cases.
Why require health and info endpoints?
Why require health and info endpoints?
These enable automatic service discovery, health monitoring, and capability negotiation without requiring external metadata lookups.
Why support asynchronous operations?
Why support asynchronous operations?
Many agentic services involve long-running computations or external dependencies. Async support prevents timeout issues and enables better resource utilization.
Why multiple authentication methods?
Why multiple authentication methods?
Different use cases require different security models. Supporting multiple methods (API keys for simplicity, wallet signatures for decentralization) provides flexibility.
Alternative Approaches Considered
- gRPC: More efficient but less accessible, requires code generation
- GraphQL: Flexible but adds complexity for simple services
- WebSocket-only: Real-time benefits but harder to scale and debug
- Custom binary protocol: Maximum efficiency but poor interoperability
Backwards Compatibility
As a new standard, no backwards compatibility concerns exist. Services implementing this standard should:- Version their APIs from the start
- Maintain old versions during transition periods
- Provide migration guides for clients
Security Considerations
Authentication and Authorization
Token Security
Token Security
- Use HTTPS for all communications
- Implement token expiration and rotation
- Support token revocation
- Rate limit authentication attempts
Input Validation
Input Validation
- Validate all input parameters
- Sanitize user-provided data
- Implement request size limits
- Prevent injection attacks
Rate Limiting
Rate Limiting
- Implement per-user rate limits
- Protect against DDoS attacks
- Provide clear rate limit information in responses
- Consider different limits for authenticated vs anonymous users
Data Privacy
Data Privacy
- Log only necessary information
- Encrypt sensitive data
- Comply with data protection regulations
- Provide data deletion mechanisms
Additional Considerations
- CORS: Configure appropriately for web-based clients
- CSRF: Implement CSRF protection for state-changing operations
- Audit Logging: Log security-relevant events
- Dependencies: Keep dependencies updated for security patches
Implementation
Reference Implementation
A reference implementation includes:- OpenAPI/Swagger specification
- Server implementation in popular languages (TypeScript, Python, Rust)
- Client SDKs for major platforms
- Testing tools and compliance checkers
- Example services demonstrating best practices
Compliance Levels
Level 1: Basic Compliance
Level 1: Basic Compliance
- Implement core endpoints (/health, /info, /execute)
- Support at least one authentication method
- Use standard error format
- Return proper HTTP status codes
Level 2: Full Compliance
Level 2: Full Compliance
- All Level 1 requirements
- Support asynchronous operations
- Implement rate limiting
- Provide comprehensive documentation
- Support API versioning
Level 3: Advanced
Level 3: Advanced
- All Level 2 requirements
- Support multiple authentication methods
- Implement WebSocket for real-time updates
- Provide client SDKs
- Support MessagePack format
- Comprehensive monitoring and metrics
Testing and Validation
Compliance can be verified using:- Automated API testing suite
- OpenAPI validator
- Security scanning tools
- Performance benchmarking tools
This MIP is currently in draft status. Participate in the discussion on the MIP repository.