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

# Search Spans

> Returns a cursor-paginated page of filtered span rows. When `promptId` is provided in the request body, results are scoped to spans that were ingested with that `promptId` — regardless of content type. In practice this is most often `Model` / `ModelStream` spans, but any span type the caller attached to the prompt (for example, a `Tool` span emitted during that prompt's execution) is returned. When `promptId` is omitted, spans of every content type (Model, Tool, Function, Guardrail, Retrieval, Embeddings, Other, or caller-defined custom types) across the project are returned. Pass `nextCursor` from the response as `cursor` to fetch the next page.

Returns a cursor-paginated page of filtered model span rows for a prompt. Pass `nextCursor` from the response as `cursor` to fetch the next page.

See [Export Logs](/monitor/filter-and-search-logs) for filter types, available columns, and pagination conventions.


## OpenAPI

````yaml POST /logs/spans
openapi: 3.1.1
info:
  title: Adaline API
  version: 2.0.0
  description: >-
    Public API for managing Adaline projects, prompts, datasets, evaluators,
    evaluations, providers, models, and deployments.


    Generated from Zod schemas — this spec is the single source of truth.
servers:
  - url: https://api.adaline.ai/v2
    description: Production API
security: []
tags:
  - name: datasets
    description: Manage prompt datasets and their columns and rows.
  - name: projects
    description: List and manage Adaline projects.
  - name: providers
    description: List configured LLM providers and their settings.
  - name: models
    description: List available models across providers.
  - name: prompts
    description: Create and manage prompts and their drafts.
  - name: evaluators
    description: Configure evaluators attached to a prompt.
  - name: evaluations
    description: Run and inspect evaluation results.
  - name: deployments
    description: Retrieve deployed prompt snapshots.
  - name: logs
    description: Ingest execution traces and spans for observability.
paths:
  /logs/spans:
    post:
      tags:
        - logs
      summary: Search spans
      description: >-
        Returns a cursor-paginated page of filtered span rows. When `promptId`
        is provided in the request body, results are scoped to spans that were
        ingested with that `promptId` — regardless of content type. In practice
        this is most often `Model` / `ModelStream` spans, but any span type the
        caller attached to the prompt (for example, a `Tool` span emitted during
        that prompt's execution) is returned. When `promptId` is omitted, spans
        of every content type (Model, Tool, Function, Guardrail, Retrieval,
        Embeddings, Other, or caller-defined custom types) across the project
        are returned. Pass `nextCursor` from the response as `cursor` to fetch
        the next page.
      operationId: searchLogSpans
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SearchLogSpansRequest'
      responses:
        '200':
          description: A page of search results with cursor-based pagination metadata.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchSpansResponse'
          headers:
            X-Request-Id:
              description: >-
                Unique identifier for the request. Returned in every response.
                Send a custom value to correlate requests, or omit to receive a
                generated UUID.
              schema:
                type: string
                format: uuid
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized — invalid or missing API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden — invalid or unauthorized API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Not found — project or prompt not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    SearchLogSpansRequest:
      title: Search Log Spans Request
      type: object
      description: >-
        Request payload for paginated span search. `promptId` is optional; when
        omitted the response includes spans of every content type across the
        project.
      required:
        - projectId
      properties:
        projectId:
          $ref: '#/components/schemas/BaseEntityId'
          description: The project to search spans in.
        promptId:
          $ref: '#/components/schemas/BaseEntityId'
          description: >-
            Optional. When provided, scopes results to this prompt. Omit to
            return spans of every content type (Model, Tool, Function,
            Guardrail, Retrieval, Embeddings, Other, or custom) across all
            prompts in the project.
        model:
          type: string
          description: Case-insensitive substring match on the model name.
        provider:
          type: string
          description: Case-insensitive substring match on the provider name.
        startedAfter:
          type: integer
          description: >-
            Unix timestamp in milliseconds. Only return rows started at or after
            this time.
        startedBefore:
          type: integer
          description: >-
            Unix timestamp in milliseconds. Only return rows started at or
            before this time.
        status:
          type: string
          enum:
            - success
            - failure
            - aborted
            - cancelled
            - pending
            - unknown
          description: Filter by status.
        name:
          type: string
          description: Case-insensitive substring match on the trace or span name.
        referenceId:
          type: string
          description: Exact match on the reference ID.
        sessionId:
          type: string
          description: Exact match on the session ID.
        filters:
          type: array
          maxItems: 20
          items:
            $ref: '#/components/schemas/LogFilterObject'
          description: Typed filter objects for advanced queries. ANDed with flat params.
        sort:
          type: string
          enum:
            - startedAt:asc
            - startedAt:desc
          description: Sort order. Defaults to startedAt:desc.
        limit:
          type: integer
          minimum: 1
          maximum: 200
          description: Page size. Defaults to 50, max 200.
        cursor:
          type: string
          description: Opaque pagination cursor from a previous response.
    SearchSpansResponse:
      type: object
      properties:
        pagination:
          $ref: '#/components/schemas/Pagination'
        spans:
          type: array
          items:
            $ref: '#/components/schemas/LogSpanItem'
          description: Array of log span items.
      required:
        - pagination
        - spans
      title: Search Spans Response
      description: Paginated search results for log spans.
    ErrorResponse:
      title: Error Response
      type: object
      description: >-
        Standard error response envelope. Permits backend-specific sibling
        fields (e.g. Zod issue details) alongside the typed `error`.
      properties:
        error:
          description: >-
            Error details — typed envelope, or a raw string reason when the
            backend's validator produces a short summary (e.g. Zod validation
            fallback).
          oneOf:
            - type: string
            - type: object
              properties:
                code:
                  type: string
                  description: Machine-readable error code.
                  enum:
                    - VALIDATION_ERROR
                    - INVALID_CURSOR
                    - AUTHENTICATION_REQUIRED
                    - FORBIDDEN
                    - RESOURCE_NOT_FOUND
                    - CONFLICT
                    - PAYLOAD_TOO_LARGE
                    - RATE_LIMITED
                    - INTERNAL_ERROR
                message:
                  type: string
                  description: Human-readable error message.
                details:
                  type: array
                  description: Optional field-level validation details.
                  items:
                    type: object
                    properties:
                      field:
                        type: string
                      issue:
                        type: string
                    required:
                      - field
                      - issue
              required:
                - code
                - message
              additionalProperties: true
      required:
        - error
      additionalProperties: true
    BaseEntityId:
      title: Base Entity ID
      type: string
      description: Unique identifier for an entity, between 20 and 80 characters.
      minLength: 20
      maxLength: 80
    LogFilterObject:
      title: Log Filter Object
      type: object
      description: >-
        Typed filter object. Discriminated union on `type`: string, number,
        datetime, or arrayContains.
      required:
        - type
        - column
        - operator
        - value
      properties:
        type:
          type: string
          enum:
            - string
            - number
            - datetime
            - arrayContains
          description: Filter type. Determines valid operators and value types.
        column:
          type: string
          description: Column to filter on. Unknown columns are silently ignored.
        operator:
          type: string
          description: >-
            Comparison operator. Valid values depend on type: string (eq,
            contains), number (eq, gt, gte, lt, lte), datetime (gt, gte, lt,
            lte), arrayContains (contains).
        value:
          description: >-
            Filter value. String for string/arrayContains types, number for
            number/datetime types.
    Pagination:
      title: Pagination
      type: object
      description: Pagination metadata for list endpoints with cursor-based navigation.
      properties:
        limit:
          type: integer
          exclusiveMinimum: 0
        returned:
          type: integer
          minimum: 0
        hasMore:
          type: boolean
        nextCursor:
          type:
            - string
            - 'null'
      required:
        - limit
        - returned
        - hasMore
        - nextCursor
    LogSpanItem:
      title: Log Span Item
      type: object
      description: A log span summary returned in search responses.
      properties:
        id:
          type: string
          description: Unique span identifier.
        name:
          type: string
          description: Name of the span.
        contentType:
          type: string
          description: >-
            Content type of the span. One of Model, ModelStream, Tool, Function,
            Guardrail, Retrieval, Embeddings, Other, or a caller-defined custom
            string.
        status:
          type: string
          description: Span status.
          enum:
            - success
            - failure
            - aborted
            - cancelled
            - unknown
        startedAt:
          $ref: '#/components/schemas/UnixTimestamp'
          description: When the span started.
        endedAt:
          $ref: '#/components/schemas/UnixTimestamp'
          description: When the span ended.
        latency:
          type: number
          description: Span duration in milliseconds.
        logTraceId:
          type: string
          description: ID of the parent trace.
        promptId:
          type:
            - string
            - 'null'
          description: >-
            ID of the associated prompt. Null for non-Model span types (Tool,
            Function, Guardrail, Retrieval, Embeddings, Other, or custom) that
            are not tied to a prompt execution.
        referenceId:
          type:
            - string
            - 'null'
          description: External reference ID.
        parentReferenceId:
          type:
            - string
            - 'null'
          description: Reference ID of the parent span.
        sessionId:
          type:
            - string
            - 'null'
          description: Session ID for grouping related spans.
        cost:
          type:
            - number
            - 'null'
          description: Cost of this span.
        promptTokens:
          type:
            - number
            - 'null'
          description: Input token count.
        completionTokens:
          type:
            - number
            - 'null'
          description: Output token count.
        totalTokens:
          type:
            - number
            - 'null'
          description: Total token count.
        content:
          type: string
          description: JSON-stringified span content.
        parsedContent:
          type: string
          description: JSON-stringified parsed content.
        attributes:
          type: string
          description: JSON-stringified attributes.
        tags:
          type: string
          description: JSON-stringified tags.
        events:
          type: string
          description: JSON-stringified events.
        createdAt:
          $ref: '#/components/schemas/UnixTimestamp'
          description: When the span was created.
        updatedAt:
          $ref: '#/components/schemas/UnixTimestamp'
          description: When the span was last updated.
      required:
        - id
        - name
        - contentType
        - status
        - startedAt
        - endedAt
        - latency
        - logTraceId
        - promptId
        - referenceId
        - parentReferenceId
        - sessionId
        - cost
        - promptTokens
        - completionTokens
        - totalTokens
        - content
        - parsedContent
        - attributes
        - tags
        - events
        - createdAt
        - updatedAt
    UnixTimestamp:
      title: Unix Timestamp
      type: integer
      format: int64
      description: Unix timestamp in milliseconds.
      minimum: 1672511400000
      maximum: 33229420200000
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: 'Workspace API key. Pass as `Authorization: Bearer <key>`.'

````