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

# Search the context graph

> Boxes, connections and signals matching a name or identifier, highest cost first. q needs at least 2 characters. matches_total counts the matches before the cap (CONTEXT_GRAPH_SEARCH_LIMIT) up to 20 times that limit, and matches_capped is true when there are more; a capped search ranks the first matches found, not all of them. Boxes have the shape of context graph nodes with identity, parent, child_count, cost, basis, group, flavour and cluster (the cluster above the box) filled, and breakdown, meters, signals, refs other than provider, version, instance_type, gpu_model, idle_share and has_infrastructure empty, because a search hit does not load box detail; open the box with the children endpoint for them. Boxes also carry path, the names of the boxes above each one from the top, and ancestors, the ids of the boxes above it from the top down to its direct parent (empty for a top-level box), so a client can open each level with the children endpoint; connections have the same shape as its links; both ends of every connection are among the boxes, and a connection end that is not a match carries its cost only. With scope=network only boxes that take part in network links, and the boxes above them, are searched. filter narrows the boxes to the ones with matching cost rows in the window, ranked among the best matches, and filters echoes the filters applied.



## OpenAPI

````yaml /api-reference/costgraph/openapi.json get /api/v1/tenant/context-graph/search
openapi: 3.0.0
info:
  description: Read and manage your CostGraph organization, spend, alerts, and settings.
  title: CostGraph API
  contact: {}
  version: '1.0'
servers:
  - url: https://api.costgraph.ai
security: []
tags:
  - name: ai
    x-group: AI
  - name: ai-serving
    x-group: AI serving
  - name: anomalies
    x-group: Anomalies
  - name: auth
    x-group: Auth
  - name: billing
    x-group: Billing
  - name: billing-export
    x-group: Billing export
  - name: budgets
    x-group: Budgets
  - name: ci
    x-group: CI
  - name: compute-recommendations
    x-group: Compute recommendations
  - name: config
    x-group: Config
  - name: context-graph
    x-group: Context graph
  - name: cost
    x-group: Cost
  - name: gpus
    x-group: GPUs
  - name: graphai
    x-group: Graph AI
  - name: integrations
    x-group: Integrations
  - name: invitations
    x-group: Invitations
  - name: kubernetes-clusters
    x-group: Kubernetes clusters
  - name: marketplace
    x-group: Marketplace
  - name: network
    x-group: Network
  - name: network-requests
    x-group: Network requests
  - name: notifications
    x-group: Notifications
  - name: oauth
    x-group: OAuth
  - name: oauth-clients
    x-group: OAuth clients
  - name: opencost
    x-group: OpenCost
  - name: operator
    x-group: Operator
  - name: organization
    x-group: Audit log
  - name: organizations
    x-group: Organizations
  - name: placement-alternatives
    x-group: Placement alternatives
  - name: reports
    x-group: Reports
  - name: sandboxes
    x-group: Sandboxes
  - name: settings
    x-group: Settings
  - name: sso
    x-group: Single sign-on
  - name: tenants
    x-group: Tenants
  - name: ticketing
    x-group: Ticketing
  - name: user
    x-group: Users
  - name: virtual-machines
    x-group: Virtual machines
  - name: virtual-tags
    x-group: Virtual tags
  - name: workflows
    x-group: Workflows
