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

# Export spans



## OpenAPI

````yaml https://api.dev-sgp.scale.com/openapi-versions/v5/openapi.json post /v5/spans/export
openapi: 3.1.0
info:
  title: EGP API V5
  description: >-
    This is the parent API for all EGP APIs. If you are looking for the EGP API,
    please go to https://api.egp.scale.com/docs.
  contact:
    name: Scale Generative AI Platform
    url: https://scale.com/genai-platform
  version: 0.1.0
servers:
  - url: https://api.egp.scale.com
security: []
paths:
  /v5/spans/export:
    post:
      tags:
        - Spans
      summary: Export spans
      operationId: POST-V5-/v5/spans/export
      parameters:
        - name: from_ts
          in: query
          required: false
          schema:
            anyOf:
              - type: string
                format: date-time
              - type: 'null'
            description: The starting (oldest) timestamp in ISO format.
            title: From Ts
          description: The starting (oldest) timestamp in ISO format.
        - name: to_ts
          in: query
          required: false
          schema:
            anyOf:
              - type: string
                format: date-time
              - type: 'null'
            description: The ending (most recent) timestamp in ISO format.
            title: To Ts
          description: The ending (most recent) timestamp in ISO format.
        - name: x-selected-account-id
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Account ID Header
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SpansExportRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SpansExportResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    SpansExportRequest:
      properties:
        parents_only:
          title: Parents Only
          description: Only fetch spans that are the top-level (ie. have no parent_id)
          type: boolean
        span_ids:
          title: Span Ids
          description: Filter by span IDs
          items:
            type: string
          type: array
        trace_ids:
          title: Trace Ids
          description: Filter by trace IDs
          items:
            type: string
          type: array
        excluded_span_ids:
          title: Excluded Span Ids
          description: List of span IDs to exclude from results
          items:
            type: string
          type: array
        excluded_trace_ids:
          title: Excluded Trace Ids
          description: List of trace IDs to exclude from results
          items:
            type: string
          type: array
        group_id:
          title: Group Id
          description: Filter by group ID
          type: string
        names:
          title: Names
          description: Filter by trace/span name
          items:
            type: string
          type: array
        statuses:
          title: Statuses
          description: Filter on span status
          items:
            $ref: '#/components/schemas/ApplicationOperationStatus'
          type: array
        types:
          title: Types
          items:
            $ref: '#/components/schemas/ApplicationOperationType'
          type: array
        search_texts:
          title: Search Texts
          description: >-
            Free text search across span input and output fields. For exact
            trace ID lookup, use the `trace_ids` filter.
          items:
            type: string
          type: array
        extra_metadata:
          title: Extra Metadata
          description: Filter on custom metadata key-value pairs
          additionalProperties: true
          type: object
        application_variant_ids:
          title: Application Variant Ids
          description: Filter by application variant IDs
          items:
            type: string
          type: array
        assessment_types:
          title: Assessment Types
          description: Filter spans by traces that have assessments of these types
          items:
            type: string
          type: array
        acp_types:
          title: Acp Types
          description: Filter by ACP types
          items:
            type: string
          type: array
        agentex_agent_names:
          title: Agentex Agent Names
          description: Filter by Agentex agent names
          items:
            type: string
          type: array
        agentex_agent_ids:
          title: Agentex Agent Ids
          description: Filter by Agentex agent IDs
          items:
            type: string
          type: array
        min_duration_ms:
          title: Min Duration Ms
          description: Minimum span duration in milliseconds (inclusive)
          type: integer
        max_duration_ms:
          title: Max Duration Ms
          description: Maximum span duration in milliseconds (inclusive)
          type: integer
        export_method:
          $ref: '#/components/schemas/ExportMethod'
          description: >-
            The method for exporting spans. `signed_url` returns a pre-signed
            URL, while `direct` returns the raw content.
          default: direct
        export_format:
          $ref: '#/components/schemas/ExportFormat'
          description: >-
            The format of the exported spans. `json` returns a single JSON
            array, while `jsonl` returns one JSON object per line.
          default: json
        with_children:
          type: boolean
          title: With Children
          description: >-
            Whether to include child spans in the export. If true, all spans
            related to the trace will be included.
          default: false
        include_assessments:
          type: boolean
          title: Include Assessments
          description: >-
            If true, include span assessments inline in the export under each
            span's 'assessments' field.
          default: false
      type: object
      title: SpansExportRequest
    SpansExportResponse:
      properties:
        filename:
          type: string
          title: Filename
          description: The name of the exported file
        signed_url:
          title: Signed Url
          description: >-
            Pre-signed URL to download the file from object storage, if
            applicable
          type: string
        content:
          title: Content
          description: The raw file content as bytes, used when direct download is enabled
          type: string
          contentMediaType: application/octet-stream
      type: object
      required:
        - filename
      title: SpansExportResponse
      description: >-
        Response model for exporting spans.

        This class represents the response when users export span data.

        It contains either a signed URL to download the exported data from
        object storage,

        or the actual content bytes when direct download is used (in
        environments where object storage is not configured).
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ApplicationOperationStatus:
      type: string
      enum:
        - SUCCESS
        - ERROR
        - CANCELED
      title: ApplicationOperationStatus
    ApplicationOperationType:
      type: string
      enum:
        - TEXT_INPUT
        - TEXT_OUTPUT
        - COMPLETION_INPUT
        - COMPLETION
        - KB_RETRIEVAL
        - KB_INPUT
        - RERANKING
        - EXTERNAL_ENDPOINT
        - PROMPT_ENGINEERING
        - DOCUMENT_INPUT
        - MAP_REDUCE
        - DOCUMENT_SEARCH
        - DOCUMENT_PROMPT
        - CUSTOM
        - CODE_EXECUTION
        - DATA_MANIPULATION
        - EVALUATION
        - FILE_RETRIEVAL
        - KB_ADD_CHUNK
        - KB_MANAGEMENT
        - GUARDRAIL
        - OUTPUT_GUARDRAIL
        - TRACER
        - AGENT_TRACER
        - AGENT_WORKFLOW
        - STANDALONE
      title: ApplicationOperationType
    ExportMethod:
      type: string
      enum:
        - signed_url
        - direct
      title: ExportMethod
    ExportFormat:
      type: string
      enum:
        - json
        - jsonl
        - csv
      title: ExportFormat
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          title: Error Type
          type: string
        input:
          title: Input
        ctx:
          type: object
          title: Context
          additionalProperties: true
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: x-api-key

````