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

# Start a questionnaire↔survey audit

> Creates a questionnaire↔survey audit pinned to a saved content revision and starts `survey.audit` (detect only).

`content_revision` defaults to the current tip. **404** if that revision does not exist. Source is loaded from the pinned revision — do not send a free-form `source` body. Unsaved editor drafts are not a revision.

Re-running on the same saved revision is allowed. **409** `audit_already_exists` only while an audit is still running for that revision.

Returns **202** `{ data: audit }` with `workflow_id` (detect World run). Subscribe via `GET /v1/workflows/{workflow_id}` and `.../stream`. Domain payloads do not include `stream_url`.

Newest-wins across revisions: a new POST replaces any active detect run for this survey (`survey.audit:{surveyId}`).



## OpenAPI

````yaml /openapi/program.openapi.json post /surveys/{surveyId}/audits
openapi: 3.1.0
info:
  title: Questra Program API
  version: 0.0.1
  description: >-
    REST API for the Questra Program product. Browser users authenticate through
    Questra Auth SSO; automation uses workspace-scoped API keys (`Authorization:
    Bearer qpk_live_…`). API keys carry scopes enforced before handlers.
    Outbound webhooks follow Standard Webhooks (at-least-once delivery;
    consumers must be idempotent).
servers:
  - url: /v1
    description: Program API base path
security: []
paths:
  /surveys/{surveyId}/audits:
    post:
      tags:
        - Survey audits
      summary: Start a questionnaire↔survey audit
      description: >-
        Creates a questionnaire↔survey audit pinned to a saved content revision
        and starts `survey.audit` (detect only).


        `content_revision` defaults to the current tip. **404** if that revision
        does not exist. Source is loaded from the pinned revision — do not send
        a free-form `source` body. Unsaved editor drafts are not a revision.


        Re-running on the same saved revision is allowed. **409**
        `audit_already_exists` only while an audit is still running for that
        revision.


        Returns **202** `{ data: audit }` with `workflow_id` (detect World run).
        Subscribe via `GET /v1/workflows/{workflow_id}` and `.../stream`. Domain
        payloads do not include `stream_url`.


        Newest-wins across revisions: a new POST replaces any active detect run
        for this survey (`survey.audit:{surveyId}`).
      parameters:
        - schema:
            type: string
            format: uuid
          required: true
          name: surveyId
          in: path
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSurveyAuditRequest'
      responses:
        '202':
          description: Audit accepted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SurveyAuditResponse'
        '400':
          description: Validation error, missing questionnaire, or workflow create failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '404':
          description: Survey, content revision, questionnaire, or file not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '409':
          description: >-
            Questionnaire file not ready, or an audit is already running for
            this saved revision
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
components:
  schemas:
    CreateSurveyAuditRequest:
      type: object
      properties:
        content_revision:
          type: integer
          exclusiveMinimum: 0
        focus:
          type: string
          minLength: 1
        trigger:
          $ref: '#/components/schemas/SurveyAuditTrigger'
    SurveyAuditResponse:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/SurveyAudit'
      required:
        - data
    ErrorBody:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
        resource:
          type: string
        slug:
          type: string
        file_id:
          type: string
        endpoint_id:
          type: string
        event_id:
          type: string
        delivery_id:
          type: string
        api_key_id:
          type: string
        integration_id:
          type: string
        audit_id:
          type: string
        status:
          type: string
        details: {}
        question_ids:
          type: array
          items:
            type: string
        survey_ids:
          type: array
          items:
            type: string
        revisions:
          type: array
          items:
            type: number
      required:
        - error
    SurveyAuditTrigger:
      type: string
      enum:
        - agent
        - user
        - programming
    SurveyAudit:
      type: object
      properties:
        id:
          type: string
          format: uuid
        workspace_id:
          type: string
        survey_id:
          type: string
          format: uuid
        workflow_id:
          type: string
          minLength: 1
        status:
          $ref: '#/components/schemas/SurveyAuditStatus'
        trigger:
          $ref: '#/components/schemas/SurveyAuditTrigger'
        run_number:
          type: integer
          exclusiveMinimum: 0
        questionnaire_revision:
          type: integer
          exclusiveMinimum: 0
        content_revision:
          type: integer
          exclusiveMinimum: 0
        platform:
          type:
            - string
            - 'null'
        focus:
          type:
            - string
            - 'null'
        audited_source_key:
          type:
            - string
            - 'null'
        proposed_source_key:
          type:
            - string
            - 'null'
        finding_count:
          type: integer
          minimum: 0
        open_count:
          type: integer
          minimum: 0
        has_running_remediation:
          type: boolean
        created_by:
          type: string
          minLength: 1
        error:
          $ref: '#/components/schemas/SurveyAuditError'
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        completed_at:
          type:
            - string
            - 'null'
          format: date-time
      required:
        - id
        - workspace_id
        - survey_id
        - workflow_id
        - status
        - trigger
        - run_number
        - questionnaire_revision
        - content_revision
        - platform
        - focus
        - audited_source_key
        - proposed_source_key
        - finding_count
        - open_count
        - has_running_remediation
        - created_by
        - error
        - created_at
        - updated_at
        - completed_at
    SurveyAuditStatus:
      type: string
      enum:
        - running
        - completed
        - failed
        - cancelled
    SurveyAuditError:
      type:
        - object
        - 'null'
      properties:
        code:
          type: string
        message:
          type: string
      required:
        - code
        - message

````