Skip to content

Add questions to a survey

POST
/surveys/{id}/questions
curl --request POST \
--url https://app.surveyrock.com/api/v1/surveys/example/questions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "questions": [ { "type": "text_input", "text": "example", "subject": "example", "helpText": "example", "required": false, "choices": [ "example" ], "multipleAnswers": false, "rows": [ "example" ], "columns": [ "example" ], "pageTitle": "example", "mostLabel": "example", "leastLabel": "example", "itemsPerSet": 1, "exposuresPerItem": 1 } ], "pageId": "example" }'

Add questions after the survey’s last question, or after the last question of the page named by pageId. Each is the question the survey editor would make for its type, with that type’s defaults; the list takes the same fields as createSurvey’s questions. A question with pageTitle starts a new page at the end of the survey, so pageTitle is refused when pageId names a page other than the last. All or nothing: the list is checked whole first; any problem is a 422 naming each question at fault, and more questions than the plan allows on one survey (counting those it has) is a 403 quota_exceeded. Either way nothing is written. A published survey keeps collecting with its published questions until it is published again. Not idempotent: send an Idempotency-Key so a retry does not add the questions twice.

id
required
string

Survey ID

Idempotency-Key
string
>= 1 characters <= 128 characters

1 to 128 characters, chosen by the caller. Recommended: adding questions is not idempotent, and a retry with the same key and body replays the first response instead of adding them twice; the same key with a different body is a 409

Media typeapplication/json
object
questions
required

The questions to add, in order. Each takes the fields of createSurvey’s questions items: type (required), text (required), helpText, required, choices, multipleAnswers, rows, columns, pageTitle, subject (nps only; an NPS question asks the standard sentence about its subject, not its text), mostLabel, leastLabel, itemsPerSet and exposuresPerItem (maxdiff only). The response gives each question’s text as respondents will see it.

Array<object>
>= 1 items <= 100 items
object
type
required

Question type. text_input is a free-text answer, rating_scale a rating scale, ranking puts choices in order, matrix asks rows against columns. maxdiff (MaxDiff, best-worst scaling; Growth plan and above, otherwise a 403 feature_locked) shows its choices a few at a time and asks for the most and least important of each set; give it 6 to 30 short items of the same kind, one idea each, none negated, and no “None of these” or “Other”.

string
Allowed values: text_input multiple_choice rating_scale matrix slider nps yes_no email date ranking file_upload maxdiff
text
required

The question as respondents read it. Except for nps: an NPS question always asks the standard sentence, “How likely is it that you would recommend [subject] to a friend or colleague?”, so its text is not shown; set subject instead.

string
<= 5000 characters
subject

For nps only: who or what is recommended, e.g. “us” or “our support team”. Leave it out for “this company”. Refused on other types.

string
nullable <= 50 characters
helpText

Optional guidance shown under the question.

string
nullable <= 5000 characters
required

Whether a respondent must answer it.

boolean
choices

The answer options, for multiple_choice and ranking; the items, for maxdiff (6 to 30; none gives the editor’s six placeholder items). Ignored for other types.

Array<string>
<= 50 items
multipleAnswers

For multiple_choice: let respondents pick more than one. Ignored for other types.

boolean
rows

For matrix and slider: the statements rated. None gives the editor’s three placeholder rows. Ignored for other types.

Array<string>
<= 50 items
columns

For matrix: the answer columns. None keeps the editor’s standard scale. Ignored for other types.

Array<string>
<= 10 items
pageTitle

Start a new page at this question, with this title.

string
nullable <= 255 characters
mostLabel

For maxdiff only: the wording of the “most” pick, e.g. “Most appealing”. Leave it out for “Most important”. The two labels name one thing and its opposite. Refused on other types.

string
nullable <= 60 characters
leastLabel

For maxdiff only: the wording of the “least” pick, e.g. “Least appealing”. Leave it out for “Least important”. Refused on other types.

string
nullable <= 60 characters
itemsPerSet

For maxdiff only: items shown in each set. Leave it out for the recommended size for the number of items. Refused on other types.

integer
nullable >= 3 <= 5
exposuresPerItem

For maxdiff only: how many times each respondent sees each item. Leave it out for the recommended number, which keeps a respondent to about 12 sets. Refused on other types.

integer
nullable >= 1 <= 3
pageId

The question page to add to (each element in listSurveyElements carries its page_id). Leave it out to add to the last page.

string
nullable

Questions added

Media typeapplication/json
object
success
boolean
data
object
surveyId
string
questions

Each question added, in the request’s order, with its new element id and the page it is on.

Array<object>
object
elementId
string
pageId
string
type
string
text
string
meta

Standard response metadata

object
timestamp

Response timestamp in ISO 8601 format

string format: date-time
version

API version

string
requestId

Unique request identifier

string
etag

The resource’s ETag, on a read, create or update of a survey, element, rating or NPS question, distributor or contact. The same value as the ETag response header. Treat it as opaque and send it back as If-Match on the next update.

string
Example
{
"success": true,
"meta": {
"version": "3.0"
}
}

Forbidden: the token or its owner may not edit this survey; or (error code quota_exceeded; details give limit, requested and required_plan) the survey would hold more questions than the plan allows. Nothing is written.

Media typeapplication/json

Standard error response format

object
success
boolean
error
object
code

Stable, snake_case domain code – see ApiErrorHandler::EXCEPTION_MAP and DomainException

string
message

Human-readable error message

string
suggestion

Imperative recovery hint for this domain code – see ApiErrorHandler::DOMAIN_CODE_SUGGESTIONS

string
retryable

Whether retrying the identical request might succeed without any change on the caller’s end

boolean
details

Additional, code-specific error details

object
meta

Standard response metadata

object
timestamp

Response timestamp in ISO 8601 format

string format: date-time
version

API version

string
requestId

Unique request identifier

string
etag

The resource’s ETag, on a read, create or update of a survey, element, rating or NPS question, distributor or contact. The same value as the ETag response header. Treat it as opaque and send it back as If-Match on the next update.

string
Example
{
"success": false,
"error": {
"code": "survey_not_found"
},
"meta": {
"version": "3.0"
}
}

Validation failed: questions is missing or names the questions at fault, or pageId is not one of the survey’s question pages

Media typeapplication/json

Validation error response with field-specific errors

object
success
boolean
error
object
code
string
message
string
suggestion
string
retryable
boolean
details

Field-specific validation errors

object
key
additional properties
Array<string>
meta

Standard response metadata

object
timestamp

Response timestamp in ISO 8601 format

string format: date-time
version

API version

string
requestId

Unique request identifier

string
etag

The resource’s ETag, on a read, create or update of a survey, element, rating or NPS question, distributor or contact. The same value as the ETag response header. Treat it as opaque and send it back as If-Match on the next update.

string
Example
{
"success": false,
"error": {
"code": "validation_failed",
"message": "Validation failed",
"suggestion": "Fix the fields listed in details and re-submit.",
"retryable": false
},
"meta": {
"version": "3.0"
}
}