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

# Get widget chart data

> Returns chart data for one or more widget types in the requested time range.

**Workflow**

1. `GET /widgets` — list valid widget slugs (`data[].id`).
2. `POST /applications/{applicationId}/widget-data` — pass those slugs as body `types` (array of strings), plus `start` and `end` (ISO 8601 UTC, inclusive; `end` must be on or after `start`).

**Request body**

| Field | Required | When to use |
| --- | --- | --- |
| `types` | yes | Widget slugs from `GET /widgets` `data[].id` (e.g. `sessions-evaluated`, `guardrail-latency`) |
| `start`, `end` | yes | Time range for the charts |

**Response**

- `data` — array of widget results in the same order as `types`. Each item includes:
  - `id` — requested widget slug
  - `data` — chart payload when successful; shape depends on the widget (see response examples)
  - `meta.source` — category label for the widget data (see response examples)
  - `meta.type` — resolved widget type (e.g. `token-usage` may map to `tokens-analysis`)
  - `message` / `code` — present when that widget could not be loaded (`unknown_type`, `unsupported`, `upstream`)

Time-bucketed series are zero-filled between `start` and `end`. Bucket granularity (hour / day / week / month) is chosen from the range length.



## OpenAPI

````yaml /openapi.json post /applications/{applicationId}/widget-data
openapi: 3.0.0
info:
  title: Trusys API
  version: 1.0.0
  description: >-
    Programmatic access to Trusys for integrating AI quality monitoring,
    evaluation, and guardrails into your own systems — without using the Trusys
    UI.


    **Typical integration flow**


    1. `POST /applications` — register your application and get an id.

    2. `PUT /applications/{id}/monitoring` and/or `PUT
    /applications/{id}/guardrails` — configure which metrics, security plugins,
    and guardrails apply.

    3. `POST /applications/{id}/evaluations` — submit prompt/response traces to
    be scored as your application runs.

    4. `GET /applications/{id}/traces`, `GET /applications/{id}/evaluations`,
    and `POST /applications/{id}/widget-data` — pull results, trends, and
    dashboard-equivalent chart data back into your own tools.


    All requests require an `x-api-key` header (see Authentication). All
    timestamps are ISO 8601 UTC. Paginated endpoints default to 20 items per
    page (max 100).
servers:
  - url: https://app.trusys.ai/api/external
security:
  - ApiKeyAuth: []
