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

# Update a span

> Partially update a span's mutable fields and return the updated span.

Only the provided fields among name, end timestamp, output, metadata, and
status are changed. This endpoint is available only for accounts still served
solely by the legacy trace store: once an account begins dual-writing to the
tracing service — which is upsert-only and has no partial-update operation —
PATCH returns 501 and PUT /v5/spans/batch must be used instead. Updates are
authorized against the span's parent trace, and an unknown id returns 404.


Credential redaction: values in the free-form ``input``, ``output``, ``metadata``,
and ``expected`` objects, and in ``name``, that are credential-shaped (bearer/JWT,
API keys, connection-string passwords) or under a credential-named key are replaced
with ``[REDACTED:credential]`` before the span is persisted, so the stored and
returned span reflects the redacted value.



## OpenAPI

````yaml /openapi/v5.yaml patch /v5/spans/{span_id}
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/{span_id}:
    patch:
      tags:
        - Spans
      summary: Update a span
      description: >-
        Partially update a span's mutable fields and return the updated span.


        Only the provided fields among name, end timestamp, output, metadata,
        and

        status are changed. This endpoint is available only for accounts still
        served

        solely by the legacy trace store: once an account begins dual-writing to
        the

        tracing service — which is upsert-only and has no partial-update
        operation —

        PATCH returns 501 and PUT /v5/spans/batch must be used instead. Updates
        are

        authorized against the span's parent trace, and an unknown id returns
        404.



        Credential redaction: values in the free-form ``input``, ``output``,
        ``metadata``,

        and ``expected`` objects, and in ``name``, that are credential-shaped
        (bearer/JWT,

        API keys, connection-string passwords) or under a credential-named key
        are replaced

        with ``[REDACTED:credential]`` before the span is persisted, so the
        stored and

        returned span reflects the redacted value.
      operationId: PATCH-V5-/v5/spans/span_id
      parameters:
        - name: span_id
          in: path
          required: true
          schema:
            type: string
            title: Span Id
        - 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/SpanUpdateRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Span'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    SpanUpdateRequest:
      properties:
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
        end_timestamp:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: End Timestamp
        output:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Output
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
        status:
          anyOf:
            - $ref: '#/components/schemas/ApplicationOperationStatus'
            - type: 'null'
          default: SUCCESS
      type: object
      title: SpanUpdateRequest
    Span:
      properties:
        id:
          type: string
          title: Id
        object:
          type: string
          const: span
          title: Object
          default: span
        created_by:
          anyOf:
            - $ref: '#/components/schemas/Identity'
            - type: 'null'
          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:
          anyOf:
            - type: string
            - type: 'null'
          title: Parent Id
          description: Reference to a parent span_id
        group_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Group Id
          description: Reference to a group_id
        start_timestamp:
          type: string
          format: date-time
          title: Start Timestamp
        end_timestamp:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: End Timestamp
        input:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Input
        output:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Output
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
        expected:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Expected
        status:
          anyOf:
            - $ref: '#/components/schemas/ApplicationOperationStatus'
            - type: 'null'
          default: SUCCESS
        type:
          anyOf:
            - $ref: '#/components/schemas/ApplicationOperationType'
            - type: 'null'
          default: STANDALONE
        application_interaction_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Application Interaction Id
          description: The interaction ID this span belongs to
        application_variant_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Application Variant Id
          description: The id of the application variant this span belongs to
        obs_trace_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Obs Trace Id
          description: >-
            W3C trace id of the observability trace this span executed in. Null
            for spans written without the edge, and for accounts still served by
            the legacy trace store.
        obs_span_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Obs Span Id
          description: W3C span id of the observability span this span executed in.
        input_tokens:
          anyOf:
            - type: integer
              maximum: 4294967295
              minimum: 0
            - type: 'null'
          title: Input Tokens
          description: >-
            Prompt tokens the producer reported for this span, absent when it
            reported none. Same quantity the input_tokens sort orders by.
        output_tokens:
          anyOf:
            - type: integer
              maximum: 4294967295
              minimum: 0
            - type: 'null'
          title: Output Tokens
          description: >-
            Completion tokens the producer reported for this span, absent when
            it reported none. Same quantity the output_tokens sort orders by.
        account_id:
          type: string
          title: Account Id
      type: object
      required:
        - id
        - name
        - trace_id
        - start_timestamp
        - account_id
    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
    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
    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
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
          additionalProperties: true
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    IdentityType:
      type: string
      enum:
        - user
        - service_account
      title: IdentityType
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: x-api-key

````