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

# Change or publish a survey

> Changes what you send of a draft survey: its title, type, description, questions, theme or email, and publishes it with state: published. A published survey is locked (a 409): duplicate it to change it. A title another survey has, a deleted one included, returns 409. Publishing without an email or a question returns 422.



## OpenAPI

````yaml /api/statisfy-api.openapi.json patch /v1/surveys/{survey_id}
openapi: 3.1.0
info:
  description: >-
    The agent-first Statisfy API. Authenticate with an API key (`Authorization:
    Bearer stfy_live_…`), then call `GET /v1/meta/capabilities` to discover
    every operation and its schemas.
  title: Statisfy API
  version: 1.0.0
servers:
  - url: https://api.statisfy.com
    description: Production
security: []
paths:
  /v1/surveys/{survey_id}:
    patch:
      tags:
        - surveys
      summary: Change or publish a survey
      description: >-
        Changes what you send of a draft survey: its title, type, description,
        questions, theme or email, and publishes it with state: published. A
        published survey is locked (a 409): duplicate it to change it. A title
        another survey has, a deleted one included, returns 409. Publishing
        without an email or a question returns 422.
      operationId: surveys_update
      parameters:
        - description: The survey's id, from GET /v1/surveys
          in: path
          name: survey_id
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              additionalProperties: false
              properties:
                creator:
                  default: null
                  description: >-
                    With `email`, on a survey no one owns: the email of a
                    current member of your workspace, who owns the survey's
                    email. A survey with an owner gives its email to them
                  maxLength: 320
                  minLength: 3
                  pattern: ^[^@\s]+@[^@\s]+$
                  title: Creator
                  type: string
                definition:
                  additionalProperties: true
                  default: null
                  description: >-
                    The survey's questions and pages: the SurveyJS JSON the
                    app's survey builder saves
                    (https://help.statisfy.com/rest-api/survey_definition).
                    Elements sit in `pages[].elements` (or top-level `elements`)
                    and in panels' `elements`; panels nest at most 10 deep. An
                    element's `type` is one of boolean, checkbox, comment,
                    dropdown, expression, file, html, image, imagepicker,
                    matrix, matrixdropdown, matrixdynamic, multipletext, panel,
                    paneldynamic, radiogroup, ranking, rating, signaturepad,
                    tagbox, text. A question's `name` is the key its answers
                    carry, so every question needs one and names must be unique.
                    At most 1,000,000 characters as JSON. HTML in it (`html`
                    elements, `completedHtml`) is stored as sent and cleaned
                    where the survey renders
                  examples:
                    - pages:
                        - elements:
                            - isRequired: true
                              name: nps
                              rateMax: 10
                              rateMin: 0
                              title: How likely are you to recommend us?
                              type: rating
                            - name: reason
                              title: What is the main reason for your score?
                              type: comment
                          name: page1
                  title: Definition
                  type: object
                description:
                  default: null
                  description: '"" clears it'
                  maxLength: 2000
                  title: Description
                  type: string
                email:
                  $ref: '#/components/schemas/EmailBody'
                  default: null
                  description: >-
                    The email a survey campaign sends, replaced whole. The app
                    opens it in its HTML editor; a design made in its simple
                    form or visual editor is replaced
                  title: Email
                state:
                  const: published
                  default: null
                  description: >-
                    published publishes it, once it has an email and a question;
                    publishing can't be undone. Changes sent with it are written
                    first
                  title: State
                  type: string
                theme:
                  additionalProperties: true
                  default: null
                  description: >-
                    The SurveyJS theme JSON the app's survey builder saves
                    (https://help.statisfy.com/rest-api/survey_definition#theme)
                  title: Theme
                  type: object
                title:
                  default: null
                  maxLength: 255
                  minLength: 1
                  title: Title
                  type: string
                type:
                  default: null
                  description: >-
                    NPS, CSAT, CES or CUSTOM. NPS and CSAT surveys feed account
                    health
                  enum:
                    - NPS
                    - CSAT
                    - CES
                    - CUSTOM
                  title: Type
                  type: string
              type: object
        required: false
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Survey'
          description: Successful Response
      security:
        - HTTPBearer: []
components:
  schemas:
    EmailBody:
      properties:
        html:
          description: >-
            The email's HTML, with Jinja merge tags. It needs {{survey_url}}
            (the recipient's link to the survey) and {{unsubscribe_this}} (the
            unsubscribe link), and may use the tags GET /v1/templates/merge-tags
            lists
          maxLength: 2000000
          minLength: 1
          title: Html
          type: string
        sender_email:
          description: The address it's sent from
          maxLength: 320
          minLength: 3
          pattern: ^[^@\s]+@[^@\s]+$
          title: Sender Email
          type: string
        sender_name:
          maxLength: 255
          minLength: 1
          title: Sender Name
          type: string
        subject:
          maxLength: 998
          minLength: 1
          title: Subject
          type: string
      required:
        - subject
        - sender_name
        - sender_email
        - html
      title: EmailBody
      type: object
    Survey:
      properties:
        created_at:
          format: date-time
          title: Created At
          type: string
        definition:
          additionalProperties: true
          description: >-
            The survey's questions and pages: the SurveyJS JSON the app's survey
            builder saves
            (https://help.statisfy.com/rest-api/survey_definition). Elements sit
            in `pages[].elements` (or top-level `elements`) and in panels'
            `elements`; panels nest at most 10 deep. An element's `type` is one
            of boolean, checkbox, comment, dropdown, expression, file, html,
            image, imagepicker, matrix, matrixdropdown, matrixdynamic,
            multipletext, panel, paneldynamic, radiogroup, ranking, rating,
            signaturepad, tagbox, text. A question's `name` is the key its
            answers carry, so every question needs one and names must be unique.
            At most 1,000,000 characters as JSON. HTML in it (`html` elements,
            `completedHtml`) is stored as sent and cleaned where the survey
            renders
          title: Definition
          type: object
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        email:
          anyOf:
            - $ref: '#/components/schemas/SurveyEmail'
            - type: 'null'
          description: The email a survey campaign sends; null until one is set
        id:
          title: Id
          type: string
        state:
          description: >-
            draft or published. Only a published survey can be sent in a
            campaign, and a published survey is locked: it can't be changed or
            deleted, only duplicated
          enum:
            - draft
            - published
          title: State
          type: string
        theme:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          description: >-
            The SurveyJS theme JSON the app's survey builder saves
            (https://help.statisfy.com/rest-api/survey_definition#theme)
          title: Theme
        title:
          title: Title
          type: string
        type:
          description: NPS, CSAT, CES or CUSTOM. NPS and CSAT surveys feed account health
          title: Type
          type: string
        updated_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          title: Updated At
      required:
        - id
        - title
        - type
        - state
        - created_at
        - updated_at
        - description
        - definition
        - theme
        - email
      title: Survey
      type: object
    SurveyEmail:
      properties:
        editor:
          description: >-
            Which of the app's email editors made it: simple (the form), visual
            (the drag-and-drop builder) or html (the HTML editor, where the API
            writes)
          enum:
            - simple
            - visual
            - html
          title: Editor
          type: string
        html:
          description: The HTML a campaign sends, merge tags not yet filled in
          title: Html
          type: string
        sender_email:
          anyOf:
            - type: string
            - type: 'null'
          title: Sender Email
        sender_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Sender Name
        subject:
          anyOf:
            - type: string
            - type: 'null'
          title: Subject
      required:
        - editor
        - subject
        - sender_name
        - sender_email
        - html
      title: SurveyEmail
      type: object
  securitySchemes:
    HTTPBearer:
      scheme: bearer
      type: http
      description: >-
        An API key, sent as `Authorization: Bearer stfy_live_…`. See
        [Authentication](/rest-api/authentication) for how to get one and which
        scopes it needs.

````

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