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

# Close Trace

> Marks a trace as closed, preventing any further span ingestion for that trace. Once closed, subsequent calls to `/spans-bulk` or `/v1/traces` that include spans for this trace will have those spans rejected.

Marks a trace as closed, preventing any further spans from being written to it. Once closed, subsequent calls to [Create Spans Bulk](/reference/spans-bulk) or [Ingest Traces (OTLP)](/reference/otlp-ingest-traces) that include spans for this trace will have those spans rejected.

## Behavior Notes

* Closing is permanent — there is no re-open operation.
* If the trace is already closed, the endpoint returns `409 Conflict`.
* If no spans exist for the given `trace_id` in your workspace, the endpoint returns `404 Not Found`.

## Related

* [Get Trace](/reference/get-trace)
* [Create Spans Bulk](/reference/spans-bulk)
* [Ingest Traces (OTLP)](/reference/otlp-ingest-traces)
* [Traces](/running-requests/traces)


## OpenAPI

````yaml POST /api/public/v2/traces/{trace_id}/close
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers: []
security:
  - ApiKeyAuth: []
paths:
  /api/public/v2/traces/{trace_id}/close:
    post:
      tags:
        - tracking
      summary: Close Trace
      description: >-
        Marks a trace as closed, preventing any further span ingestion for that
        trace. Once closed, subsequent calls to `/spans-bulk` or `/v1/traces`
        that include spans for this trace will have those spans rejected.
      operationId: closeTrace
      parameters:
        - name: trace_id
          in: path
          required: true
          schema:
            type: string
          description: The trace ID to close.
          example: a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6
      responses:
        '201':
          description: Trace successfully closed.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  closure:
                    type: object
                    properties:
                      id:
                        type: string
                        format: uuid
                      workspace_id:
                        type: integer
                      trace_id:
                        type: string
                      status:
                        type: string
                        enum:
                          - closed
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
              examples:
                closed:
                  summary: Trace closed
                  value:
                    success: true
                    closure:
                      id: 550e8400-e29b-41d4-a716-446655440000
                      workspace_id: 1
                      trace_id: a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6
                      status: closed
                      created_at: '2026-06-06T18:00:00Z'
                      updated_at: '2026-06-06T18:00:00Z'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '409':
          description: Trace is already closed.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  message:
                    type: string
                    example: Trace already closed
        '422':
          $ref: '#/components/responses/ValidationError'
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  responses:
    UnauthorizedError:
      description: Unauthorized - missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFoundError:
      description: Not found - requested resource does not exist or is not accessible.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ValidationError:
      description: Validation error - request parameters or body are invalid.
      content:
        application/json:
          schema:
            oneOf:
              - $ref: '#/components/schemas/HTTPValidationError'
              - $ref: '#/components/schemas/ErrorResponse'
  schemas:
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          default: false
          description: Indicates that the request failed.
        message:
          type: string
          description: Human-readable error message.
        error:
          type: string
          description: Machine-readable or fallback error message.
      additionalProperties: true
      description: >-
        Standard error response. Some legacy endpoints may return either message
        or error.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY

````