Skip to main content
The 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
When you build APIs with the 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 to http://localhost:8080. You can change this in several ways:
Priority order: command argument > --url flag > MIZU_URL environment variable > default.

mizu contract ls

Lists all services and their methods.

Usage

Flags

Example

Output:

JSON Output


mizu contract show

Shows detailed information about a specific method.

Usage

Flags

Example

Output:

Show Full Schema

Outputs the complete JSON Schema for input and output types.

mizu contract call

Calls a method with input data and returns the result.

Usage

Input Formats

Flags

Examples

Call with inline JSON:
Output:
Call with file input:
Call with stdin:
Call a method that takes an ID:
Add authentication header:

Error Output

If the call fails:

mizu contract spec

Exports the API specification in OpenAPI or OpenRPC format.

Usage

Flags

Examples

Export OpenAPI spec:
Export pretty-printed:
Export to file:
Output:
Export OpenRPC format:

mizu contract types

Lists all types and their schemas.

Usage

Flags

List All Types

Output:

Show Specific Type

Output:

Show Full Schema


Discovery Methods

The CLI tries multiple methods to discover your API:
  1. JSON-RPC Discovery - Calls rpc.discover method
  2. OpenRPC Spec - Fetches /openrpc.json
  3. OpenAPI Spec - Fetches /openapi.json
  4. Contract Endpoint - Fetches /_contract
It uses the first method that succeeds.

Practical Workflows

Explore a New API

Generate Client Documentation

Test During Development

CI/CD Integration


Error Messages

Cannot Discover Contract

Causes:
  • Server is not running
  • Server doesn’t expose discovery endpoints
  • Wrong URL
Fix:
  1. Make sure your server is running (mizu dev)
  2. Verify the URL is correct
  3. Check that you’re using the contract template

Method Not Found

Fix: Check the method name. Use mizu contract ls to see available methods.

Missing Required Input

Fix: Provide the required input data.

Exit Codes


Next Steps

Contract Template

Learn how to build contract-based services

OpenAPI Export

Learn about OpenAPI spec generation