SageOx Guidance API

AI-generated guidance content and statistics. Provides contextual recommendations, best practices, and insights derived from team context and recording analysis.

OpenAPI Specification

sageox-guidance-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: SageOx Admin Guidance API
  version: 1.0.0
  description: "# API Reference\n\n## Overview\n\nSageOx is a platform that captures team knowledge from discussions, decisions, and work context into a Ledger (per-repo historical record) and Team Context (team-wide shared knowledge). The SageOx API provides programmatic access to manage repositories, recordings, notifications, and team data with high performance and reliability.\n\n## Base URLs\n\n| Environment | URL |\n|---|---|\n| Local Development | `http://localhost:3000` |\n| Test | `https://test.sageox.ai` |\n| Production | `https://sageox.ai` |\n\n## Authentication\n\nAll requests to the SageOx API require authentication via JWT tokens issued by the Better Auth service.\n\nInclude your token in the `Authorization` header:\n```\nAuthorization: Bearer <token>\n```\n\n**Initial Auth Flow (CLI)**\n- CLI initiates device flow to obtain initial credentials\n- Exchange device code for JWT token\n- Store token securely for subsequent API requests\n- Refresh token when expired\n\n**Authenticated Endpoints**\n- Pass JWT in `Authorization: Bearer <token>` header\n- Tokens contain user identity and team membership\n- Invalid or expired tokens return 401 Unauthorized\n\n## Response Format\n\n### Success\nStandard response format with optional pagination metadata:\n```json\n{\n  \"success\": true,\n  \"data\": { ... }\n}\n```\n\n### Error\nAll errors follow a consistent format:\n```json\n{\n  \"success\": false,\n  \"error\": \"Human-readable error description\"\n}\n```\n\n**Status Codes**\n- `400` — Bad Request: Invalid parameters or malformed request\n- `401` — Unauthorized: Missing or invalid authentication token\n- `403` — Forbidden: Insufficient permissions for this resource\n- `404` — Not Found: Resource does not exist\n- `409` — Conflict: Request conflicts with current state (e.g., duplicate)\n- `429` — Rate Limited: Too many requests; retry with backoff\n- `500` — Internal Error: Server error; contact support if persistent\n\n## Pagination\n\nList endpoints support cursor-based pagination via query parameters:\n\n**Query Parameters**\n- `limit` — Number of results per page (default: 20, max: 100)\n- `offset` — Number of results to skip (default: 0)\n\n**Response Metadata**\nList responses include pagination info:\n```json\n{\n  \"success\": true,\n  \"data\": [ ... ],\n  \"meta\": {\n    \"total\": 150,\n    \"limit\": 20,\n    \"offset\": 0,\n    \"hasMore\": true\n  }\n}\n```\n\n## ID Formats\n\nResources use standardized ID formats for easy identification:\n\n| Resource | Format | Length | Example |\n|---|---|---|---|\n| Team | `team_<cuid2>` | 10 chars | `team_abc1234567` |\n| User | `usr_<cuid2>` | 10 chars | `usr_xyz9876543` |\n| Repository | `repo_<uuidv7>` | 36 chars | `repo_01934f5a-8b9c-7def-abcd-0123456789ab` |\n| Recording | `rec_<uuidv7>` | 36 chars | `rec_01934f5a-8b9c-7def-abcd-0123456789ab` |\n| Image | `img_<uuidv7>` | 36 chars | `img_01934f5a-8b9c-7def-abcd-0123456789ab` |\n| Notification | `notif_<cuid2>` | 14 chars | `notif_ab1cd2ef3g` |\n\nUse these IDs for all API operations. IDs are unique across environments.\n\n## Rate Limiting\n\nThe API applies rate limiting to protect against abuse and ensure fair access:\n\n**Authenticated Endpoints**\n- Limited per user: depends on subscription tier\n- Quota resets hourly\n\n**Unauthenticated Endpoints**\n- Limited per IP address\n- More restrictive than authenticated limits\n\nWhen rate limited, the API returns `429 Too Many Requests`. Retry requests with exponential backoff:\n```\nwait = min(2^attempt * 100ms, 10s)\n```\n\n## Timestamps\n\nAll timestamps in API responses use RFC 3339 / ISO 8601 format in UTC:\n```\n2025-12-03T10:30:00Z\n```\n\nUse this format when providing timestamps in requests as well. The API rejects timestamps in other formats.\n\n## SDKs & Tools\n\n- **OpenAPI Spec** — Full schema available at `/api/openapi.json`\n- **Postman Collection** — Import from `/api/postman.json` for interactive exploration\n- **CLI** — Use `ox` CLI for command-line access\n"
  contact:
    name: SageOx Team
  license:
    name: MIT
