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

# Generate Form with AI

> Generate a form from a natural language prompt using AI.



## OpenAPI

````yaml openapi.json post /forms/generate
openapi: 3.1.0
info:
  title: GeniusForms API
  description: >-
    AI-powered form builder API. Create forms manually or generate them from
    natural language prompts.
  version: 1.0.0
  contact:
    name: GeniusForms Support
    email: support@geniusforms.ai
    url: https://geniusforms.ai
servers:
  - url: https://geniusforms.ai/api/v1
    description: Production
  - url: http://localhost:8000/api/v1
    description: Local Development
security:
  - ApiKeyAuth: []
paths:
  /forms/generate:
    post:
      tags:
        - Forms
      summary: Generate Form with AI
      description: Generate a form from a natural language prompt using AI.
      operationId: generateForm
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GenerateFormRequest'
      responses:
        '201':
          description: Form generated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FormWithQuestions'
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Form-scoped API keys cannot generate forms
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    GenerateFormRequest:
      type: object
      required:
        - prompt
      properties:
        prompt:
          type: string
          minLength: 10
          maxLength: 5000
          example: Create a job application form for a software developer position
        title:
          type: string
          description: Override AI-generated title
        description:
          type: string
          description: Override AI-generated description
    FormWithQuestions:
      allOf:
        - $ref: '#/components/schemas/Form'
        - type: object
          properties:
            questions:
              type: array
              items:
                $ref: '#/components/schemas/Question'
    Error:
      type: object
      properties:
        error:
          type: string
          example: validation_error
        message:
          type: string
          example: Invalid request
    Form:
      type: object
      properties:
        id:
          type: integer
          example: 208
        title:
          type: string
          example: Customer Feedback
        description:
          type: string
          example: Help us improve our service
        isPublished:
          type: boolean
          example: false
        shareUrl:
          type: string
          example: abc123xyz
        url:
          type: string
          example: https://geniusforms.ai/f/abc123xyz
        displayMode:
          type: string
          enum:
            - single-page
            - multi-step
          example: single-page
        createdAt:
          type: string
          format: date-time
        publishedAt:
          type: string
          format: date-time
          nullable: true
        webhook:
          $ref: '#/components/schemas/WebhookConfig'
    Question:
      type: object
      properties:
        id:
          type: integer
          example: 1
        order:
          type: integer
          example: 1
        type:
          type: string
          enum:
            - text
            - textarea
            - email
            - number
            - phone
            - url
            - date
            - time
            - select
            - multi_select
            - rating
            - slider
            - yes_no
            - file_upload
            - currency
          example: text
        question:
          type: string
          example: Your name
        required:
          type: boolean
          example: true
        options:
          type: array
          items:
            type: string
          nullable: true
          example:
            - Option A
            - Option B
        conditionalLogic:
          $ref: '#/components/schemas/ConditionalLogic'
    WebhookConfig:
      type: object
      description: Webhook configuration for the form
      properties:
        enabled:
          type: boolean
          example: false
        url:
          type: string
          nullable: true
          example: https://example.com/webhook
    ConditionalLogic:
      type: object
      description: Conditional logic for showing/hiding questions
      properties:
        showIf:
          type: object
          description: Simple condition - show if another question matches
          properties:
            questionId:
              type: integer
              description: ID of the question to check
            operator:
              type: string
              enum:
                - equals
                - not_equals
            value:
              type: string
              description: Value to compare against
        advanced:
          type: object
          description: Advanced logic with multiple conditions and actions
          properties:
            conditionGroups:
              type: array
              items:
                type: object
                properties:
                  id:
                    type: string
                  operator:
                    type: string
                    enum:
                      - AND
                      - OR
                  conditions:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                        questionId:
                          type: integer
                        operator:
                          type: string
                          enum:
                            - equals
                            - not_equals
                            - contains
                            - greater_than
                            - less_than
                            - is_empty
                            - is_not_empty
                        value:
                          type:
                            - string
                            - number
                        valueType:
                          type: string
                          enum:
                            - static
                            - dynamic
                            - score
            actions:
              type: array
              items:
                type: object
                properties:
                  type:
                    type: string
                    enum:
                      - show_question
                      - hide_question
                      - skip_to_section
                      - skip_to_question
                      - end_form
                      - set_score
                  targetId:
                    type:
                      - integer
                      - string
                  value: {}
            scoreRules:
              type: array
              items:
                type: object
                properties:
                  id:
                    type: string
                  questionId:
                    type: integer
                  scoreMap:
                    type: object
                    additionalProperties:
                      type: number
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key obtained from your GeniusForms dashboard

````