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

# Start a persisted AI search job

> Trigger an AI search job for the specified feature_type and input params. Creates a DB record (status=pending) and enqueues a worker job. Returns immediately — poll GET /ai-search/{result_id} to track progress. If a job for the same feature_type is already in progress for this project a 400 is returned.



## OpenAPI

````yaml https://api.surnex.io/openapi.json post /v1/projects/{project_id}/ai-search
openapi: 3.1.0
info:
  title: Surnex API
  description: |-
    Surnex SEO Platform API — api.surnex.io

    Provides the complete backend for the Surnex SEO dashboard including:
    - Multi-tenant organization management
    - Project tracking (domains)
    - Keyword rank tracking (Phase 1+)
    - Backlink analysis (Phase 3+)
    - Site auditing (Phase 4+)
    - Stripe billing integration
    - MCP endpoint for AI agents at /mcp
  version: 0.1.0
servers: []
security: []
paths:
  /v1/projects/{project_id}/ai-search:
    post:
      tags:
        - AI Search
      summary: Start a persisted AI search job
      description: >-
        Trigger an AI search job for the specified feature_type and input
        params. Creates a DB record (status=pending) and enqueues a worker job.
        Returns immediately — poll GET /ai-search/{result_id} to track progress.
        If a job for the same feature_type is already in progress for this
        project a 400 is returned.
      operationId: start_ai_search_v1_projects__project_id__ai_search_post
      parameters:
        - name: project_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Project Id
        - name: X-API-Key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Api-Key
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StartAiSearchRequest'
      responses:
        '202':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIResponse_AiSearchResultResponse_'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    StartAiSearchRequest:
      properties:
        feature_type:
          type: string
          title: Feature Type
          description: >-
            AI search feature to execute. One of: google_ai_mode,
            chatgpt_visibility, llm_benchmark, ai_keyword_trends, citation_gap.
        input_params:
          additionalProperties: true
          type: object
          title: Input Params
          description: >-
            Tool-specific parameters (keyword, keywords, location_code,
            language_code, your_domain, competitor_domains).
        refresh_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Refresh Id
          description: >-
            If provided, resets the existing result instead of creating a new
            one.
      type: object
      required:
        - feature_type
      title: StartAiSearchRequest
      description: |-
        Request body for triggering a persisted AI search job.

        Attributes:
            feature_type: Which AI search tool to run. One of:
                google_ai_mode, chatgpt_visibility, llm_benchmark,
                ai_keyword_trends, citation_gap.
            input_params: Tool-specific parameters. Expected keys vary by
                feature_type:
                - google_ai_mode:       keyword, location_code, language_code
                - chatgpt_visibility:   keyword, location_code, language_code
                - llm_benchmark:        keyword, location_code, language_code
                - ai_keyword_trends:    keywords (list), location_code, language_code
                - citation_gap:         keywords (list), your_domain,
                                        competitor_domains (list), location_code,
                                        language_code
    APIResponse_AiSearchResultResponse_:
      properties:
        success:
          type: boolean
          title: Success
          default: true
        data:
          anyOf:
            - $ref: '#/components/schemas/AiSearchResultResponse'
            - type: 'null'
      type: object
      title: APIResponse[AiSearchResultResponse]
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    AiSearchResultResponse:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        project_id:
          type: string
          format: uuid
          title: Project Id
        feature_type:
          type: string
          title: Feature Type
        status:
          type: string
          title: Status
        input_params:
          additionalProperties: true
          type: object
          title: Input Params
        result_data:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Result Data
        error_message:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Message
        completed_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Completed At
        created_by:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Created By
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
      type: object
      required:
        - id
        - project_id
        - feature_type
        - status
        - input_params
        - created_at
        - updated_at
      title: AiSearchResultResponse
      description: |-
        Full AI search result record returned from the API.

        Attributes:
            id: Primary key UUID.
            project_id: Project this result belongs to.
            feature_type: Which AI search feature produced this result.
            status: Lifecycle state — pending, processing, completed, failed.
            input_params: Parameters that were supplied when the job was triggered.
            result_data: The DataForSEO response payload (null while pending/processing).
            error_message: Populated when status is failed.
            completed_at: Timestamp when the worker finished (or errored).
            created_by: UUID of the user who triggered the job.
            created_at: Row creation timestamp.
            updated_at: Last modification timestamp.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````