Set question display logic

Survey Question Logic

Configure display options and skip logic for survey questions using the Survey Question API. These settings correspond to options on the Logic tab in the question builder.

Endpoints

Logic settings are configured via the standard survey question methods. Use the appropriate endpoint depending on whether you are reading, creating, or updating a question.

GET v5/survey/{survey_id}/surveyquestion/{question_id}
PUT v5/survey/{survey_id}/surveypage/{page_id}/surveyquestion
POST v5/survey/{survey_id}/surveyquestion/{question_id}

Requires authentication

Display Options

The following parameters control how a question is displayed or hidden.

properties
object
Display and behavior settings for the question.
shortname
string
Alias or short name for the question. Used in merge codes and as an alternate key when submitting response data.
varname
string
SPSS variable name for the question.

Skip Logic

Note: Setting or updating skip logic via the PUT and POST endpoints is not currently supported. The show_rules parameter is documented here for reference and for use once support becomes available. To read existing skip logic on a question, use the GET endpoint — the full show_rules object is returned in the response. Skip logic should be configured through the Alchemer web interface in the meantime.

Skip logic (display conditions) is set using the show_rules parameter. All values should be passed as strings.

Tip: The quickest way to learn the correct logic structure for a given scenario is to configure it using the web interface first, then retrieve the question via the API. The response will include the full show_rules object, which you can use as a reference.

Note: The question details response also includes a show_rules id and same_page_skus. These do not need to be supplied when setting show_rules via the API.
show_rules
object
Defines the display condition for the question. Contains three components: the primary condition entity, the logical operator, and the secondary condition entity or expected value.

Condition Types (show_rules[atom][type])

The show_rules[atom][type] value identifies what entity the condition is based on.

Type ID Constant
3SGLogicAtom_TYPE_QUESTION
6SGLogicAtom_TYPE_CURRENTDATE
21SGLogicAtom_TYPE_MOBILE
5SGLogicAtom_TYPE_IP
8SGLogicAtom_TYPE_COUNTRY
9SGLogicAtom_TYPE_REGION
19SGLogicAtom_TYPE_POSTAL
10SGLogicAtom_TYPE_CITY
4SGLogicAtom_TYPE_URLVAR
36SGLogicAtom_TYPE_SSOVAR
13SGLogicAtom_TYPE_INVITEFIELD

Operators by Question Type

Valid operators and the required show_rules[atom2][type] vary by question type. Use the tables below to identify the correct values for your condition.

Unsupported question types: File Upload, Drag and Drop, Ranking Grid, Signature, Continuous Sum, Textbox List, Slider List, Video Sentiment, Audio Sentiment, Grouping (Open Card Sort), Dropdown Menu Grid, Textbox Grid, Max Diff, Custom Table. Actions and Text/Media elements are also excluded.

Single-Select Questions

Applies to: Radio Buttons, Radio Button Grid, Net Promoter Score, Rating (Likert Scale), Image (Select One), Dropdown Menu List, Grouping (Closed Card Sort), Quick Sort, Semantic Differential, User Data

show_rules[atom2][type]: 17 — SGLogicAtom_TYPE_QUESTION_OPTIONS

Operator IDConstant
12SGLogicUnit_LOGIC_IN_LIST
5SGLogicUnit_LOGIC_NOTEQUAL
20SGLogicUnit_LOGIC_ANSWERED
21SGLogicUnit_LOGIC_NOTANSWERED

Multi-Select Questions

Applies to: Checkboxes, Image (Multi-Select), Checkbox Grid, Conjoint (Choice-Based)

show_rules[atom2][type]: 17 — SGLogicAtom_TYPE_QUESTION_OPTIONS

Operator IDConstant
4SGLogicUnit_LOGIC_EQUAL
22SGLogicUnit_LOGIC_NOT_EXACTLYEQUAL
12SGLogicUnit_LOGIC_IN_LIST
5SGLogicUnit_LOGIC_NOTEQUAL
20SGLogicUnit_LOGIC_ANSWERED
21SGLogicUnit_LOGIC_NOTANSWERED

Text-Based Questions

Applies to: Textbox, Essay / Long Answer

show_rules[atom2][type]: 2 — SGLogicAtom_TYPE_VALUE (use for all operators, including ANSWERED and NOTANSWERED)

