---
schema_version: "1"
id: df25f76f84bebaadf6a1269affc7277db458a9f87334f8aa20759a4a0b4072fc
title: Survey Invitations
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/service-cloud/salesforce-feedback-management-dev-guide/guides/feedback-management/salesforce-surveys-invitations.md
canonical_url: https://developer.salesforce.com/docs/service/salesforce-feedback-management-dev-guide/guide/salesforce-surveys-invitations.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: c91eeea16eaa4c8c8960ac8960f55d5f9faa220b3ac227992832fe426c3637e4
products:
  - Salesforce Feedback Management Developer Guide
  - Service Cloud Developer Content
---

# Survey Invitations

Learn how to create survey invitations through API requests that are invoked from an Apex class.

Survey invitations are created using these steps.

1.  The SurveyApi Apex class (SurveyApi.cls file) is available within a [package](https://resources.docs.salesforce.com/rel1/doc/en-us/static/misc/Survey_Sample_App.zip). The POST method from the SurveyApi Apex class calls the API endpoint having the required payload to create the survey invitation.

    **Resource**

    ```nolang
    /services/data/vXX.X/connect/surveys/surveyId/survey-response
    ```

    **Request body for POST**

    ```nolang
    {
      "languageCode": "",
      "invitationSettings": {
        "allowGuestUserResponse": false,
        "allowParticipantsAccessTheirResponse": false,
        "collectAnonymousResponse": false,
        "invitationExpirationDate": "2022-07-31T21:32:54",
        "communityId": "",
        "invitationOwner": ""
      }
    }
    ```

    See [Survey Responses Using Invitation Configurations](https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/connect_resources_create_submit_surveys.htm) for details of the request properties.

2.  The response to the previous POST request fetches the survey and its questions.

    **Response**

    ```nolang
    {
      "languageCode": "en",
      "invitationId": "0Kixx0000004MWaCAM",
      "flowInterviewState": "state1",
      "status": "Success",
      "surveyDetail": {
        "label": "Survey01",
        "name": "Survey01",
        "surveyPage": {
          "label": "Page 1",
          "name": "p_d84afb73_3a30_4a3f_aae7_b0478b3bb4ed",
          "surveyQuestions": [
            {
              "name": "q_856a997e_be2c_4ea3_b70d_7f6fb9cfbf4f",
              "label": "Good so Far!",
              "questionType": "ShortText",
              "responseDataType": "STRING",
              "validationFormula": <Formula if any custom validation is added>,
              "isResponseRequired": false
            }
          ]
        "versionLabel":"<Survey name>",
        "versionNumber": <Survey version>
        }
      },
      "errors": [],
      "warnings": []
    }
    
    ```

3.  The SurveyApi Apex class also has the code to parse the API response, which returns the survey details and questions to the Lightning Web Component (LWC).

    See [Survey Description Output](https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/connect_responses_survey_description_output.htm) for details of the response properties.

    Here’s how the survey appears on the Salesforce home page.

    ![A representation of the created survey on the Salesforce home page.](https://developer.salesforce.com/media/salesforce-feedback-management-dev-guide/surveys_home_page_output.png)


