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

# Generate Script

> Uses AI to generate a structured interview script with tasks and questions tailored to the role.

Uses AI to generate a structured interview script tailored to a specific role. Returns tasks with questions and qualifying criteria.

The body takes `job_title` (required), `job_description` and `focus_areas`. The endpoint saves nothing. To use the script, create it with [Create Script](/docs/api-reference/scripts/create-script.md) (`POST /v2/scripts`) using the generated `name` and `description`. Create Script doesn't accept `tasks`, so add each generated task with `POST /v2/scripts/{scriptId}/tasks`, then attach the returned `script_id` to a job with [Update Job](/docs/api-reference/jobs/update-job.md).

The new script starts with Classet's standard tasks, which are already numbered from 1. When you add a generated task, leave out its `order` so it appends, and skip generated greeting or wrap-up tasks like "Introduction" and "Closing" that duplicate the standard Introduction and Next Steps. Then use [Reorder Tasks](/docs/api-reference/scripts/reorder-tasks.md) to move Next Steps back to the end. You can remove standard tasks you don't want with `PATCH /v2/script-tasks/{taskId}` and `{ "removed": true }`, but keep Introduction and Next Steps. See [AI endpoints](/docs/guides/ai-endpoints.md) for the full steps.

```bash cURL theme={null}
curl -X POST https://api.classet.ai/v2/scripts/generate \
  -H "X-API-KEY: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "job_title": "CDL Truck Driver",
    "job_description": "Long-haul routes, Class A CDL required",
    "focus_areas": ["driving experience", "safety record", "availability"]
  }'
```

```json 200 theme={null}
{
  "data": {
    "name": "CDL Driver Screen",
    "description": "Phone screening script for CDL truck driver candidates",
    "tasks": [
      {
        "name": "Introduction",
        "description": "Greet the candidate and explain the screening process",
        "questions": [],
        "order": 1
      },
      {
        "name": "Driving Experience",
        "description": "Assess commercial driving background",
        "questions": [
          "How many years of CDL driving experience do you have?",
          "What types of freight have you hauled?",
          "Have you done long-haul routes before?"
        ],
        "qualifying_questions": [
          {
            "question": "Do you hold a valid Class A CDL?",
            "disqualifyIf": "no"
          }
        ],
        "order": 2
      },
      {
        "name": "Safety & Compliance",
        "description": "Verify safety record and compliance",
        "questions": [
          "Have you had any moving violations in the past 3 years?",
          "Are you familiar with DOT HOS regulations?"
        ],
        "order": 3
      },
      {
        "name": "Availability & Logistics",
        "description": "Confirm availability and logistics",
        "questions": [
          "Are you available to start within two weeks?",
          "Are you comfortable being away from home for extended periods?"
        ],
        "order": 4
      },
      {
        "name": "Closing",
        "description": "Wrap up and explain next steps",
        "questions": [],
        "order": 5
      }
    ]
  }
}
```


## OpenAPI

````yaml POST /v2/scripts/generate
openapi: 3.1.0
info:
  title: Classet API
  version: 2.0.3
  description: >-
    AI-powered recruiting and phone screening API.


    **API key scopes.** `read` covers every GET; any other method needs `write`
    (403 `insufficient_scope`); starting or stopping an interview also needs
    `interviews:send`. A branch-limited key sees and writes only jobs in its
    branches (not jobs with no branch) and their candidates, applications and
    calls; anything outside is a 404. An organization-group key is read-only
    across every organization in its group. Branch-limited and group keys cannot
    use organization configuration (scripts, knowledge, webhooks, message
    automations, agent settings, AI generation, organization): 403
    `restricted_key_unsupported`. `GET /v2/me` reports what the calling key can
    do.
servers:
  - url: https://api.classet.ai
    description: Production
  - url: http://localhost:8081
    description: Local development
security:
  - ApiKeyAuth: []
paths:
  /v2/scripts/generate:
    post:
      tags:
        - AI
      summary: Generate an interview script with AI
      description: >-
        Uses AI to generate a structured interview script with tasks and
        questions tailored to the role.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                job_title:
                  type: string
                  minLength: 1
                  example: Senior Software Engineer
                  description: The role to generate the script for.
                job_description:
                  type: string
                  example: Full-stack role building payment infrastructure...
                  description: Additional context about the role, requirements, or company.
                focus_areas:
                  type: array
                  items:
                    type: string
                  example:
                    - technical skills
                    - cultural fit
                    - leadership
                  description: >-
                    Specific areas to focus the interview on (e.g. `["technical
                    skills", "safety knowledge", "availability"]`).
              required:
                - job_title
      responses:
        '200':
          description: Generated script data
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      name:
                        type: string
                        description: Generated script name.
                      description:
                        type: string
                        description: Description of the script's purpose.
                      tasks:
                        type: array
                        items:
                          type: object
                          properties:
                            name:
                              type: string
                              description: Display name of the task.
                            description:
                              type: string
                              description: What this task covers.
                            questions:
                              type: array
                              items:
                                type: string
                              description: Questions to ask.
                            qualifying_questions:
                              type: array
                              items:
                                type: object
                                properties:
                                  question:
                                    type: string
                                  disqualifyIf:
                                    type: string
                                required:
                                  - question
                                  - disqualifyIf
                              description: >-
                                Pass/fail questions with `question` and
                                `disqualifyIf` fields.
                            order:
                              type: integer
                              description: Position in the flow.
                          required:
                            - name
                            - description
                            - questions
                            - order
                        description: >-
                          Ordered list of interview tasks, each with questions
                          and optional qualifying criteria.
                    required:
                      - name
                      - description
                      - tasks
                required:
                  - data
        '500':
          description: Server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Resource not found
                  code:
                    type: string
                    enum:
                      - not_found
                      - validation_error
                      - unauthorized
                      - forbidden
                      - insufficient_scope
                      - restricted_key_unsupported
                      - branch_out_of_scope
                      - key_misconfigured
                      - quota_exceeded
                      - rate_limited
                      - rate_limit_unavailable
                      - conflict
                      - idempotency_key_reuse
                      - candidate_opted_out
                      - recently_contacted
                      - request_in_progress
                      - unprocessable
                      - bad_request
                      - payload_too_large
                      - internal_error
                      - service_unavailable
                    example: not_found
                    description: Stable machine-readable error code.
                  request_id:
                    type: string
                    example: 9f2c1d7e-4a3b-4c8d-9e0f-1a2b3c4d5e6f
                    description: >-
                      Request ID, also echoed in the X-Request-Id response
                      header. Include it when reporting issues.
                required:
                  - error
      security:
        - ApiKeyAuth: []
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY
      description: Your Classet API key. Create and rotate keys in Settings → API.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.