Internal HTTP API
Implemented same-origin authentication, conversation, strategy and market routes.
On this page
Common request and error conventions
These Route Handlers serve the CogniTech application. They are not versioned public third-party endpoints. Routes scoped to chat or strategies require a valid session cookie and matching x-cogni-wallet header. JSON mutations use application/json, validate request shape and enforce same-origin where specified. Path identifiers for persisted records are UUIDs. Error bodies use error.code and error.message. Invalid input is 400; unauthenticated is 401; origin rejection is 403; missing owned records are 404; conflicts can be 409; payload and rate limits can return 413 and 429; unavailable services may return 503.
POST /api/auth/nonce HTTP/1.1
Origin: http://localhost:3000
Content-Type: application/json
{"address":"<connected Elysium wallet address>"}{"error":{"code":"sign_in_required","message":"Verify the connected wallet to access this chat."}}Authentication
| Method and path | Input | Result |
|---|---|---|
| POST /api/auth/nonce | address | message containing the challenge to sign |
| POST /api/auth/verify | message, signature | wallet, aiConfigured, maxMessageLength and session cookie |
| GET /api/auth/session | existing cookie if present | wallet or null, aiConfigured, maxMessageLength |
| POST /api/auth/logout | same-origin request | ok and revoked session cookie |
Conversation and action routes
In this table, S is /api/chat/sessions and :id is a session UUID. Message and action IDs are independently scoped.
| Method and path | Input | Result |
|---|---|---|
| GET S | q and optional cursor from the previous response | Owned sessions and next cursor |
| POST S | requestId; optional imported user-message array | New or reused session |
| GET S/:id | path ID | Session metadata |
| PATCH S/:id | title | Updated session metadata |
| DELETE S/:id | path ID | Deletion acknowledgment |
| GET S/:id/messages | optional before sequence cursor | Ordered messages and pagination |
| POST S/:id/messages | requestId, message, optional timezone, local, regenerate UUID | NDJSON turn or existing request state as JSON |
| PATCH S/:id/messages/:messageId/feedback | feedback positive, negative, or null | Feedback acknowledgment |
| PATCH /api/chat/actions/:actionId | status awaiting_review, cancelled, confirmed, failed or interrupted | Updated status; invalid transitions can conflict |
{"requestId":"9da52e9c-b62e-4a1f-8a45-de83f030aff3","message":"Explain a Merkle root.","timezone":"UTC"}Strategy routes
T is /api/strategies. The strategy ID is a path UUID. Edits and run mutations are subject to origin and rate checks.
| Method and path | Input | Result |
|---|---|---|
| GET T | none | Owned strategy summaries |
| POST T | requestId, optional registered template | Strategy ID, 201 |
| GET T/:id | path ID | Owned graph and revision |
| PATCH T/:id | revision and graph or name | Saved graph state; stale revisions can return 409 |
| DELETE T/:id | path ID | ok |
| POST T/generate | requestId and prompt | New strategy ID and optional message, 201 |
| POST T/:id/assist | prompt and checked graph | Structured proposal or explanation |
| POST T/:id/duplicate | requestId | Copy ID, 201 |
| GET / POST T/:id/versions | GET none; POST revision | Version list or checkpoint ID, 201 for creation |
| POST T/:id/restore | revision and version UUID | Restored draft state |
| GET / POST T/:id/runs | GET none; POST revision and optional node | Run list or new run ID, 201 for creation |
| PATCH T/:id/runs | step event with run, node, order and status, or end event with run and status | ok |
| GET T/quote | asset BTC, ETH or SOL | Validated timestamped quote |
| POST T/:id/analyze | type research/analysis/decision, asset BTC/ETH/SOL or empty, topic, web, options array, and nullable public price or research context | NDJSON tool/progress and result or error |
{"type":"step","run":"8c2d9a49-2b4c-4c44-8ac3-558d8076af43","node":"start","order":0,"status":"passed"}See stream framing and database architecture.

CogniTech