Kagura AI Analyses API

Memory Analysis runs. REST companion to the 5 MCP tools (analyze_context / get_analysis / list_analyses / get_active_analysis / get_cluster). Behind a 4-stage gate: workspace owner + Pro tier + per-day quota + workspace allowlist.

GitHub OpenAPI

Operations 8

POST /api/v1/contexts/{context_id}/analyses/preview Estimate analysis cost without starting a run #
POST /api/v1/contexts/{context_id}/analyses Start a Memory Analysis run #
GET /api/v1/contexts/{context_id}/analyses List analysis runs for a context #
GET /api/v1/contexts/{context_id}/analyses/active Most recent succeeded run for a context #
GET /api/v1/contexts/{context_id}/analyses/{run_id} Fetch one analysis run by id #
DELETE /api/v1/contexts/{context_id}/analyses/{run_id} Soft-cancel a running analysis (status → cancelled) #
GET /api/v1/contexts/{context_id}/analyses/{run_id}/clusters List all clusters for an analysis run #
GET /api/v1/contexts/{context_id}/analyses/{run_id}/positions List per-memory 2D positions for an analysis run #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/kagura-ai-com:kagura-ai-com-analyses-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

kagura-ai-com-analyses-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Kagura Memory Cloud Analyses API
  description: Universal AI Memory Platform - Remote MCP Server + Web Management
  version: 0.158.1
tags:
- name: analyses
  description: 'Memory Analysis runs. REST companion to the 5 MCP tools (analyze_context / get_analysis / list_analyses / get_active_analysis / get_cluster). Behind a 4-stage gate: workspace owner + Pro tier + per-day quota + workspace allowlist.'
