> ## 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.

# Network flow tree

> Groups the filtered network flows into a tree by group_by, a list of one or more dimensions applied outermost first: client, client_kind, server, server_kind, server_port, locality and proto. Every node carries its cost, bytes (total and per direction), connections opened, unhealthy connections, share of the filtered bytes and cost, the direction the cost is charged for, and connection_ids (up to 100, connection_ids_truncated when more exist) for charting through GET /service-map/connections/{id}/series. sort_by (cost|bytes, default cost) orders the groups at every level. group_limit (default 20, max 100, negative for all) caps the children under each parent and remainder sums what was cut; group_offset pages the top level only. children_total and nodes_total give the full group counts. A node's cost is null when none of its flows is priced. Every node and the totals also carry previous_bytes_total, previous_cost_monthly (the previous period's traffic priced at each connection's current rate), bytes_change_pct and cost_change_pct, which are null when there is no previous value. Totals describe all filtered flows, so they equal the network detail totals for the same filters. Filters accept locality, kind (the server endpoint kind) and dst_port, AND across dimensions and OR within one.



## OpenAPI

````yaml /api-reference/costgraph/openapi.json post /api/v1/tenant/network/tree
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-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: organization
    x-group: Audit log
  - name: organizations
    x-group: Organizations
  - name: placement-alternatives
    x-group: Placement alternatives
  - name: reports
    x-group: Reports
  - name: service-map
    x-group: Service map
  - 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/network/tree:
    post:
      tags:
        - network-requests
      summary: Network flow tree
      description: >-
        Groups the filtered network flows into a tree by group_by, a list of one
        or more dimensions applied outermost first: client, client_kind, server,
        server_kind, server_port, locality and proto. Every node carries its
        cost, bytes (total and per direction), connections opened, unhealthy
        connections, share of the filtered bytes and cost, the direction the
        cost is charged for, and connection_ids (up to 100,
        connection_ids_truncated when more exist) for charting through GET
        /service-map/connections/{id}/series. sort_by (cost|bytes, default cost)
        orders the groups at every level. group_limit (default 20, max 100,
        negative for all) caps the children under each parent and remainder sums
        what was cut; group_offset pages the top level only. children_total and
        nodes_total give the full group counts. A node's cost is null when none
        of its flows is priced. Every node and the totals also carry
        previous_bytes_total, previous_cost_monthly (the previous period's
        traffic priced at each connection's current rate), bytes_change_pct and
        cost_change_pct, which are null when there is no previous value. Totals
        describe all filtered flows, so they equal the network detail totals for
        the same filters. Filters accept locality, kind (the server endpoint
        kind) and dst_port, AND across dimensions and OR within one.
      parameters:
        - description: Tenant ID
          name: X-CostGraph-Tenant-ID
          in: header
          required: true
          schema:
            type: string
        - description: Cost period; defaults to month_to_date
          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
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/networktree.TreeRequest'
        description: >-
          Dimensions to nest by (group_by), filters as dimension -> values,
          sort_by (cost|bytes), group_limit and group_offset
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/responses.SuccessResponse'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/networktree.TreeResult'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responses.ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responses.ErrorResponse'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responses.ErrorResponse'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responses.ErrorResponse'
      security:
        - BearerAuth: []
components:
  schemas:
    networktree.TreeRequest:
      type: object
      properties:
        filter:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
        group_by:
          type: array
          items:
            type: string
        group_limit:
          type: integer
          nullable: true
        group_offset:
          type: integer
          minimum: 0
        scope:
          type: array
          items:
            type: string
        sort_by:
          type: string
          enum:
            - cost
            - bytes
    responses.SuccessResponse:
      type: object
      required:
        - message
        - status
      properties:
        data: {}
        message:
          type: string
          example: some message
        status:
          type: string
          example: success
    networktree.TreeResult:
      type: object
      properties:
        dimensions:
          type: array
          items:
            type: string
        nodes:
          type: array
          items:
            $ref: '#/components/schemas/networktree.Node'
        nodes_total:
          type: integer
        range:
          $ref: '#/components/schemas/networkdetail.DateRange'
        remainder:
          $ref: '#/components/schemas/networktree.Remainder'
        scope_node:
          allOf:
            - $ref: '#/components/schemas/networktree.Node'
          nullable: true
        totals:
          $ref: '#/components/schemas/networktree.Totals'
    responses.ErrorResponse:
      type: object
      required:
        - message
        - status
      properties:
        message:
          type: string
          example: some message
        status:
          type: string
          example: error
    networktree.Node:
      type: object
      properties:
        bytes_change_pct:
          type: number
          nullable: true
        bytes_client_to_server:
          type: number
        bytes_server_to_client:
          type: number
        bytes_total:
          type: number
        charged_direction:
          type: string
        children:
          type: array
          items:
            $ref: '#/components/schemas/networktree.Node'
        children_total:
          type: integer
        connection_ids:
          type: array
          items:
            type: string
        connection_ids_truncated:
          type: boolean
        connections_opened:
          type: integer
        cost_change_pct:
          type: number
          nullable: true
        cost_monthly:
          type: number
          nullable: true
        dimension:
          type: string
        key:
          type: string
        kind:
          type: string
        label:
          type: string
        previous_bytes_total:
          type: number
        previous_cost_monthly:
          type: number
          nullable: true
        remainder:
          $ref: '#/components/schemas/networktree.Remainder'
        share_of_bytes:
          type: number
        share_of_cost:
          type: number
          nullable: true
        unhealthy_connections:
          type: integer
    networkdetail.DateRange:
      type: object
      properties:
        end:
          type: string
        start:
          type: string
    networktree.Remainder:
      type: object
      properties:
        bytes_total:
          type: number
        cost_monthly:
          type: number
          nullable: true
        count:
          type: integer
        unhealthy_connections:
          type: integer
    networktree.Totals:
      type: object
      properties:
        bytes_change_pct:
          type: number
          nullable: true
        bytes_total:
          type: number
        connections:
          type: integer
        connections_opened:
          type: integer
        cost_change_pct:
          type: number
          nullable: true
        cost_monthly:
          type: number
          nullable: true
        previous_bytes_total:
          type: number
        previous_cost_monthly:
          type: number
          nullable: true
        unhealthy_connections:
          type: integer
  securitySchemes:
    BearerAuth:
      description: Enter "Bearer {token}"
      type: apiKey
      name: Authorization
      in: header

````

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