> ## 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 slow events

For how to request attributes with `wanted_attributes`, see [Querying traces](https://docs.appsignal.com/api/v2/traces.md#slow-events).

```yaml POST /api/v2/tracing/slow_events 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/slow_events:
    post:
      tags:
        - Tracing
      summary: List slow events
      operationId: slow_events
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SlowEventsParams'
            example:
              site_id: abc123
              from: '2024-01-01T00:00:00Z'
              to: '2024-01-01T01:00:00Z'
              wanted_attributes:
                payload:
                  Required:
                    - db.query.text
                    - db.statement
                system:
                  Optional:
                    - db.system.name
        required: true
      responses:
        '200':
          description: The slow events, with the requested attributes.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/SlowEventItem'
              example:
                - digest: '1234567890'
                  count: 42
                  mean: 125.5
                  impact: 5271
                  payload: SELECT * FROM users WHERE id = ?
                  system: postgresql
        '400':
          description: >-
            `wanted_attributes` is empty, has no `Required` entry, or has an
            empty key list; or an attribute category or key is invalid.
          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:
    AttributeRequirement:
      oneOf:
        - type: object
          description: >-
            Filters spans to those with at least one of these keys set to a
            non-empty value; the value is returned.
          required:
            - Required
          properties:
            Required:
              type: array
              items:
                type: string
              description: >-
                Filters spans to those with at least one of these keys set to a
                non-empty value; the value is returned.
        - type: object
          description: >-
            Always returned (empty when none of the keys is set); does not
            filter spans.
          required:
            - Optional
          properties:
            Optional:
              type: array
              items:
                type: string
              description: >-
                Always returned (empty when none of the keys is set); does not
                filter spans.
      description: >-
        Whether a group of attribute keys filters the slow events or is only
        returned.
    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.
    SlowEventItem:
      type: object
      description: A slow event aggregation (e.g. a slow database query).
      required:
        - digest
        - count
        - mean
        - impact
      properties:
        digest:
          type: string
          description: Hash digest identifying the slow event's operation.
        count:
          type: integer
          format: u-int64
          description: Number of times this slow event occurred in the time range.
          minimum: 0
        mean:
          type: number
          format: double
          description: Mean duration of this slow event in milliseconds.
        impact:
          type: number
          format: double
          description: Relative impact score (higher means more total time spent).
      additionalProperties:
        type: string
        description: Additional attributes for the slow event (e.g. query body, category).
    SlowEventsParams:
      type: object
      description: Filters for listing slow events such as slow database queries.
      required:
        - site_id
        - from
        - to
        - wanted_attributes
      properties:
        site_id:
          type: string
          description: Site to query.
        from:
          type: string
          format: date-time
          description: Start of the time range; clamped to the account's data retention.
        to:
          type: string
          format: date-time
          description: End of the time range; clamped to now.
        span_kind:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/SpanKind'
              description: Only return spans of this kind.
        wanted_attributes:
          type: object
          description: >-
            Attributes to return, keyed by category (e.g. `payload`, `system`).
            The key `appsignal.library`

            returns what follows `appsignal/` in the span's scope (e.g.
            `active_record`), empty for other scopes.
          additionalProperties:
            $ref: '#/components/schemas/AttributeRequirement'
          propertyNames:
            type: string
        excluded_attributes:
          type: array
          items:
            type: string
          description: >-
            Attribute keys to exclude; a span is excluded if any listed key is
            present.
    SpanKind:
      type: string
      description: >-
        The OpenTelemetry kind of a span, as a PascalCase string.


        `Client` and `Server` are synchronous calls; `Producer` and `Consumer`
        are async jobs.
      enum:
        - Client
        - Server
        - Internal
        - Producer
        - Consumer
    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.