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

# Generate AI Call Script

> Generates AI call instructions and structured data extraction plan based on company details, task prompt, questions, and FAQs.

<Info>
  This endpoint is **AI-powered**. It generates AI call instructions and a structured data extraction plan based on your company details, task prompt, questions, and FAQs.
</Info>

## What it returns

* **instructions** — AI behavior instructions for the call. These can be passed directly to the [Initiate AI Call](/api-reference/endpoint/call-initiate) endpoint as the `instructions` field.
* **extract\_variables** — Structured data fields the AI should extract during the call. These can be passed directly to the [Initiate AI Call](/api-reference/endpoint/call-initiate) endpoint as the `extract_variables` field.

## Example Request

```json theme={null}
{
  "company_name": "Acme Corp",
  "prompt": "Screen candidates for the Senior Software Engineer position and assess their experience with distributed systems.",
  "questions": [
    "How many years of experience do you have with Node.js?",
    "Have you worked with microservices architecture?",
    "Describe a challenging system design problem you have solved."
  ],
  "faqs": [
    {
      "question": "What is the salary range?",
      "answer": "The range is $120k - $180k depending on experience."
    },
    {
      "question": "Is this remote?",
      "answer": "Yes, fully remote."
    },
    {
      "question": "What is the interview process?",
      "answer": "There will be a technical round followed by a system design discussion."
    }
  ]
}
```

## Example Response

```json theme={null}
{
  "success": true,
  "data": {
    "instructions": "You are a recruiter for Acme Corp screening candidates for the Senior Software Engineer role. Ask about their experience with distributed systems, Node.js, and microservices architecture. Be professional and friendly. If candidates ask about salary, mention the range is $120k - $180k depending on experience. If they ask about remote work, confirm it is fully remote.",
    "extract_variables": [
      {
        "label": "Years of Experience",
        "type": "integer",
        "description": "How many years of professional experience does the candidate have?",
        "format_example": "5"
      },
      {
        "label": "Node.js Experience",
        "type": "boolean",
        "description": "Does the candidate have experience with Node.js?",
        "format_example": "true"
      },
      {
        "label": "Microservices Experience",
        "type": "string",
        "description": "Describe the candidate's experience with microservices architecture.",
        "format_example": "Built and maintained a microservices-based e-commerce platform"
      }
    ]
  }
}
```


## OpenAPI

````yaml POST /api/public/v1/ai/generate-script
openapi: 3.1.0
info:
  title: Tidyhire API
  description: Tidyhire Public API for ATS integrations
  version: 1.0.0
servers:
  - url: https://api.tidyhire.app
    description: Production
security:
  - apiKey: []
paths:
  /api/public/v1/ai/generate-script:
    post:
      tags:
        - AI
      summary: Generate AI Call Script
      description: >-
        Generates AI call instructions and structured data extraction plan based
        on company details, task prompt, questions, and FAQs.
      operationId: generateCallScript
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GenerateCallScriptRequest'
      responses:
        '200':
          description: Success.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenerateCallScriptSuccessResponse'
        '400':
          description: Validation Error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorResponse'
        '401':
          description: Unauthorized.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedResponse'
        '429':
          description: Rate limit exceeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitErrorResponse'
        '500':
          description: Internal error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalErrorResponse'
      security:
        - apiKey: []
components:
  schemas:
    GenerateCallScriptRequest:
      type: object
      required:
        - company_name
        - prompt
      properties:
        company_name:
          type: string
          minLength: 1
          description: Name of the company.
          example: Acme Corp
        prompt:
          type: string
          minLength: 1
          description: >-
            The main task or goal for the AI call. Describes what the AI should
            accomplish.
          example: >-
            Screen candidates for the Senior Software Engineer position and
            assess their experience with distributed systems.
        questions:
          type: array
          items:
            type: string
            minLength: 1
          description: Specific questions the AI should ask during the call.
          example:
            - How many years of experience do you have with Node.js?
            - Have you worked with microservices architecture?
        faqs:
          type: array
          items:
            type: object
            required:
              - question
              - answer
            properties:
              question:
                type: string
                minLength: 1
                description: The frequently asked question.
              answer:
                type: string
                minLength: 1
                description: The answer to the question.
          description: >-
            Frequently asked questions and their answers to help the AI respond
            accurately.
          example:
            - question: What is the salary range?
              answer: The range is $120k - $180k depending on experience.
            - question: Is this remote?
              answer: Yes, fully remote.
        end_call_on_disqualification:
          type: boolean
          default: false
          description: >-
            If true, the AI will automatically end the call when a candidate is
            disqualified based on screening criteria.
          example: false
    GenerateCallScriptSuccessResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        data:
          type: object
          properties:
            instructions:
              type: string
              description: Generated AI behavior instructions for the call.
              example: >-
                You are a recruiter for Acme Corp screening candidates for the
                Senior Software Engineer role. Ask about their experience with
                distributed systems.
            extract_variables:
              type: array
              items:
                $ref: '#/components/schemas/ExtractVariable'
              description: Structured data fields the AI should extract during the call.
    ValidationErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        code:
          type: string
          example: VALIDATION_ERROR
        message:
          type: string
          example: Request validation failed
        errors:
          type: array
          items:
            type: object
            properties:
              field:
                type: string
                example: candidates.0.name
              message:
                type: string
                example: Candidate name must be at least 3 characters
    UnauthorizedResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        message:
          type: string
          example: Unauthorized
        error:
          type: string
          example: INVALID_API_KEY
    RateLimitErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        code:
          type: string
          example: RATE_LIMIT_EXCEEDED
        message:
          type: string
          example: Too many requests
    InternalErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        code:
          type: string
          example: UNKNOWN_ERROR
        message:
          type: string
          example: Something went wrong.
    ExtractVariable:
      type: object
      required:
        - label
        - type
        - description
      properties:
        label:
          type: string
          description: Human-readable name for the variable.
          example: Years of Experience
        type:
          type: string
          enum:
            - string
            - single_select
            - boolean
            - integer
            - number
            - array
            - date
            - datetime
          description: Data type of the extracted variable.
        description:
          type: string
          description: What the AI should extract.
          example: How many years of professional experience does the candidate have?
        format_example:
          type: string
          description: Example of the expected output format.
          example: 5 years
        choices:
          type: array
          items:
            type: string
          description: Allowed values for single_select type.
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-tidyhire-api-key
      description: Your Tidyhire API key

````