> ## 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.

# Upsert Spans in Batch



## OpenAPI

````yaml https://api.dev-sgp.scale.com/openapi-versions/v5/openapi.json put /v5/spans/batch
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/batch:
    put:
      tags:
        - Spans
      summary: Upsert Spans in Batch
      operationId: PUT-V5-/v5/spans/batch
      parameters:
        - 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/SpanBatchCreateRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIList_Span_'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    SpanBatchCreateRequest:
      properties:
        items:
          items:
            $ref: '#/components/schemas/SpanCreateRequest'
          type: array
          title: Items
      type: object
      required:
        - items
      title: SpanBatchCreateRequest
    APIList_Span_:
      properties:
        object:
          type: string
          const: list
          title: Object
          default: list
        items:
          items:
            $ref: '#/components/schemas/Span'
          type: array
          title: Items
      type: object
      required:
        - items
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    SpanCreateRequest:
      properties:
        id:
          title: Id
          description: The id of the span
          type: string
        name:
          type: string
          title: Name
        trace_id:
          type: string
          maxLength: 256
          title: Trace Id
          description: id for grouping traces together, uuid is recommended
        parent_id:
          title: Parent Id
          description: Reference to a parent span_id
          type: string
        group_id:
          title: Group Id
          description: Reference to a group_id
          type: string
        start_timestamp:
          type: string
          format: date-time
          title: Start Timestamp
        end_timestamp:
          title: End Timestamp
          type: string
          format: date-time
        input:
          title: Input
          additionalProperties: true
          type: object
        output:
          title: Output
          additionalProperties: true
          type: object
        metadata:
          additionalProperties: true
          type: object
          title: Metadata
        status:
          $ref: '#/components/schemas/ApplicationOperationStatus'
          default: SUCCESS
        type:
          $ref: '#/components/schemas/ApplicationOperationType'
          default: STANDALONE
        application_interaction_id:
          title: Application Interaction Id
          description: The optional application interaction ID this span belongs to
          type: string
        application_variant_id:
          title: Application Variant Id
          description: The optional application variant ID this span belongs to
          type: string
        expected:
          title: Expected
          additionalProperties: true
          type: object
      type: object
      required:
        - name
        - trace_id
        - start_timestamp
      title: SpanCreateRequest
    Span:
      properties:
        id:
          type: string
          title: Id
        object:
          type: string
          const: span
          title: Object
          default: span
        created_by:
          $ref: '#/components/schemas/Identity'
          description: The identity that created the entity.
        name:
          type: string
          title: Name
        trace_id:
          type: string
          maxLength: 256
          title: Trace Id
          description: id for grouping traces together, uuid is recommended
        parent_id:
          title: Parent Id
          description: Reference to a parent span_id
          type: string
        group_id:
          title: Group Id
          description: Reference to a group_id
          type: string
        start_timestamp:
          type: string
          format: date-time
          title: Start Timestamp
        end_timestamp:
          title: End Timestamp
          type: string
          format: date-time
        input:
          title: Input
          additionalProperties: true
          type: object
        output:
          title: Output
          additionalProperties: true
          type: object
        metadata:
          additionalProperties: true
          type: object
          title: Metadata
        expected:
          title: Expected
          additionalProperties: true
          type: object
        status:
          $ref: '#/components/schemas/ApplicationOperationStatus'
          default: SUCCESS
        type:
          $ref: '#/components/schemas/ApplicationOperationType'
          default: STANDALONE
        application_interaction_id:
          title: Application Interaction Id
          description: The interaction ID this span belongs to
          type: string
        application_variant_id:
          title: Application Variant Id
          description: The id of the application variant this span belongs to
          type: string
        account_id:
          type: string
          title: Account Id
      type: object
      required:
        - id
        - name
        - trace_id
        - start_timestamp
        - account_id
    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
    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
    Identity:
      properties:
        id:
          type: string
          title: Id
        object:
          type: string
          const: identity
          title: Object
          default: identity
        type:
          $ref: '#/components/schemas/IdentityType'
      type: object
      required:
        - id
        - type
      title: Identity
    IdentityType:
      type: string
      enum:
        - user
        - service_account
      title: IdentityType
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: x-api-key

````