Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.simplefunctions.dev/llms.txt

Use this file to discover all available pages before exploring further.

Errors come in two flavors: CLI envelope errors (when --json is set) and HTTP errors (status code + JSON body).

CLI error envelope

{
  "ok": false,
  "command": "portfolio.history",
  "error": {
    "code": "AUTH_REQUIRED",
    "message": "...",
    "status": 401,
    "details": {}
  },
  "meta": { "fetchedAt": "..." }
}

Error codes

Auth and access

CodeStatusMeaning
AUTH_REQUIRED401No API key supplied
AUTH_INVALID401API key is invalid or expired
AUTH_FORBIDDEN403Key lacks the required scope
RATE_LIMITED429Per-key or per-route limit exceeded
IP_BLOCKED403IP-level block (rare)

Validation

CodeStatusMeaning
VALIDATION_ERROR400Bad input (missing field, wrong type)
UNSUPPORTED_OPERATION400Operation not supported for this resource
CONFLICT409State conflict (e.g. publish a thesis with a duplicate slug)

Trade execution

CodeStatusMeaning
RISK_GATE_FAIL403One or more risk gates blocked the order
STALE_PRICE400Specified price no longer reachable
INSUFFICIENT_BALANCE400Balance below required amount
CATEGORY_BLOCKED400Market category in your exclude list
THESIS_MISMATCH400Intent direction conflicts with linked thesis
EXCHANGE_REJECT502Kalshi or Polymarket rejected the order
EXECUTION_HALTED403execution_mode is halted
DRY_RUN200Order accepted as dry-run; no real execution

Resources

CodeStatusMeaning
NOT_FOUND404Resource does not exist or is not visible to you
GONE410Resource was deleted
EXPIRED410Market expired and is settled

Upstream

CodeStatusMeaning
UPSTREAM_UNAVAILABLE502Kalshi / Polymarket / mirror down
UPSTREAM_TIMEOUT504Upstream request timed out
MIRROR_STALE503Mirror data is too old to serve

Internal

CodeStatusMeaning
INTERNAL_ERROR500Unhandled server error (logged with trace_id)
DATABASE_ERROR503Postgres unavailable
LLM_FAILURE503OpenRouter / Anthropic provider failure

How to debug

1

Capture the full error

--json always returns the full error envelope.
2

Note the trace id

details.traceId is the audit chain key.
3

Look up the trace

GET /api/audit/trace/<traceId> (admin) or grep server logs.
4

Inspect risk gates

For RISK_GATE_FAIL, details.blocked lists the specific gate(s).

See also

JSON contract

Exit codes and CLI envelope shape.

Risk gates

Why entry orders fail.

Provenance

traceId audit chain lookup.