JSON-RPC API Standard JSON-RPC 2.0 endpoint for programmatic access to Shroud tools.
When to Use Which API Use Case
Endpoint
Format
AI agents with tool discovery
MCP API POST /mcp
MCP protocol (streamable HTTP)
Programmatic tool access
JSON-RPC POST /rpc
JSON-RPC 2.0 via tools.call
OpenAI-compatible AI inference
OpenAI API POST /v1/chat/completions
OpenAI chat format
Direct Substrate RPC calls
RPC Proxy POST /v1/midnight/rpc
Raw Substrate JSON-RPC
E2E encrypted inference
Cocoon SDK wss://.../v1/cocoon/stream
WebSocket + AES-256-GCM
Important: The /rpc endpoint exposes exactly two JSON-RPC methods: tools.list and tools.call. To invoke a Midnight tool (e.g. midnight_getBlock), use tools.call with the tool name in params.tool. Calling midnight_getBlock directly as a JSON-RPC method will return -32601 Method Not Found.
Authentication
Authorization: Bearer shroud_prod_...
Content-Type: application/json
Methods List all available tools:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools.list"
}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"tools": [
{
"name": "midnight_getBlock",
"description": "Get a Midnight block by height or hash",
"inputSchema": { ... },
"estimatedCUMilli": 1000,
"estimatedCUVaries": false
}
]
}
}
Invoke a specific tool:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools.call",
"params": {
"tool": "midnight_getBlock",
"params": {
"height": 100
}
}
}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"content": { "block": { "header": { ... }, "extrinsics": [...] } },
"usedCUMilli": 1000
}
}
Error Codes Errors follow the JSON-RPC 2.0 spec : a top-level error object with code, message, and an optional data field. Tool-level failures additionally carry a SHROUD code in error.data.errorCode:
{
"jsonrpc": "2.0",
"id": 1,
"error": {
"code": -32601,
"message": "tool not found: midnight_nonExistent",
"data": {
"errorCode": "SHROUD_TOOL_NOT_FOUND"
}
}
}
Always read the SHROUD code from error.data.errorCode rather than the numeric code — the numeric mapping may evolve, the SHROUD codes are stable.
Standard JSON-RPC Errors Code
Name
Description
-32700
Parse Error
Invalid JSON
-32600
Invalid Request
Malformed JSON-RPC request
-32601
Method Not Found
Unknown method or unknown tool name
-32602
Invalid Params
Invalid method/tool parameters
-32603
Internal Error
Server-side error or tool execution failure
See Error Reference — SHROUD Error Codes for the full list of error.data.errorCode values and their meanings.
HTTP-Level Errors Authentication and rate limiting errors are returned at the HTTP level (before JSON-RPC parsing):
HTTP Status
Description
401 Unauthorized
Invalid or missing API key
429 Too Many Requests
Rate limit or CU limit exceeded
Examples Get chain statistics
curl -X POST https://shroud.us/rpc \
-H "Authorization: Bearer shroud_prod_..." \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools.call",
"params": {
"tool": "midnight_getChainStats",
"params": {}
}
}'
Get account info
curl -X POST https://shroud.us/rpc \
-H "Authorization: Bearer shroud_prod_..." \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools.call",
"params": {
"tool": "midnight_getAccount",
"params": {
"address": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"
}
}
}'
Generic RPC call
curl -X POST https://shroud.us/rpc \
-H "Authorization: Bearer shroud_prod_..." \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools.call",
"params": {
"tool": "midnight_rpc",
"params": {
"method": "chain_getFinalizedHead",
"params": []
}
}
}'
Last modified: 08 May 2026