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

# List incident metadata distributions

For how to investigate error incidents with this endpoint, see [Querying traces](https://docs.appsignal.com/api/v2/traces.md#investigate-error-incidents).

```yaml POST /api/v2/tracing/metadata_distributions theme={null}
openapi: 3.1.0
info:
  title: AppSignal V2 API
  description: >-
    REST API for metrics, traces, logs, Kubernetes monitoring, and deployment
    tracking.
  license:
    name: ''
  version: 0.1.0
paths:
  /api/v2/tracing/metadata_distributions:
    post:
      tags:
        - Tracing
      summary: List incident metadata distributions
      operationId: metadata_distributions
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MetadataDistributionsQuery'
            example:
              site_id: abc123
              incident_digests:
                - '1023993'
              from: '2024-01-01T00:00:00Z'
              group_by: VALUE
              metadata_key: hostname
        required: true
      responses:
        '200':
          description: 'A bare array: key rows in KEY mode, value rows in VALUE mode.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MetadataDistributions'
              example:
                - key: frontend1
                  value: 42
        '400':
          description: >-
            `incident_digests` is empty, or `group_by` is `VALUE` without a
            `metadata_key`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequestResponse'
        '401':
          description: Missing or invalid authentication token.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Route or resource not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: External query concurrency limit exceeded; retry shortly.
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before retrying.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TooManyRequestsResponse'
        '500':
          description: Unhandled server-side failure.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearer_auth: []
        - token_query: []
components:
  schemas:
    BadRequestResponse:
      type: object
      description: >-
        Standard body for HTTP 400 Bad Request responses. Branch on the stable
        `error` slug, display `message` as-is, and read per-error structured
        data from `details`.
      required:
        - error
        - message
      properties:
        error:
          type: string
          description: Stable, machine-readable slug identifying the specific error case.
        message:
          type: string
          description: Human-readable message. Safe to log or display to end users.
        details:
          description: >-
            Per-error structured payload. Shape varies by
            [`error`](Self::error).
    ErrorResponse:
      type: object
      description: Error body returned for 401, 404 and 500 responses.
      required:
        - error
      properties:
        error:
          type: string
          description: Human-readable error message.
    MetadataDistributions:
      anyOf:
        - type: array
          items:
            $ref: '#/components/schemas/MetadataKeyDistribution'
        - type: array
          items:
            $ref: '#/components/schemas/MetadataValueDistribution'
      description: A bare JSON array of key rows or value rows.
    MetadataDistributionsQuery:
      type: object
      description: Query for the metadata distribution list.
      required:
        - site_id
        - incident_digests
        - from
        - group_by
      properties:
        site_id:
          type: string
          description: Site to fetch metadata for.
        incident_digests:
          type: array
          items:
            type: string
          description: Incident digests to include.
        from:
          type: string
          format: date-time
          description: Start of the time range (inclusive).
        to:
          type:
            - string
            - 'null'
          format: date-time
          description: End of the time range (inclusive). Defaults to now.
        group_by:
          $ref: '#/components/schemas/MetadataGroupBy'
          description: Which dimension to group by (`KEY` or `VALUE`).
        metadata_key:
          type:
            - string
            - 'null'
          description: |-
            The metadata key to filter values by. Required when `group_by` is
            `VALUE`; ignored in `KEY` mode.
        limit:
          type:
            - integer
            - 'null'
          format: int32
          description: >-
            Maximum rows to return, clamped to 1–1000. Defaults to 10 in `VALUE`
            mode;

            in `KEY` mode absent means no limit.
    MetadataGroupBy:
      type: string
      description: Which dimension the metadata distribution query groups by.
      enum:
        - KEY
        - VALUE
    MetadataKeyDistribution:
      type: object
      description: A single metadata key row (KEY mode).
      required:
        - key
        - total
        - unique
      properties:
        key:
          type:
            - string
            - 'null'
          description: The metadata key (e.g. `hostname`).
        total:
          type:
            - integer
            - 'null'
          format: int64
          description: Total occurrences across all values.
        unique:
          type:
            - integer
            - 'null'
          format: int64
          description: Number of distinct values.
    MetadataValueDistribution:
      type: object
      description: A single metadata value row (VALUE mode).
      required:
        - key
        - value
      properties:
        key:
          type:
            - string
            - 'null'
          description: The metadata value (e.g. `frontend1`), under the field name `key`.
        value:
          type:
            - integer
            - 'null'
          format: int64
          description: Occurrences of this value.
    TooManyRequestsResponse:
      type: object
      description: Error body returned for 429 responses.
      required:
        - error
      properties:
        error:
          type: string
          description: Human-readable error message.
        suggestion:
          type:
            - string
            - 'null'
          description: >-
            A cheaper way to write the request's filter. Only the trace list

            endpoints set it, and only for a filter with a known indexed
            rewrite.
  securitySchemes:
    bearer_auth:
      type: http
      scheme: bearer
      description: '`Authorization: Bearer <token>`'
    token_query:
      type: apiKey
      in: query
      name: token
      description: >-
        Alternative to the Authorization header: pass the token as a
        `?token=<token>` query parameter.
```


## API Specification

The full API specification for this endpoint is available in the [documentation index](https://docs.appsignal.com/llms.txt).


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