paths:
  /applications/{applicationId}/widget-data:
    post:
      tags:
        - Widgets
      summary: Get widget chart data
      description: >-
        Returns chart data for one or more widget types in the requested time
        range.


        **Workflow**


        1. `GET /widgets` — list valid widget slugs (`data[].id`).

        2. `POST /applications/{applicationId}/widget-data` — pass those slugs
        as body `types` (array of strings), plus `start` and `end` (ISO 8601
        UTC, inclusive; `end` must be on or after `start`).


        **Request body**


        | Field | Required | When to use |

        | --- | --- | --- |

        | `types` | yes | Widget slugs from `GET /widgets` `data[].id` (e.g.
        `sessions-evaluated`, `guardrail-latency`) |

        | `start`, `end` | yes | Time range for the charts |


        **Response**


        - `data` — array of widget results in the same order as `types`. Each
        item includes:
          - `id` — requested widget slug
          - `data` — chart payload when successful; shape depends on the widget (see response examples)
          - `meta.source` — category label for the widget data (see response examples)
          - `meta.type` — resolved widget type (e.g. `token-usage` may map to `tokens-analysis`)
          - `message` / `code` — present when that widget could not be loaded (`unknown_type`, `unsupported`, `upstream`)

        Time-bucketed series are zero-filled between `start` and `end`. Bucket
        granularity (hour / day / week / month) is chosen from the range length.
      operationId: postWidgetData
      parameters:
        - $ref: '#/components/parameters/applicationId'
      requestBody:
        required: true
        description: Widget types and time range (`types`, `start`, `end`).
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WidgetDataRequest'
            examples:
              monitoringSessions:
                summary: Monitoring — sessions evaluated
                description: >-
                  Session pass/fail/error totals and time series for a
                  monitoring widget.
                value:
                  types:
                    - sessions-evaluated
                  start: '2026-01-01T00:00:00.000Z'
                  end: '2026-01-31T23:59:59.999Z'
              monitoringHealthScore:
                summary: Monitoring — AI reliability score
                value:
                  types:
                    - current-health-score
                  start: '2026-01-01T00:00:00.000Z'
                  end: '2026-01-31T23:59:59.999Z'
              guardrailLatency:
                summary: Guardrails — latency over time
                value:
                  types:
                    - guardrail-latency
                  start: '2026-01-01T00:00:00.000Z'
                  end: '2026-01-31T23:59:59.999Z'
              multipleWidgets:
                summary: Multiple widgets in one request
                value:
                  types:
                    - sessions-evaluated
                    - guardrail-latency
                  start: '2026-01-01T00:00:00.000Z'
                  end: '2026-01-31T23:59:59.999Z'
      responses:
        '200':
          description: >-
            Widget chart data. Each `data[]` item corresponds to one requested
            widget id in the same order as `types`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WidgetDataResponse'
              examples:
                monitoringSessions:
                  summary: sessions-evaluated (monitoring)
                  description: >-
                    Returns evaluation totals plus time-bucketed series.
                    `sessions_chart_data` / `traces_chart_data` are arrays of
                    buckets; each bucket holds `[bucketLabel, count, status,
                    bucketLabel]` tuples for Success, Fail, and Error.
                  value:
                    success: true
                    data:
                      - id: sessions-evaluated
                        data:
                          sessions_total_requests: 120
                          sessions_total_success: 100
                          sessions_total_failures: 15
                          sessions_total_errors: 5
                          sessions_chart_data:
                            - - - '2026-01-01'
                                - 35
                                - Success
                                - '2026-01-01'
                              - - '2026-01-01'
                                - 4
                                - Fail
                                - '2026-01-01'
                              - - '2026-01-01'
                                - 1
                                - Error
                                - '2026-01-01'
                            - - - '2026-01-02'
                                - 40
                                - Success
                                - '2026-01-02'
                              - - '2026-01-02'
                                - 6
                                - Fail
                                - '2026-01-02'
                              - - '2026-01-02'
                                - 0
                                - Error
                                - '2026-01-02'
                          traces_total_requests: 340
                          traces_total_success: 280
                          traces_total_failures: 55
                          traces_total_errors: 5
                          traces_chart_data: []
                        meta:
                          source: pulse
                          type: sessions-evaluated
                monitoringHealthScore:
                  summary: current-health-score (monitoring)
                  description: >-
                    Reliability score summary with `chart_data` points
                    (`timestamp`, `pass_cases`, `total_cases`,
                    `reliability_score`).
                  value:
                    success: true
                    data:
                      - id: current-health-score
                        data:
                          bucket_type: daily
                          reliability_score: 0.8333
                          pass_cases: 100
                          total_cases: 120
                          chart_data:
                            - timestamp: '2026-01-01 00:00:00'
                              pass_cases: 35
                              total_cases: 40
                              reliability_score: 0.875
                            - timestamp: '2026-01-02 00:00:00'
                              pass_cases: 40
                              total_cases: 48
                              reliability_score: 0.8333
                        meta:
                          source: pulse
                          type: current-health-score
                guardrailsLatency:
                  summary: guardrail-latency (guardrails)
                  description: >-
                    Daily input/output latency percentiles in
                    `guardrailLatencyData`.
                  value:
                    success: true
                    data:
                      - id: guardrail-latency
                        data:
                          guardrailLatencyData:
                            - timestamp: '2026-01-01T00:00:00.000Z'
                              inputAvg: 42.5
                              inputP60: 38
                              inputP90: 95
                              inputP99: 180
                              outputAvg: 55.1
                              outputP60: 48
                              outputP90: 110
                              outputP99: 210
                        meta:
                          source: guardrails
                          type: guardrail-latency
                guardrailsSummary:
                  summary: guardrail-exceptions (guardrails)
                  description: Summary metric cards grouped by rail in `summaryData`.
                  value:
                    success: true
                    data:
                      - id: guardrail-exceptions
                        data:
                          summaryData:
                            all:
                              totalRequests: 500
                              validationChecks: 500
                              exceptions: 12
                              exceptionsPercentage: 2.4
                            input:
                              totalRequests: 300
                              validationChecks: 300
                              exceptions: 8
                              exceptionsPercentage: 2.67
                            output:
                              totalRequests: 200
                              validationChecks: 200
                              exceptions: 4
                              exceptionsPercentage: 2
                        meta:
                          source: guardrails
                          type: guardrail-exceptions
        '400':
          description: >-
            Invalid request body (e.g. missing `types`, empty array, or `end`
            before `start`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                validation:
                  summary: Missing or invalid fields
                  value:
                    success: false
                    message: Invalid request body
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '502':
          description: Failed to load widget data.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                message: Failed to load widget data
components:
  parameters:
    applicationId:
      name: applicationId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: >-
        Unique identifier (UUID) of the application. Returned by `POST
        /applications`.
  schemas:
    WidgetDataRequest:
      type: object
      additionalProperties: false
      required:
        - types
        - start
        - end
      properties:
        types:
          type: array
          minItems: 1
          items:
            type: string
            minLength: 1
          description: >-
            Board widget type slugs from `GET /widgets` `data[].id`. Results are
            returned in the same order.
          example:
            - sessions-evaluated
            - guardrail-latency
        start:
          type: string
          format: date-time
          description: Start of the time range, inclusive (ISO 8601 UTC).
          example: '2026-01-01T00:00:00.000Z'
        end:
          type: string
          format: date-time
          description: >-
            End of the time range, inclusive (ISO 8601 UTC). Must be on or after
            `start`.
          example: '2026-01-31T23:59:59.000Z'
    WidgetDataResponse:
      type: object
      properties:
        success:
          type: boolean
        data:
          type: array
          items:
            $ref: '#/components/schemas/WidgetDataResultItem'
      required:
        - success
        - data
    ErrorResponse:
      type: object
      description: Standard error envelope for non-validation failures.
      properties:
        success:
          type: boolean
          example: false
          description: Always `false` for errors.
        message:
          type: string
          description: Human-readable explanation of the error.
      required:
        - success
        - message
    WidgetDataResultItem:
      type: object
      required:
        - id
      properties:
        id:
          type: string
          description: Requested widget slug from `types`.
        data:
          nullable: true
          description: >-
            Chart payload when the widget loaded successfully; `null` when it
            failed. Shape depends on the widget type — see `POST
            .../widget-data` response examples. Monitoring widgets typically
            return totals and time-bucketed series; guardrail widgets return
            latency, request counts, and failure summaries.
        meta:
          type: object
          description: Routing metadata when the widget loaded successfully.
          properties:
            source:
              type: string
              enum:
                - pulse
                - pulse-security
                - observe
                - functional
                - security
                - guardrails
                - rag
              description: >-
                Category label returned with chart data. See response examples
                for values and meanings.
            type:
              type: string
              description: Resolved widget type for this result.
          required:
            - source
            - type
        message:
          type: string
          description: Error message when this widget could not be loaded.
        code:
          type: string
          enum:
            - unknown_type
            - unsupported
            - upstream
          description: Error category when this widget could not be loaded.
  responses:
    Unauthorized:
      description: >-
        The API key is missing, invalid, or revoked. Verify the `x-api-key`
        header and that the key is active in Trusys settings.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            message: Error while verifying api key
    NotFound:
      description: The requested resource does not exist, or your API key cannot access it.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            success: false
            message: Application not found
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        Your Trusys API key. Create and manage keys in the Trusys UI under
        **Settings → API Keys**.


        Include the key on every request:


        ```

        x-api-key: <your-api-key>

        ```

````