paths:
  /api/v1/contexts/{context_id}/analyses/preview:
    post:
      tags:
      - analyses
      summary: Estimate analysis cost without starting a run
      description: 'Returns the cost estimate for a hypothetical run.


        Goes through the full 4-gate chain so a non-Pro / quota-exhausted

        / non-allowlisted user gets the same 403/429 they would on POST,

        rather than seeing the price and then being blocked at confirm.'
      operationId: preview_analysis_api_v1_contexts__context_id__analyses_preview_post
      parameters:
      - name: context_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
          title: Context Id
      - name: authorization
        in: header
        required: false
        schema:
          anyOf:
          - type: string
          - type: 'null'
          title: Authorization
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AnalysisPreviewRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnalysisPreviewResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v1/contexts/{context_id}/analyses:
    post:
      tags:
      - analyses
      summary: Start a Memory Analysis run
      description: 'Kick off a background analysis run.


        Returns 202 with the new run_id. The pipeline runs in

        ``asyncio.create_task(run_analysis_task)``; clients poll

        ``GET /analyses/{run_id}`` for status transitions.


        Error mapping (delegated to global handler via custom exceptions):


        - 422 ValidationError — context exceeds the #1244 run-size cap

        (checked BEFORE the idempotency guard, so an over-cap context

        with a run already in flight gets 422, not the 409+run_id hint;

        cancel/poll that run via the list endpoint).

        - 409 ConflictError — a prior run is still ``running`` for the

        same (workspace, context). Body carries the existing run_id.

        - 422 ValidationError — BYOK key missing (orchestrator''s

        pre-flight) OR caller-supplied ``model_id`` does not exist.'
      operationId: start_analysis_api_v1_contexts__context_id__analyses_post
      parameters:
      - name: context_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
          title: Context Id
      - name: authorization
        in: header
        required: false
        schema:
          anyOf:
          - type: string
          - type: 'null'
          title: Authorization
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AnalysisStartRequest'
      responses:
        '202':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnalysisStartResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
    get:
      tags:
      - analyses
      summary: List analysis runs for a context
      description: Return runs for the context, sorted by ``started_at DESC``.
      operationId: list_runs_api_v1_contexts__context_id__analyses_get
      parameters:
      - name: context_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
          title: Context Id
      - name: cursor
        in: query
        required: false
        schema:
          anyOf:
          - type: string
          - type: 'null'
          description: Opaque pagination cursor
          title: Cursor
        description: Opaque pagination cursor
      - name: limit
        in: query
        required: false
        schema:
          anyOf:
          - type: integer
            maximum: 100
            minimum: 1
          - type: 'null'
          title: Limit
      - name: authorization
        in: header
        required: false
        schema:
          anyOf:
          - type: string
          - type: 'null'
          title: Authorization
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnalysisListResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v1/contexts/{context_id}/analyses/active:
    get:
      tags:
      - analyses
      summary: Most recent succeeded run for a context
      description: Returns 404 when the context has no succeeded run yet.
      operationId: get_active_api_v1_contexts__context_id__analyses_active_get
      parameters:
      - name: context_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
          title: Context Id
      - name: authorization
        in: header
        required: false
        schema:
          anyOf:
          - type: string
          - type: 'null'
          title: Authorization
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnalysisRow'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v1/contexts/{context_id}/analyses/{run_id}:
    get:
      tags:
      - analyses
      summary: Fetch one analysis run by id
      operationId: get_run_api_v1_contexts__context_id__analyses__run_id__get
      parameters:
      - name: context_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
          title: Context Id
      - name: run_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
          title: Run Id
      - name: authorization
        in: header
        required: false
        schema:
          anyOf:
          - type: string
          - type: 'null'
          title: Authorization
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnalysisRow'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
    delete:
      tags:
      - analyses
      summary: Soft-cancel a running analysis (status → cancelled)
      description: 'Mark a running run as ``cancelled``.


        No-op (idempotent 200) when the run is already in a terminal

        state — not all clients will ship a "stop polling" hook to detect

        that the run finished between their last poll and the cancel

        click. 409 only for the genuinely contradictory case (status not

        in {running, succeeded, failed, cancelled}).


        Cancellation does NOT decrement the daily quota — the run row

        has already been INSERTed by orchestrator.start, and BYOK /

        partial LLM cost may have been incurred (#496 quota AC).'
      operationId: cancel_run_api_v1_contexts__context_id__analyses__run_id__delete
      parameters:
      - name: context_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
          title: Context Id
      - name: run_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
          title: Run Id
      - name: authorization
        in: header
        required: false
        schema:
          anyOf:
          - type: string
          - type: 'null'
          title: Authorization
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnalysisCancelResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v1/contexts/{context_id}/analyses/{run_id}/clusters:
    get:
      tags:
      - analyses
      summary: List all clusters for an analysis run
      description: 'Returns every cluster row for the run, ordered by ``cluster_index``.


        Powers the #497 frontend cluster list, scatter centroids, and the

        per-cluster property-stats panel. Cluster count is bounded

        server-side by ``ceil(sqrt(memory_count))`` (≈ 90 on an 8000-memory

        run), so the endpoint returns the full set with no pagination — the

        frontend would otherwise have to make up-to-N round-trips to render

        the cluster list which dominates the latency budget on this page.


        A run that is still ``running`` or that ``failed`` before the

        labeler stage may have zero cluster rows; the response is then

        ``items: []`` rather than 404 (matches the running-status semantics

        of the run-level read).'
      operationId: list_run_clusters_api_v1_contexts__context_id__analyses__run_id__clusters_get
      parameters:
      - name: context_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
          title: Context Id
      - name: run_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
          title: Run Id
      - name: authorization
        in: header
        required: false
        schema:
          anyOf:
          - type: string
          - type: 'null'
          title: Authorization
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClusterListResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v1/contexts/{context_id}/analyses/{run_id}/positions:
    get:
      tags:
      - analyses
      summary: List per-memory 2D positions for an analysis run
      description: 'Returns every ``(memory_id, x, y, cluster_index)`` for the scatter dots.


        Bounded by ``MemoryAnalysis.input_count`` (capped at 10k memories

        in the orchestrator). Returns ~640 KB worst-case JSON which is

        acceptable on an explicit page open. No pagination — splitting

        forces the frontend to coordinate progressive renders for very

        little user-visible benefit, and the tab is gated by 4-stage

        auth so the audience is small.


        Same context-boundary check as ``/clusters``: the URL''s

        ``context_id`` must match the run''s stored ``context_id``.'
      operationId: list_run_positions_api_v1_contexts__context_id__analyses__run_id__positions_get
      parameters:
      - name: context_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
          title: Context Id
      - name: run_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
          title: Run Id
      - name: authorization
        in: header
        required: false
        schema:
          anyOf:
          - type: string
          - type: 'null'
          title: Authorization
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PositionListResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    AnalysisPreviewResponse:
      properties:
        memory_count:
          type: integer
          title: Memory Count
        cluster_count_estimate:
          type: integer
          title: Cluster Count Estimate
        estimated_cost_cents:
          anyOf:
          - type: integer
          - type: 'null'
          title: Estimated Cost Cents
        model_id:
          type: string
          title: Model Id
        breakdown:
          additionalProperties:
            type: integer
          type: object
          title: Breakdown
      type: object
      required:
      - memory_count
      - cluster_count_estimate
      - estimated_cost_cents
      - model_id
      - breakdown
      title: AnalysisPreviewResponse
      description: 'Cost-estimate output (Stage [A] from preview.py).


        ``estimated_cost_cents`` is ``null`` when no price is configured for the

        model (#1570) — the estimate is unavailable, not zero — or when the

        deployment disables cost display (``ENABLE_COST_DISPLAY=false``, #1571).'
    ClusterListResponse:
      properties:
        items:
          items:
            $ref: '#/components/schemas/ClusterRow'
          type: array
          title: Items
      type: object
      required:
      - items
      title: ClusterListResponse
      description: All clusters for a run, ordered by ``cluster_index``.
    AnalysisRow:
      properties:
        run_id:
          title: Run Id
        workspace_id:
          title: Workspace Id
        context_id:
          title: Context Id
        status:
          title: Status
        triggered_by:
          title: Triggered By
        started_at:
          title: Started At
        finished_at:
          title: Finished At
        input_count:
          title: Input Count
        cost_estimated_cents:
          title: Cost Estimated Cents
        cost_actual_cents:
          title: Cost Actual Cents
        error:
          title: Error
        cancellation_reason:
          title: Cancellation Reason
      type: object
      required:
      - run_id
      - workspace_id
      - context_id
      - status
      - triggered_by
      - started_at
      - finished_at
      - input_count
      - cost_estimated_cents
      - cost_actual_cents
      - error
      - cancellation_reason
      title: AnalysisRow
      description: 'One row in list / single-fetch responses.


        Fields mirror ``MemoryAnalysis`` columns the API contract surfaces

        (#496 spec). Internal columns like ``model_snapshot`` are omitted

        on purpose — the snapshot is a debugging artifact, not part of

        the public contract, and adds ~500B per row to the list payload.


        ``validation_alias="id"`` (input-only) maps the ORM column ``id``

        → ``run_id`` field while keeping the wire-format key as ``run_id``

        for clients (matches the issue spec naming).'
    PositionRow:
      properties:
        memory_id:
          type: string
          format: uuid
          title: Memory Id
        x:
          type: number
          title: X
        y:
          type: number
          title: Y
        cluster_index:
          type: integer
          title: Cluster Index
      type: object
      required:
      - memory_id
      - x
      - y
      - cluster_index
      title: PositionRow
      description: One ``(memory_id, x, y, cluster_index)`` row for scatter rendering.
    AnalysisListResponse:
      properties:
        items:
          items:
            $ref: '#/components/schemas/AnalysisRow'
          type: array
          title: Items
        next_cursor:
          anyOf:
          - type: string
          - type: 'null'
          title: Next Cursor
      type: object
      required:
      - items
      - next_cursor
      title: AnalysisListResponse
      description: Paginated list of runs.
    ClusterRow:
      properties:
        cluster_index:
          type: integer
          title: Cluster Index
        label:
          type: string
          title: Label
        description:
          anyOf:
          - type: string
          - type: 'null'
          title: Description
        count:
          type: integer
          title: Count
        centroid_2d:
          items:
            type: number
          type: array
          title: Centroid 2D
        representative_memory_ids:
          items:
            type: string
            format: uuid
          type: array
          title: Representative Memory Ids
        property_stats:
          additionalProperties: true
          type: object
          title: Property Stats
        label_confidence:
          type: number
          title: Label Confidence
      type: object
      required:
      - cluster_index
      - label
      - description
      - count
      - centroid_2d
      - representative_memory_ids
      - property_stats
      - label_confidence
      title: ClusterRow
      description: 'One cluster within an analysis run.


        Mirrors ``MemoryAnalysisCluster`` columns the API contract surfaces

        (#497 frontend). Internal columns (``analysis_id``, ``parent_id``,

        cluster ``id`` UUID PK) are omitted: the wire identifier is the

        user-visible ``cluster_index`` ordinal, not the DB UUID.


        ``representative_memory_ids`` is the raw list as stored — the

        frontend resolves these to memory summaries via a follow-up

        ``recall(filters={"id": [...]})`` call rather than embedding the

        summaries in this response (keeps the cluster list payload small

        and lets the recall layer apply its own importance / freshness

        sorting).'
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
            - type: string
            - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
      - loc
      - msg
      - type
      title: ValidationError
    AnalysisCancelResponse:
      properties:
        run_id:
          title: Run Id
        status:
          title: Status
        cancellation_reason:
          title: Cancellation Reason
        finished_at:
          title: Finished At
      type: object
      required:
      - run_id
      - status
      - cancellation_reason
      - finished_at
      title: AnalysisCancelResponse
      description: 'DELETE /{run_id} response — confirms the soft-cancel.


        Same ``model_validate(row)`` pattern as AnalysisStartResponse so

        SQLAlchemy column types are bridged via Pydantic ``from_attributes``.'
    AnalysisStartRequest:
      properties:
        from:
          anyOf:
          - type: string
          - type: 'null'
          title: From
        to:
          anyOf:
          - type: string
          - type: 'null'
          title: To
        types:
          anyOf:
          - items:
              type: string
            type: array
          - type: 'null'
          title: Types
        tags:
          anyOf:
          - items:
              type: string
            type: array
          - type: 'null'
          title: Tags
        min_importance:
          anyOf:
          - type: number
            maximum: 1.0
            minimum: 0.0
          - type: 'null'
          title: Min Importance
        query:
          anyOf:
          - type: string
          - type: 'null'
          title: Query
        model_id:
          anyOf:
          - type: integer
          - type: 'null'
          title: Model Id
      type: object
      title: AnalysisStartRequest
      description: POST /analyses body — same shape as preview (intentional).
    AnalysisPreviewRequest:
      properties:
        from:
          anyOf:
          - type: string
          - type: 'null'
          title: From
        to:
          anyOf:
          - type: string
          - type: 'null'
          title: To
        types:
          anyOf:
          - items:
              type: string
            type: array
          - type: 'null'
          title: Types
        tags:
          anyOf:
          - items:
              type: string
            type: array
          - type: 'null'
          title: Tags
        min_importance:
          anyOf:
          - type: number
            maximum: 1.0
            minimum: 0.0
          - type: 'null'
          title: Min Importance
        query:
          anyOf:
          - type: string
          - type: 'null'
          title: Query
        model_id:
          anyOf:
          - type: integer
          - type: 'null'
          title: Model Id
      type: object
      title: AnalysisPreviewRequest
      description: 'Pre-flight cost-estimate request body.


        Mirrors the POST body so the modal in #497 can submit the same

        payload twice (preview, then run on confirm) without re-shaping.

        Empty body is valid — the preview falls back to the count of

        every memory in the context.'
    PositionListResponse:
      properties:
        items:
          items:
            $ref: '#/components/schemas/PositionRow'
          type: array
          title: Items
      type: object
      required:
      - items
      title: PositionListResponse
      description: All scatter positions for a run, ordered by ``cluster_index``.
    AnalysisStartResponse:
      properties:
        run_id:
          title: Run Id
        status:
          title: Status
        started_at:
          title: Started At
      type: object
      required:
      - run_id
      - status
      - started_at
      title: AnalysisStartResponse
      description: '202 Accepted body.


        Constructed via ``model_validate(analysis)`` so the ORM row''s

        ``id`` column maps to ``run_id`` (matches the issue spec naming)

        and SQLAlchemy ``Column[datetime]`` ↔ Python ``datetime`` is

        bridged by Pydantic''s ``from_attributes`` rather than manual

        cast at every call site.'