API Reference

Complete reference for the Tractatus Framework REST API. All endpoints return JSON and require proper authentication where indicated.

Base URL: http://localhost:9000/api

Authentication

POST /auth/login

Authenticate and receive JWT token.

Request Body

{
  "email": "admin@tractatus.local",
  "password": "your_password"
}

Response

{
  "success": true,
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "user": {
    "email": "admin@tractatus.local",
    "role": "admin"
  }
}
GET /auth/me 🔒 Requires Auth

Get current user information.

Headers

Authorization: Bearer {token}

Response

{
  "success": true,
  "user": {
    "id": "68e3a6fb21af2fd194bf4b50",
    "email": "admin@tractatus.local",
    "role": "admin"
  }
}

Documents

GET /documents

Get list of all documents.

Query Parameters

limit Number of results (default: 50)
skip Pagination offset (default: 0)
quadrant Filter by quadrant (STRATEGIC, OPERATIONAL, etc.)

Response

{
  "success": true,
  "documents": [
    {
      "_id": "672f821b6e820c0c7a0e0d55",
      "title": "Introduction to the Tractatus Framework",
      "slug": "introduction-to-the-tractatus-framework",
      "quadrant": "STRATEGIC",
      "content_html": "

Introduction

...", "toc": [{ "level": 1, "text": "Introduction", "slug": "introduction" }], "created_at": "2025-10-07T10:30:00Z" } ], "total": 12 }
GET /documents/:identifier

Get document by ID or slug.

Parameters

identifier Document ID or slug

Response

{
  "success": true,
  "document": {
    "_id": "672f821b6e820c0c7a0e0d55",
    "title": "Introduction to the Tractatus Framework",
    "slug": "introduction-to-the-tractatus-framework",
    "content_html": "

Introduction

The Tractatus framework...

", "toc": [...] } }
GET /documents/search

Full-text search across documents.

Query Parameters

q Search query (required)

Response

{
  "success": true,
  "results": [
    {
      "title": "Core Concepts",
      "slug": "core-concepts",
      "score": 0.92,
      "excerpt": "...boundary enforcement..."
    }
  ]
}

Governance

GET /governance

Get governance framework status.

Response

{
  "success": true,
  "governance": {
    "active": true,
    "services": {
      "classifier": { "enabled": true, "status": "operational" },
      "validator": { "enabled": true, "status": "operational" },
      "boundary": { "enabled": true, "status": "operational" },
      "pressure": { "enabled": true, "status": "operational" },
      "metacognitive": { "enabled": true, "status": "selective" }
    },
    "instruction_count": 7,
    "last_validation": "2025-10-07T12:00:00Z"
  }
}

Admin Endpoints

All admin endpoints require authentication with admin role.

GET /admin/stats 🔒 Admin Only

Get dashboard statistics.

Response

{
  "success": true,
  "documents": 12,
  "pending": 3,
  "approved": 45,
  "users": 5
}
GET /admin/moderation 🔒 Admin Only

Get items in moderation queue.

Response

{
  "success": true,
  "items": [
    {
      "_id": "672f8xxx",
      "type": "blog_post",
      "title": "Understanding Boundary Enforcement",
      "status": "pending",
      "submitted_at": "2025-10-07T11:00:00Z"
    }
  ]
}

Error Codes

Code Description
400 Bad Request - Invalid parameters
401 Unauthorized - Missing or invalid token
403 Forbidden - Insufficient permissions
404 Not Found - Resource does not exist
409 Conflict - Duplicate resource (e.g., slug)
500 Internal Server Error

Error Response Format

{
  "success": false,
  "message": "Error description",
  "error": "ERROR_CODE"
}