servers:
- url: http://localhost:3000
  description: Devcontainer
- url: https://test.sageox.ai
  description: Test
- url: https://sageox.ai
  description: Production
security:
- bearerAuth: []
tags:
- name: Guidance
  description: 'AI-generated guidance content and statistics. Provides contextual recommendations, best practices, and insights derived from team context and recording analysis.

    '
paths:
  /api/v1/guidance/:
    get:
      operationId: getRootGuidance
      summary: Get root guidance content
      description: 'Returns guidance content for the root path.

        Used to bootstrap guided experiences and progressive disclosure.


        **Progressive disclosure:** Guidance is tiered based on user context:

        - Unauthenticated: Limited guidance, 60 req/min

        - Authenticated: Full guidance, 300 req/min


        **Authentication:** Optional (tiered rate limiting based on auth status)

        **Rate limit:** Tiered (60 req/min unauthenticated, 300 req/min authenticated)

        '
      tags:
      - Guidance
      security:
      - BearerAuth: []
      - {}
      responses:
        '200':
          description: Root guidance content
          content:
            application/json:
              schema:
                type: object
                properties:
                  title:
                    type: string
                    example: Getting Started
                  content:
                    type: string
                    description: Markdown content
                    example: '# Getting Started\n\nWelcome to SageOx...'
                  sections:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                        title:
                          type: string
                        href:
                          type: string
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /api/v1/guidance/{path}:
    get:
      operationId: getPathGuidance
      summary: Get path-based guidance
      description: 'Returns guidance content for a specific path (wildcard route).

        Supports nested paths for progressive disclosure.


        **Path examples:**

        - `/api/v1/guidance/getting-started`

        - `/api/v1/guidance/repos/setup`

        - `/api/v1/guidance/teams/collaboration`


        **Progressive disclosure:** Content adjusted based on user tier and context


        **Authentication:** Optional (tiered rate limiting)

        **Rate limit:** Tiered (60 req/min unauthenticated, 300 req/min authenticated)

        '
      tags:
      - Guidance
      security:
      - BearerAuth: []
      - {}
      parameters:
      - in: path
        name: path
        required: true
        schema:
          type: string
        description: Guidance path (supports nested paths with slashes)
        example: getting-started/setup
      responses:
        '200':
          description: Guidance content for path
          content:
            application/json:
              schema:
                type: object
                properties:
                  path:
                    type: string
                    example: getting-started
                  title:
                    type: string
                    example: Getting Started
                  content:
                    type: string
                    description: Markdown content
                    example: '# Getting Started\n\nStep by step guide...'
                  next:
                    type: array
                    description: Suggested next topics
                    items:
                      type: object
                      properties:
                        path:
                          type: string
                        title:
                          type: string
        '404':
          description: Guidance not found for path
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /api/v1/guidance/my-stats:
    get:
      operationId: getGuidanceStats
      summary: Get user guidance statistics
      description: 'Returns guidance-related statistics for the authenticated user.

        Tracks progress, visited topics, and engagement metrics.


        **Statistics tracked:**

        - Topics visited

        - Guidance completion percentage

        - Recommended next steps based on usage


        **Authentication:** Bearer token required

        '
      tags:
      - Guidance
      security:
      - BearerAuth: []
      responses:
        '200':
          description: Guidance statistics for user
          content:
            application/json:
              schema:
                type: object
                properties:
                  total_topics:
                    type: integer
                    example: 15
                  visited_topics:
                    type: integer
                    example: 8
                  completion_percentage:
                    type: integer
                    description: Percentage of guidance completed
                    example: 53
                  last_visited:
                    type: string
                    format: date-time
                    example: '2025-12-18T10:30:00Z'
                  recommended:
                    type: array
                    description: Recommended topics based on usage
                    items:
                      type: object
                      properties:
                        path:
                          type: string
                        title:
                          type: string
                        reason:
                          type: string
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    ErrorResponse:
      type: object
      description: Standard error response returned by all endpoints on failure.
      required:
      - success
      - error
      properties:
        success:
          type: boolean
          description: Always `false` for error responses.
          enum:
          - false
        error:
          type: string
          description: Human-readable error message describing what went wrong. Do not parse this programmatically — use HTTP status codes for control flow.
          example: Invalid request parameters
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 'JWT token obtained from the auth service (/api/auth/token).

        Token is validated using JWKS from the auth service.

        Required claims: sub (user_id), email, name, tier.

        '