paths:
  /api/v1/tenant/context-graph/search:
    get:
      tags:
        - context-graph
      summary: Search the context graph
      description: >-
        Boxes, connections and signals matching a name or identifier, highest
        cost first. q needs at least 2 characters. matches_total counts the
        matches before the cap (CONTEXT_GRAPH_SEARCH_LIMIT) up to 20 times that
        limit, and matches_capped is true when there are more; a capped search
        ranks the first matches found, not all of them. Boxes have the shape of
        context graph nodes with identity, parent, child_count, cost, basis,
        group, flavour and cluster (the cluster above the box) filled, and
        breakdown, meters, signals, refs other than provider, version,
        instance_type, gpu_model, idle_share and has_infrastructure empty,
        because a search hit does not load box detail; open the box with the
        children endpoint for them. Boxes also carry path, the names of the
        boxes above each one from the top, and ancestors, the ids of the boxes
        above it from the top down to its direct parent (empty for a top-level
        box), so a client can open each level with the children endpoint;
        connections have the same shape as its links; both ends of every
        connection are among the boxes, and a connection end that is not a match
        carries its cost only. With scope=network only boxes that take part in
        network links, and the boxes above them, are searched. filter narrows
        the boxes to the ones with matching cost rows in the window, ranked
        among the best matches, and filters echoes the filters applied.
      parameters:
        - description: Tenant ID
          name: X-CostGraph-Tenant-ID
          in: header
          schema:
            type: string
        - description: Search text, at least 2 characters
          name: q
          in: query
          required: true
          schema:
            type: string
        - description: Window; defaults to last_7d
          name: period
          in: query
          schema:
            type: string
            enum:
              - month_to_date
              - last_7d
              - last_30d
              - calendar_month
              - custom
        - description: >-
            Closed calendar month in YYYY-MM format; required when
            period=calendar_month
          name: month
          in: query
          schema:
            type: string
        - description: Window start in RFC3339 format; required when period=custom
          name: start
          in: query
          schema:
            type: string
        - description: Window end in RFC3339 format; required when period=custom
          name: end
          in: query
          schema:
            type: string
        - description: >-
            Limit the search to boxes that take part in network links; only
            network is accepted
          name: scope
          in: query
          schema:
            type: string
            enum:
              - network
        - description: >-
            Repeated key:value dimension filter, same keys and modifiers as
            /cost/query
          name: filter
          in: query
          style: form
          explode: false
          schema:
            type: array
            items:
              type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/responses.SuccessResponse'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/contextgraph.SearchResult'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responses.ErrorResponse'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responses.ErrorResponse'
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/controllers.ContextGraphBuildingResponse'
      security:
        - BearerAuth: []
        - ApiKeyAuth: []
