> ## Documentation Index
> Fetch the complete documentation index at: https://strattumai.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Execute a read-only Cypher query

> Runs a user-supplied Cypher query against the tenant Memory graph and returns the result in the same v2 contract shape as GET /v1/memory/graph. Backs the Console UI 'Cypher view' feature.

**Safety:** the query is validated to be read-only — write keywords (CREATE, MERGE, DELETE, SET, REMOVE, DROP, FOREACH, LOAD, CALL) cause a 400. Edges between the returned nodes are fetched automatically so the frontend doesn't need to RETURN them.



## OpenAPI

````yaml /api-reference/memory-api.json post /v1/memory/cypher
openapi: 3.1.0
info:
  title: Strattum Memory API
  description: >-
    REST API that serves entity context — profile, timeline, graph, sources and
    formatted context — for agents and UIs. (PRD-003, Workstream 1.3)
  version: 1.0.0
servers: []
security: []
paths:
  /v1/memory/cypher:
    post:
      tags:
        - memory
      summary: Execute a read-only Cypher query
      description: >-
        Runs a user-supplied Cypher query against the tenant Memory graph and
        returns the result in the same v2 contract shape as GET
        /v1/memory/graph. Backs the Console UI 'Cypher view' feature.


        **Safety:** the query is validated to be read-only — write keywords
        (CREATE, MERGE, DELETE, SET, REMOVE, DROP, FOREACH, LOAD, CALL) cause a
        400. Edges between the returned nodes are fetched automatically so the
        frontend doesn't need to RETURN them.
      operationId: run_cypher_v1_memory_cypher_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CypherQueryRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MemoryGraphResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    CypherQueryRequest:
      properties:
        query:
          type: string
          maxLength: 10000
          minLength: 1
          title: Query
          description: >-
            Read-only Cypher query (MATCH / WHERE / RETURN). Write keywords
            (CREATE, MERGE, DELETE, SET, REMOVE, DROP, FOREACH, LOAD, CALL) are
            rejected for safety.
        limit:
          type: integer
          maximum: 5000
          minimum: 1
          title: Limit
          description: Maximum number of nodes to return.
          default: 500
      type: object
      required:
        - query
      title: CypherQueryRequest
      description: Request body for POST /v1/memory/cypher.
    MemoryGraphResponse:
      properties:
        nodes:
          items:
            $ref: '#/components/schemas/MemoryGraphNode'
          type: array
          title: Nodes
        edges:
          items:
            $ref: '#/components/schemas/MemoryGraphEdge'
          type: array
          title: Edges
        truncated:
          type: boolean
          title: Truncated
          description: >-
            True when the result was capped by the ``limit`` parameter. The
            frontend can use this to show 'displaying N of total_nodes'.
          default: false
        total_nodes:
          anyOf:
            - type: integer
            - type: 'null'
          title: Total Nodes
          description: >-
            Actual node count before the cap was applied. Only populated when
            ``truncated=True``.
      type: object
      required:
        - nodes
        - edges
      title: MemoryGraphResponse
      description: Response for GET /graph (the full tenant graph, v2 contract).
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    MemoryGraphNode:
      properties:
        id:
          type: string
          title: Id
        entity_type:
          type: string
          title: Entity Type
        display_tier:
          type: string
          title: Display Tier
          description: >-
            Display tier set at MERGE time by memory-worker (ADR-010):
            ``entity`` (core) | ``activity`` (event-ish) | ``detail`` (child
            rows filtered out of the graph payload).
        display_color:
          type: string
          title: Display Color
          description: >-
            Display color token (ADR-010): blue, green, purple, amber, red,
            indigo, gray.
        properties:
          additionalProperties: true
          type: object
          title: Properties
      type: object
      required:
        - id
        - entity_type
        - display_tier
        - display_color
      title: MemoryGraphNode
      description: A single node in the Memory graph visualisation (v2 contract).
    MemoryGraphEdge:
      properties:
        source:
          type: string
          title: Source
        target:
          type: string
          title: Target
        type:
          type: string
          title: Type
        last_activity_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Last Activity At
          description: >-
            Last activity timestamp materialised on the edge at MERGE time
            (ADR-010). Null for edges where no source timestamp was available.
      type: object
      required:
        - source
        - target
        - type
      title: MemoryGraphEdge
      description: A single edge in the Memory graph visualisation (v2 contract).
    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

````