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

# Start a new prompt optimization job.

> 
Creates an asynchronous job that optimizes the specified prompt template version.
The job will analyze examples from the dataset and generate an improved prompt.

When `run_test_after_optimization` is True (default), the job will also run
baseline and optimized test runs and create a comparison.

Poll GET /prompt-optimization-jobs/{job_id} to check job status.



## OpenAPI

````yaml https://app.freeplay.ai/openapi.json post /api/v2/projects/{project_id}/prompt-optimization-jobs
openapi: 3.1.0
info:
  title: Freeplay API
  version: 0.1.0
servers: []
security:
  - BearerAuth: []
paths:
  /api/v2/projects/{project_id}/prompt-optimization-jobs:
    post:
      tags:
        - Prompt Optimization
      summary: Start a new prompt optimization job.
      description: >-

        Creates an asynchronous job that optimizes the specified prompt template
        version.

        The job will analyze examples from the dataset and generate an improved
        prompt.


        When `run_test_after_optimization` is True (default), the job will also
        run

        baseline and optimized test runs and create a comparison.


        Poll GET /prompt-optimization-jobs/{job_id} to check job status.
      operationId: post_start_prompt_optimization_job
      parameters:
        - name: project_id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              properties:
                prompt_template_version_id:
                  format: uuid
                  title: Prompt Template Version Id
                  type: string
                dataset_id:
                  format: uuid
                  title: Dataset Id
                  type: string
                user_instructions:
                  default: null
                  title: User Instructions
                  type:
                    - string
                    - 'null'
                use_best_practices:
                  default: true
                  title: Use Best Practices
                  type: boolean
                use_labels:
                  default: true
                  title: Use Labels
                  type: boolean
                use_customer_feedback:
                  default: true
                  title: Use Customer Feedback
                  type: boolean
                run_test_after_optimization:
                  default: true
                  title: Run Test After Optimization
                  type: boolean
              required:
                - prompt_template_version_id
                - dataset_id
              title: StartPromptOptimizationJobRequest
              type: object
      responses:
        '202':
          content:
            application/json:
              schema:
                properties:
                  job_id:
                    format: uuid
                    title: Job Id
                    type: string
                  status:
                    title: Status
                    type: string
                  created_at:
                    format: date-time
                    title: Created At
                    type: string
                required:
                  - job_id
                  - status
                  - created_at
                title: PromptOptimizationJobCreatedResponse
                type: object
          description: >-
            PromptOptimizationJobCreatedResponse(job_id: uuid.UUID, status: str,
            created_at: datetime.datetime)
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````