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

# Add Request Log to Dataset

Add a request log as a row in the draft dataset version for a dataset group. PromptLayer extracts request inputs, metadata, scores, tags, prompt data, and response data into dataset columns.

## Behavior Notes

* A draft dataset version must already exist for the dataset group.
* The request log and dataset group must belong to the same workspace.
* New columns are automatically added from the request log's available data fields.
* If no draft exists, the endpoint returns `404`.

## Related

* [Create Draft Dataset Version](/reference/create-draft-dataset-version)
* [Save Draft Dataset Version](/reference/save-draft-dataset-version)
* [Get Request](/reference/get-request)


## OpenAPI

````yaml POST /api/public/v2/dataset-versions/add-request-log
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers: []
security:
  - ApiKeyAuth: []
paths:
  /api/public/v2/dataset-versions/add-request-log:
    post:
      tags:
        - datasets
      summary: Add Request Log to Draft Dataset
      operationId: addRequestLogToDatasetVersion
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddRequestLogToDatasetRequest'
            examples:
              addRequestLog:
                summary: Add request log row
                value:
                  dataset_group_id: 123
                  request_log_id: 98765
      responses:
        '201':
          description: Request log added to draft dataset.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DraftDatasetVersionResponse'
              examples:
                added:
                  summary: Request log added
                  value:
                    success: true
                    message: Request log added to draft dataset
                    draft_dataset_id: 789
        '400':
          description: Request log and dataset must belong to the same workspace
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '422':
          $ref: '#/components/responses/ValidationError'
components:
  schemas:
    AddRequestLogToDatasetRequest:
      type: object
      title: AddRequestLogToDatasetRequest
      required:
        - dataset_group_id
        - request_log_id
      properties:
        dataset_group_id:
          type: integer
          minimum: 1
          description: ID of the dataset group containing the draft.
        request_log_id:
          type: integer
          minimum: 1
          description: ID of the request log to add as a dataset row.
    DraftDatasetVersionResponse:
      type: object
      title: DraftDatasetVersionResponse
      required:
        - success
        - message
        - draft_dataset_id
      properties:
        success:
          type: boolean
          enum:
            - true
        message:
          type: string
        draft_dataset_id:
          type: integer
          description: ID of the draft dataset.
    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
  responses:
    UnauthorizedError:
      description: Unauthorized - missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ForbiddenError:
      description: Forbidden - API key does not have access to the requested resource.
      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'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY

````