components:
  schemas:
    responses.SuccessResponse:
      type: object
      required:
        - message
        - status
      properties:
        data: {}
        message:
          type: string
          example: some message
        status:
          type: string
          example: success
    contextgraph.SearchResult:
      type: object
      properties:
        boxes:
          type: array
          items:
            $ref: '#/components/schemas/contextgraph.SearchBox'
        connections:
          type: array
          items:
            $ref: '#/components/schemas/contextgraph.Link'
        filters:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
        matches_capped:
          type: boolean
        matches_total:
          type: integer
        signals:
          type: array
          items:
            $ref: '#/components/schemas/contextgraph.SearchSignal'
    responses.ErrorResponse:
      type: object
      required:
        - message
        - status
      properties:
        message:
          type: string
          example: some message
        status:
          type: string
          example: error
    controllers.ContextGraphBuildingResponse:
      type: object
      properties:
        code:
          type: string
          enum:
            - context_graph_building
        message:
          type: string
          example: The context graph is being built for this tenant
        retry_after_seconds:
          type: integer
        status:
          type: string
          example: error
    contextgraph.SearchBox:
      type: object
      properties:
        ancestors:
          type: array
          items:
            type: string
        basis:
          type: string
          enum:
            - billed
            - allocated
            - not_billed
        basis_parts:
          type: array
          items:
            type: string
            enum:
              - nodes
              - vms
              - disks
              - load_balancers
              - nat_gateways
              - vpc_endpoints
              - network_interfaces
              - managed_databases
              - managed_caches
              - file_systems
              - clusters
              - accounts
              - saas_services
              - ai_models
              - groups
              - data_transfer
        breakdown_allocated:
          type: array
          items:
            $ref: '#/components/schemas/contextgraph.Breakdown'
        breakdown_billed:
          type: array
          items:
            $ref: '#/components/schemas/contextgraph.Breakdown'
        child_count:
          type: integer
        cluster:
          type: string
        cost:
          type: number
          x-semantic: costAmount
        filter_match:
          type: string
          enum:
            - direct
            - connected
        flavour:
          type: string
          enum:
            - eks
            - gke
            - aks
            - Deployment
            - StatefulSet
            - DaemonSet
            - CronJob
            - Job
            - ReplicaSet
            - Pod
            - Service
            - Rollout
          nullable: true
        gpu_model:
          type: string
        group:
          type: string
          enum:
            - service
            - db_cluster
            - cache_group
            - endpoints
            - unplaced
        has_infrastructure:
          type: boolean
        id:
          type: string
        idle_share:
          type: number
        instance_type:
          type: string
        kind:
          type: string
        meters:
          type: array
          items:
            $ref: '#/components/schemas/contextgraph.Meter'
        name:
          type: string
        open:
          type: boolean
        parent_id:
          type: string
          nullable: true
        path:
          type: array
          items:
            type: string
        primary:
          type: string
          enum:
            - node
            - vm
            - workload
            - pv
            - cluster
            - cost_tree
          nullable: true
        provider:
          type: string
        provider_name:
          type: string
        refs:
          $ref: '#/components/schemas/contextgraph.Refs'
        signals:
          type: array
          items:
            $ref: '#/components/schemas/contextgraph.Signal'
        version:
          type: string
    contextgraph.Link:
      type: object
      properties:
        a:
          type: string
        b:
          type: string
        bytes:
          type: number
        cost:
          type: number
          x-semantic: costAmount
          nullable: true
        count:
          type: integer
        direction:
          type: string
          enum:
            - in
            - out
            - both
          nullable: true
        id:
          type: string
        means:
          type: string
          enum:
            - runs_on
            - mounts
            - backed_by
            - network
            - through_nat
            - forwards_to
            - calls
            - billed_under
        nat_share:
          type: number
          x-semantic: costAmount
          nullable: true
        port:
          type: integer
          nullable: true
        source:
          type: string
          enum:
            - inventory
            - observed
            - configured
            - inferred
        write_share:
          type: number
          nullable: true
    contextgraph.SearchSignal:
      type: object
      properties:
        anomaly_id:
          type: string
          nullable: true
        entity_id:
          type: string
        title:
          type: string
    contextgraph.Breakdown:
      type: object
      properties:
        cost:
          type: number
          x-semantic: costAmount
        estimate:
          type: boolean
        key:
          type: string
        share:
          type: number
          nullable: true
    contextgraph.Meter:
      type: object
      properties:
        amortization_months:
          type: integer
        cost:
          type: number
          x-semantic: costAmount
        key:
          type: string
          enum:
            - cpu_cores
            - memory_gb
            - gpus
            - running_hours
            - vcpus
            - price_per_hour
            - disk_gb
            - iops
            - throughput_mbps
            - bytes_processed
            - bytes
            - tokens
            - billed_time
            - billed_data
            - billed_storage
            - billed_capacity
            - billed_requests
            - billed_tokens
        list_price:
          type: number
          x-semantic: costAmount
        price_source:
          type: string
          enum:
            - catalog
            - pin
        provisioned:
          type: number
          nullable: true
        unit:
          type: string
        value:
          type: number
    contextgraph.Refs:
      type: object
      properties:
        bill_resource_id:
          type: string
        cluster_id:
          type: string
        cost_filter:
          type: array
          items:
            type: string
        gpu_uuids:
          type: array
          items:
            type: string
        network_endpoint_id:
          type: string
        node_id:
          type: string
        provider:
          type: string
        provider_connected:
          type: boolean
        pv_resource_id:
          type: string
        pvc_resource_id:
          type: string
        vm_host_id:
          type: string
        workload_resource_id:
          type: string
    contextgraph.Signal:
      type: object
      properties:
        actions:
          type: array
          items:
            type: string
        anomaly_id:
          type: string
        anomaly_type:
          type: string
        code:
          type: string
          enum:
            - unnamed_private_traffic
            - unnamed_private_traffic_granted
            - no_network_tracing
        containers:
          type: array
          items:
            type: string
        count:
          type: integer
        description:
          type: string
        idle:
          type: boolean
        idle_cost:
          type: number
          x-semantic: costAmount
        idle_share:
          type: number
        kind:
          type: string
          enum:
            - anomaly
            - recommendation
            - idle
            - data_note
        recommended_instance_type:
          type: string
        savings_currency:
          type: string
        savings_monthly:
          type: number
          x-semantic: costAmount
        target:
          type: string
          enum:
            - node
            - vm
            - workload
            - pv
            - provider
        target_provider:
          type: string
        target_service:
          type: string
        title:
          type: string
  securitySchemes:
    BearerAuth:
      description: Enter "Bearer {token}"
      type: apiKey
      name: Authorization
      in: header
    ApiKeyAuth:
      description: API key for machine-to-machine authentication
      type: apiKey
      name: X-API-Key
      in: header

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.