mizu contract command helps you work with service contracts. A contract defines what your API can do - the methods, their inputs, and their outputs. This command lets you discover, explore, call methods, view schemas, and export specifications like OpenAPI directly from the command line.
What is a Service Contract?
A service contract defines the interface of your API:- What methods are available
- What data each method accepts
- What data each method returns
contract template, your services are automatically discoverable. The mizu contract command lets you explore and interact with these APIs from the command line.
Quick Examples
Subcommands
Setting the Server URL
By default, commands connect tohttp://localhost:8080. You can change this in several ways:
--url flag > MIZU_URL environment variable > default.
mizu contract ls
Lists all services and their methods.Usage
Flags
Example
JSON Output
mizu contract show
Shows detailed information about a specific method.Usage
Flags
Example
Show Full Schema
mizu contract call
Calls a method with input data and returns the result.Usage
Input Formats
Flags
Examples
Call with inline JSON:Error Output
If the call fails:mizu contract spec
Exports the API specification in OpenAPI or OpenRPC format.Usage
Flags
Examples
Export OpenAPI spec:mizu contract types
Lists all types and their schemas.Usage
Flags
List All Types
Show Specific Type
Show Full Schema
Discovery Methods
The CLI tries multiple methods to discover your API:- JSON-RPC Discovery - Calls
rpc.discovermethod - OpenRPC Spec - Fetches
/openrpc.json - OpenAPI Spec - Fetches
/openapi.json - Contract Endpoint - Fetches
/_contract
Practical Workflows
Explore a New API
Generate Client Documentation
Test During Development
CI/CD Integration
Error Messages
Cannot Discover Contract
- Server is not running
- Server doesnβt expose discovery endpoints
- Wrong URL
- Make sure your server is running (
mizu dev) - Verify the URL is correct
- Check that youβre using the
contracttemplate
Method Not Found
mizu contract ls to see available methods.
Missing Required Input
Exit Codes
Next Steps
Contract Template
Learn how to build contract-based services
OpenAPI Export
Learn about OpenAPI spec generation