Skip to main content
Agent Tools
View .md

Errors

The Canon API uses standard HTTP status codes and returns structured JSON error responses.

Error Response Format

All errors return a JSON object with an error field. Validation errors additionally include a detail field:

{
"error": "validation_error",
"detail": "invalid asset: FAKECOIN"
}

HTTP Status Codes

CodeMeaningDescription
200OKRequest succeeded
400Bad RequestInvalid request parameters
401UnauthorizedMissing or invalid API key
404Not FoundResource not found (e.g. no volatility data for requested backtest asset)
429Too Many RequestsRate limit exceeded
500Internal Server ErrorUnexpected server error
502Bad GatewayUpstream data source unavailable
503Service UnavailableService is starting up or circuit breaker is open
504Gateway TimeoutRisk computation exceeded 10 second timeout

Authentication Errors (401)

Missing or malformed Authorization header:

{
"error": "missing or invalid Authorization header"
}

Invalid API key:

{
"error": "invalid API key"
}

Validation Errors (400)

All validation errors return "error": "validation_error" with a specific detail message:

{
"error": "validation_error",
"detail": "leverage 100 exceeds maximum 50"
}
Detail patternDescription
invalid asset: {name}Asset not found or not available on Hyperliquid
invalid wallet address: {addr}Wallet address is not a valid 42-character hex address
size must be positive, got {n}Position size is not positive
size {n} exceeds maximum allowed {max}Position size exceeds $100M maximum
leverage {n} exceeds maximum {max}Requested leverage exceeds the asset's maximum
asset {name} is delisted and cannot be tradedAsset has been delisted
asset {name} only supports isolated margin modeAsset only supports isolated margin; cross margin was requested

Batch-specific errors:

ErrorDetailDescription
batch_too_largemax 50 trades per batchBatch request exceeds 50 trades
validation_errortrades array is emptyBatch request contains no trades

Upstream Errors (502)

Returned when Canon cannot fetch required data from the exchange.

{
"error": "l2_book_fetch_failed"
}
{
"error": "wallet_state_unavailable"
}

Service Unavailable (503)

Returned when the service is still starting up and caches are not yet populated:

{
"error": "service_starting"
}

Also returned when the upstream circuit breaker is open due to repeated failures.

Gateway Timeout (504)

Returned when risk computation exceeds the 10-second handler timeout:

{
"error": "timeout",
"detail": "risk computation exceeded 10s"
}