Operator IDConstant
4SGLogicUnit_LOGIC_EQUAL
22SGLogicUnit_LOGIC_NOT_EXACTLYEQUAL
6SGLogicUnit_LOGIC_GT
7SGLogicUnit_LOGIC_GTE
8SGLogicUnit_LOGIC_LTE
9SGLogicUnit_LOGIC_LT
23SGLogicUnit_LOGIC_GTE_DATE
24SGLogicUnit_LOGIC_LTE_DATE
20SGLogicUnit_LOGIC_ANSWERED
21SGLogicUnit_LOGIC_NOTANSWERED
10SGLogicUnit_LOGIC_CONTAINSTR
14SGLogicUnit_LOGIC_REGEX
15SGLogicUnit_LOGIC_NOTREGEX
28SGLogicUnit_LOGIC_SENTIMENT_POS
30SGLogicUnit_LOGIC_SENTIMENT_NEU
29SGLogicUnit_LOGIC_SENTIMENT_NEG
31SGLogicUnit_LOGIC_SENTIMENT_GT
32SGLogicUnit_LOGIC_SENTIMENT_LT

Email, Date, Number, Percent

show_rules[atom2][type]: 2 — SGLogicAtom_TYPE_VALUE

Operator IDConstant
4SGLogicUnit_LOGIC_EQUAL
22SGLogicUnit_LOGIC_NOT_EXACTLYEQUAL
6SGLogicUnit_LOGIC_GT
7SGLogicUnit_LOGIC_GTE
8SGLogicUnit_LOGIC_LTE
9SGLogicUnit_LOGIC_LT
23SGLogicUnit_LOGIC_GTE_DATE
24SGLogicUnit_LOGIC_LTE_DATE
20SGLogicUnit_LOGIC_ANSWERED
21SGLogicUnit_LOGIC_NOTANSWERED
10SGLogicUnit_LOGIC_CONTAINSTR
14SGLogicUnit_LOGIC_REGEX
15SGLogicUnit_LOGIC_NOTREGEX

Slider

show_rules[atom2][type]: 17 — SGLogicAtom_TYPE_QUESTION_OPTIONS

Operator IDConstant
4SGLogicUnit_LOGIC_EQUAL
22SGLogicUnit_LOGIC_NOT_EXACTLYEQUAL
12SGLogicUnit_LOGIC_IN_LIST
5SGLogicUnit_LOGIC_NOTEQUAL
6SGLogicUnit_LOGIC_GT
7SGLogicUnit_LOGIC_GTE
8SGLogicUnit_LOGIC_LTE
9SGLogicUnit_LOGIC_LT
23SGLogicUnit_LOGIC_GTE_DATE
24SGLogicUnit_LOGIC_LTE_DATE
20SGLogicUnit_LOGIC_ANSWERED
21SGLogicUnit_LOGIC_NOTANSWERED
10SGLogicUnit_LOGIC_CONTAINSTR
14SGLogicUnit_LOGIC_REGEX
15SGLogicUnit_LOGIC_NOTREGEX

Star Rating Grid

show_rules[atom2][type]: 2 — SGLogicAtom_TYPE_VALUE

Operator IDConstant
4SGLogicUnit_LOGIC_EQUAL
22SGLogicUnit_LOGIC_NOT_EXACTLYEQUAL
12SGLogicUnit_LOGIC_IN_LIST
5SGLogicUnit_LOGIC_NOTEQUAL
23SGLogicUnit_LOGIC_GTE_DATE
24SGLogicUnit_LOGIC_LTE_DATE
20SGLogicUnit_LOGIC_ANSWERED
21SGLogicUnit_LOGIC_NOTANSWERED

Image Heatmap, Text Highlighter, Cascading Dropdown

show_rules[atom2][type]: 2 — SGLogicAtom_TYPE_VALUE

Operator IDConstant
20SGLogicUnit_LOGIC_ANSWERED
21SGLogicUnit_LOGIC_NOTANSWERED

Examples

Request (cURL) — Set Question Hidden by Default
curl -X POST "https://api.alchemer.com/v5/survey/123456/surveyquestion/5?api_token=YOUR_API_TOKEN&api_token_secret=YOUR_API_TOKEN_SECRET&properties[hidden]=true"
Request (cURL) — Get Question with Skip Logic
curl -X GET "https://api.alchemer.com/v5/survey/123456/surveyquestion/3?api_token=YOUR_API_TOKEN&api_token_secret=YOUR_API_TOKEN_SECRET"
Response — show_rules Object
"show_rules": {
  "atom": {
    "type": "3",
    "value": "2",
    "case_sensitive": true
  },
  "operator": "20",
  "atom2": {
    "type": "2",
    "value": "",
    "case_sensitive": false
  },
  "id": "69dd604f87828",
  "same_page_skus": []
}