Questions
Create a Question
Creates a Question, with its options, nested under the given Study.
POST
/
v2
/
studies
/
{studyId}
/
questions
Create a Question
curl --request POST \
--url https://api.sprig.com/v2/studies/{studyId}/questions \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--header 'If-Match: <if-match>' \
--data '
{
"title": {
"html": "<string>",
"variables": {}
},
"type": "OPEN_TEXT",
"name": "<string>",
"required": false,
"randomizePosition": true,
"blockId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"responsePlaceholder": "<string>"
}
'import requests
url = "https://api.sprig.com/v2/studies/{studyId}/questions"
payload = {
"title": {
"html": "<string>",
"variables": {}
},
"type": "OPEN_TEXT",
"name": "<string>",
"required": False,
"randomizePosition": True,
"blockId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"responsePlaceholder": "<string>"
}
headers = {
"If-Match": "<if-match>",
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'If-Match': '<if-match>',
Authorization: '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
title: {html: '<string>', variables: {}},
type: 'OPEN_TEXT',
name: '<string>',
required: false,
randomizePosition: true,
blockId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
responsePlaceholder: '<string>'
})
};
fetch('https://api.sprig.com/v2/studies/{studyId}/questions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sprig.com/v2/studies/{studyId}/questions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'title' => [
'html' => '<string>',
'variables' => [
]
],
'type' => 'OPEN_TEXT',
'name' => '<string>',
'required' => false,
'randomizePosition' => true,
'blockId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'responsePlaceholder' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json",
"If-Match: <if-match>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sprig.com/v2/studies/{studyId}/questions"
payload := strings.NewReader("{\n \"title\": {\n \"html\": \"<string>\",\n \"variables\": {}\n },\n \"type\": \"OPEN_TEXT\",\n \"name\": \"<string>\",\n \"required\": false,\n \"randomizePosition\": true,\n \"blockId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"responsePlaceholder\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("If-Match", "<if-match>")
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sprig.com/v2/studies/{studyId}/questions")
.header("If-Match", "<if-match>")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"title\": {\n \"html\": \"<string>\",\n \"variables\": {}\n },\n \"type\": \"OPEN_TEXT\",\n \"name\": \"<string>\",\n \"required\": false,\n \"randomizePosition\": true,\n \"blockId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"responsePlaceholder\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sprig.com/v2/studies/{studyId}/questions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["If-Match"] = '<if-match>'
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"title\": {\n \"html\": \"<string>\",\n \"variables\": {}\n },\n \"type\": \"OPEN_TEXT\",\n \"name\": \"<string>\",\n \"required\": false,\n \"randomizePosition\": true,\n \"blockId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"responsePlaceholder\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"title": {
"html": "<string>",
"variables": {}
},
"required": true,
"displayLogic": {
"source": {
"type": "QUESTION_RESPONSE",
"question": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
}
},
"operator": "EQUALS",
"value": "<string>"
},
"skipLogic": [
{
"when": {
"source": {
"type": "QUESTION_RESPONSE",
"question": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
}
},
"operator": "EQUALS",
"value": "<string>"
},
"destination": {
"type": "END"
}
}
],
"aiFollowUp": {
"userPrompt": "<string>"
},
"randomizePosition": true,
"type": "OPEN_TEXT",
"name": "<string>",
"description": {
"html": "<string>",
"variables": {}
},
"image": {
"url": "<string>",
"altText": "<string>",
"displaySize": "FIT",
"alignment": "LEFT",
"width": 123,
"height": 123,
"mediaType": "image/gif",
"originalFilename": "<string>",
"assetId": "<string>"
},
"responsePlaceholder": "<string>"
}{
"code": "<string>",
"message": "<string>",
"errors": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"resource": {
"type": "<string>",
"id": "<string>"
}
}
]
}{
"code": "<string>",
"message": "<string>",
"errors": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"resource": {
"type": "<string>",
"id": "<string>"
}
}
]
}{
"code": "<string>",
"message": "<string>",
"errors": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"resource": {
"type": "<string>",
"id": "<string>"
}
}
]
}{
"code": "<string>",
"message": "<string>",
"errors": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"resource": {
"type": "<string>",
"id": "<string>"
}
}
]
}{
"code": "<string>",
"message": "<string>",
"errors": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"resource": {
"type": "<string>",
"id": "<string>"
}
}
]
}{
"code": "<string>",
"message": "<string>",
"errors": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"resource": {
"type": "<string>",
"id": "<string>"
}
}
]
}Authorizations
Headers
Body
application/json
- Open text
- Single select
- Multiple select
- Rating scale
- NPS
- Validated text
- Rank order
- Matrix
- MaxDiff
- Text / URL prompt
- Consent / legal
- AI dynamic
- Conjoint
- File upload
Supported Question input for the Study creation API.
Response
Created
- Open text
- AI dynamic
- Single select
- Multiple select
- Rating scale
- NPS
- Validated text
- Rank order
- Matrix
- MaxDiff
- Text / URL prompt
- Consent / legal
- Conjoint
- File upload
Canonical Question resource.
Was this page helpful?
⌘I
Create a Question
curl --request POST \
--url https://api.sprig.com/v2/studies/{studyId}/questions \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--header 'If-Match: <if-match>' \
--data '
{
"title": {
"html": "<string>",
"variables": {}
},
"type": "OPEN_TEXT",
"name": "<string>",
"required": false,
"randomizePosition": true,
"blockId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"responsePlaceholder": "<string>"
}
'import requests
url = "https://api.sprig.com/v2/studies/{studyId}/questions"
payload = {
"title": {
"html": "<string>",
"variables": {}
},
"type": "OPEN_TEXT",
"name": "<string>",
"required": False,
"randomizePosition": True,
"blockId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"responsePlaceholder": "<string>"
}
headers = {
"If-Match": "<if-match>",
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'If-Match': '<if-match>',
Authorization: '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
title: {html: '<string>', variables: {}},
type: 'OPEN_TEXT',
name: '<string>',
required: false,
randomizePosition: true,
blockId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
responsePlaceholder: '<string>'
})
};
fetch('https://api.sprig.com/v2/studies/{studyId}/questions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sprig.com/v2/studies/{studyId}/questions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'title' => [
'html' => '<string>',
'variables' => [
]
],
'type' => 'OPEN_TEXT',
'name' => '<string>',
'required' => false,
'randomizePosition' => true,
'blockId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'responsePlaceholder' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json",
"If-Match: <if-match>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sprig.com/v2/studies/{studyId}/questions"
payload := strings.NewReader("{\n \"title\": {\n \"html\": \"<string>\",\n \"variables\": {}\n },\n \"type\": \"OPEN_TEXT\",\n \"name\": \"<string>\",\n \"required\": false,\n \"randomizePosition\": true,\n \"blockId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"responsePlaceholder\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("If-Match", "<if-match>")
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sprig.com/v2/studies/{studyId}/questions")
.header("If-Match", "<if-match>")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"title\": {\n \"html\": \"<string>\",\n \"variables\": {}\n },\n \"type\": \"OPEN_TEXT\",\n \"name\": \"<string>\",\n \"required\": false,\n \"randomizePosition\": true,\n \"blockId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"responsePlaceholder\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sprig.com/v2/studies/{studyId}/questions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["If-Match"] = '<if-match>'
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"title\": {\n \"html\": \"<string>\",\n \"variables\": {}\n },\n \"type\": \"OPEN_TEXT\",\n \"name\": \"<string>\",\n \"required\": false,\n \"randomizePosition\": true,\n \"blockId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"responsePlaceholder\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"title": {
"html": "<string>",
"variables": {}
},
"required": true,
"displayLogic": {
"source": {
"type": "QUESTION_RESPONSE",
"question": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
}
},
"operator": "EQUALS",
"value": "<string>"
},
"skipLogic": [
{
"when": {
"source": {
"type": "QUESTION_RESPONSE",
"question": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
}
},
"operator": "EQUALS",
"value": "<string>"
},
"destination": {
"type": "END"
}
}
],
"aiFollowUp": {
"userPrompt": "<string>"
},
"randomizePosition": true,
"type": "OPEN_TEXT",
"name": "<string>",
"description": {
"html": "<string>",
"variables": {}
},
"image": {
"url": "<string>",
"altText": "<string>",
"displaySize": "FIT",
"alignment": "LEFT",
"width": 123,
"height": 123,
"mediaType": "image/gif",
"originalFilename": "<string>",
"assetId": "<string>"
},
"responsePlaceholder": "<string>"
}{
"code": "<string>",
"message": "<string>",
"errors": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"resource": {
"type": "<string>",
"id": "<string>"
}
}
]
}{
"code": "<string>",
"message": "<string>",
"errors": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"resource": {
"type": "<string>",
"id": "<string>"
}
}
]
}{
"code": "<string>",
"message": "<string>",
"errors": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"resource": {
"type": "<string>",
"id": "<string>"
}
}
]
}{
"code": "<string>",
"message": "<string>",
"errors": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"resource": {
"type": "<string>",
"id": "<string>"
}
}
]
}{
"code": "<string>",
"message": "<string>",
"errors": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"resource": {
"type": "<string>",
"id": "<string>"
}
}
]
}{
"code": "<string>",
"message": "<string>",
"errors": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"resource": {
"type": "<string>",
"id": "<string>"
}
}
]
}