> ## 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.

# Create survey file

> Creates a pending file record and returns a presigned upload URL. Upload bytes directly to object storage — not through this API (except local `/_dev/objects` in development). When `content_hash` matches an existing ready file for the survey, returns that file with `existingMatch: true` and no upload URL.



## OpenAPI

````yaml /openapi/program.openapi.json post /surveys/{surveyId}/files
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}/files:
    post:
      tags:
        - Survey files
      summary: Create survey file
      description: >-
        Creates a pending file record and returns a presigned upload URL. Upload
        bytes directly to object storage — not through this API (except local
        `/_dev/objects` in development). When `content_hash` matches an existing
        ready file for the survey, returns that file with `existingMatch: true`
        and no upload URL.
      parameters:
        - schema:
            type: string
            format: uuid
          required: true
          name: surveyId
          in: path
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSurveyFileRequest'
      responses:
        '200':
          description: Existing ready file reused (content_hash match)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateSurveyFileResponse'
        '201':
          description: File created with upload URL
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateSurveyFileResponse'
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorBody'
        '404':
          description: Survey not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
components:
  schemas:
    CreateSurveyFileRequest:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          example: stimulus-pack.zip
        content_type:
          type: string
          minLength: 1
          example: application/zip
        size_bytes:
          type: integer
          exclusiveMinimum: 0
        visibility:
          allOf:
            - $ref: '#/components/schemas/ObjectVisibility'
            - example: private
              description: Bucket visibility. Defaults to private.
        content_hash:
          type: string
          pattern: ^[a-f0-9]{64}$
          description: >-
            When provided and a ready file with the same hash already exists for
            the survey, the existing file is returned and no upload URL is
            issued.
          example: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
      required:
        - name
        - content_type
    CreateSurveyFileResponse:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/SurveyFile'
        upload:
          $ref: '#/components/schemas/PresignedUpload'
        existingMatch:
          type: boolean
          description: >-
            True when an existing ready file matched `content_hash` and was
            reused.
      required:
        - data
        - upload
    ValidationErrorBody:
      type: object
      properties:
        error:
          type: string
          enum:
            - validation_error
        message:
          type: string
        details: {}
      required:
        - error
    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
    ObjectVisibility:
      type: string
      enum:
        - private
        - public
    SurveyFile:
      type: object
      properties:
        id:
          type: string
          format: uuid
        survey_id:
          type: string
          format: uuid
        name:
          type: string
          minLength: 1
        content_type:
          type: string
          minLength: 1
        size_bytes:
          type:
            - integer
            - 'null'
          minimum: 0
        storage_key:
          type: string
          minLength: 1
        status:
          $ref: '#/components/schemas/SurveyFileStatus'
        visibility:
          $ref: '#/components/schemas/ObjectVisibility'
        hosting:
          $ref: '#/components/schemas/SurveyFileHosting'
        upstream_path:
          type:
            - string
            - 'null'
          minLength: 1
        content_hash:
          type:
            - string
            - 'null'
          pattern: ^[a-f0-9]{64}$
          description: Lowercase SHA-256 hex digest of the file bytes.
          example: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
        public_url:
          type:
            - string
            - 'null'
          format: uri
        upstream_only:
          type: boolean
        reserved_type:
          type:
            - string
            - 'null'
          minLength: 1
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      required:
        - id
        - survey_id
        - name
        - content_type
        - size_bytes
        - storage_key
        - status
        - visibility
        - hosting
        - upstream_path
        - content_hash
        - public_url
        - created_at
        - updated_at
    PresignedUpload:
      type:
        - object
        - 'null'
      properties:
        url:
          type: string
          format: uri
        method:
          type: string
          enum:
            - PUT
        headers:
          type: object
          additionalProperties:
            type: string
        expires_at:
          type: string
          format: date-time
      required:
        - url
        - method
        - headers
        - expires_at
    SurveyFileStatus:
      type: string
      enum:
        - pending
        - ready
        - failed
    SurveyFileHosting:
      type: string
      enum:
        - questra
        - platform

````