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

# Save a survey draft

> Save the Surveys 2.0 draft. Body `{ definition, baseRevision?, allowEmpty? }`. Invalid logic is saved
and returned as `warnings`; a malformed definition answers 422 `{ errors }`. Live surveys keep serving
the published version. Returns `{ definition, draftRevision, warnings }`.

Every save bumps the draft's `draftRevision`. With `baseRevision` (the revision you loaded) a save over
a newer draft answers 409 `{ code: 'draft_changed', draftRevision }`. A save that would remove every
question of a draft that has some answers 409 `{ code: 'draft_would_remove_all_questions' }` unless
`allowEmpty: true`.



## OpenAPI

````yaml https://api.gleap.io/api-docs.json put /engagement/surveys/{surveyId}/draft
openapi: 3.0.0
info:
  title: gleap-server
  version: 14.0.0
  contact: {}
servers:
  - url: https://api.gleap.io/v3
security: []
paths:
  /engagement/surveys/{surveyId}/draft:
    put:
      tags:
        - Engagement Survey
      summary: Save a survey draft
      description: >-
        Save the Surveys 2.0 draft. Body `{ definition, baseRevision?,
        allowEmpty? }`. Invalid logic is saved

        and returned as `warnings`; a malformed definition answers 422 `{ errors
        }`. Live surveys keep serving

        the published version. Returns `{ definition, draftRevision, warnings
        }`.


        Every save bumps the draft's `draftRevision`. With `baseRevision` (the
        revision you loaded) a save over

        a newer draft answers 409 `{ code: 'draft_changed', draftRevision }`. A
        save that would remove every

        question of a draft that has some answers 409 `{ code:
        'draft_would_remove_all_questions' }` unless

        `allowEmpty: true`.
      operationId: SaveDraft
      parameters:
        - in: path
          name: surveyId
          required: true
          schema:
            type: string
        - in: header
          name: project
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema: {}
      responses:
        '200':
          description: Ok
          content:
            application/json:
              schema: {}
      security:
        - jwt: []
components:
  securitySchemes:
    jwt:
      type: http
      scheme: bearer
      bearerFormat: JWT

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.