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

# Add Trace to Dataset

> Add a trace to a dataset, enabling continuous fine-tuning with fresh, real-world data. If the trace score is above a threshold, a positive datapoint is added; if too low, a new positive datapoint is generated based on user feedback.



## OpenAPI

````yaml POST /api/v1/traces/{id}/addToDataset
openapi: 3.1.0
info:
  version: 0.0.1
  title: Prem Studio API
  description: Studio autofinetuning agent API
servers:
  - url: http://studio.premai.io
    description: Current environment
  - url: https://studio.premai.io
    description: Production server
security:
  - bearerAuth: []
paths:
  /api/v1/traces/{id}/addToDataset:
    post:
      tags:
        - Traces
      description: >-
        Add a trace to its linked project dataset as a datapoint or queue an
        improvement task
      operationId: traces.addToDataset
      parameters:
        - schema:
            type: string
            format: uuid
          required: true
          name: id
          in: path
      responses:
        '200':
          description: success response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TracePromotionResponse'
        '400':
          description: bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: conflict
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    TracePromotionResponse:
      type: object
      properties:
        traceId:
          type: string
          format: uuid
          description: Trace identifier that was processed.
        status:
          type: string
          enum:
            - added
            - queued
            - failed
          description: >-
            added when the datapoint is stored immediately, queued when
            generation is in progress, failed when the operation could not
            start.
        success:
          type: boolean
          description: true when the action succeeded, false when it failed.
        datapointId:
          type: string
          nullable: true
          format: uuid
          description: Identifier of the created datapoint when available.
      required:
        - traceId
        - status
        - success
        - datapointId
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
      required:
        - error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````