Create a Block
Creates a Block or Page. Pages are supported only for SURVEY Studies, not IN_PRODUCT_SURVEY Studies. skipLogic and displayLogic on the Block are the group rules. Question responses keep only member rules: display logic that is not owned by the group, and skip logic only when the Question is not in a Page.
curl --request POST \
--url https://api.sprig.com/v2/studies/{studyId}/blocks \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--header 'If-Match: <if-match>' \
--data '
{
"name": "<string>",
"label": "<string>",
"displayLogic": {
"source": {
"type": "QUESTION_RESPONSE",
"question": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
}
},
"value": "<string>"
},
"skipLogic": [
{
"when": {
"source": {
"type": "QUESTION_RESPONSE",
"question": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
}
},
"value": "<string>"
},
"destination": {
"type": "END"
}
}
],
"randomizePosition": true,
"subsetCount": 2,
"displayAsPage": false
}
'import requests
url = "https://api.sprig.com/v2/studies/{studyId}/blocks"
payload = {
"name": "<string>",
"label": "<string>",
"displayLogic": {
"source": {
"type": "QUESTION_RESPONSE",
"question": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
}
},
"value": "<string>"
},
"skipLogic": [
{
"when": {
"source": {
"type": "QUESTION_RESPONSE",
"question": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
}
},
"value": "<string>"
},
"destination": { "type": "END" }
}
],
"randomizePosition": True,
"subsetCount": 2,
"displayAsPage": False
}
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({
name: '<string>',
label: '<string>',
displayLogic: {
source: {
type: 'QUESTION_RESPONSE',
question: {id: '3c90c3cc-0d44-4b50-8888-8dd25736052a', name: '<string>'}
},
value: '<string>'
},
skipLogic: [
{
when: {
source: {
type: 'QUESTION_RESPONSE',
question: {id: '3c90c3cc-0d44-4b50-8888-8dd25736052a', name: '<string>'}
},
value: '<string>'
},
destination: {type: 'END'}
}
],
randomizePosition: true,
subsetCount: 2,
displayAsPage: false
})
};
fetch('https://api.sprig.com/v2/studies/{studyId}/blocks', 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}/blocks",
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([
'name' => '<string>',
'label' => '<string>',
'displayLogic' => [
'source' => [
'type' => 'QUESTION_RESPONSE',
'question' => [
'id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'name' => '<string>'
]
],
'value' => '<string>'
],
'skipLogic' => [
[
'when' => [
'source' => [
'type' => 'QUESTION_RESPONSE',
'question' => [
'id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'name' => '<string>'
]
],
'value' => '<string>'
],
'destination' => [
'type' => 'END'
]
]
],
'randomizePosition' => true,
'subsetCount' => 2,
'displayAsPage' => false
]),
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}/blocks"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"label\": \"<string>\",\n \"displayLogic\": {\n \"source\": {\n \"type\": \"QUESTION_RESPONSE\",\n \"question\": {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\"\n }\n },\n \"value\": \"<string>\"\n },\n \"skipLogic\": [\n {\n \"when\": {\n \"source\": {\n \"type\": \"QUESTION_RESPONSE\",\n \"question\": {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\"\n }\n },\n \"value\": \"<string>\"\n },\n \"destination\": {\n \"type\": \"END\"\n }\n }\n ],\n \"randomizePosition\": true,\n \"subsetCount\": 2,\n \"displayAsPage\": false\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}/blocks")
.header("If-Match", "<if-match>")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"label\": \"<string>\",\n \"displayLogic\": {\n \"source\": {\n \"type\": \"QUESTION_RESPONSE\",\n \"question\": {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\"\n }\n },\n \"value\": \"<string>\"\n },\n \"skipLogic\": [\n {\n \"when\": {\n \"source\": {\n \"type\": \"QUESTION_RESPONSE\",\n \"question\": {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\"\n }\n },\n \"value\": \"<string>\"\n },\n \"destination\": {\n \"type\": \"END\"\n }\n }\n ],\n \"randomizePosition\": true,\n \"subsetCount\": 2,\n \"displayAsPage\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sprig.com/v2/studies/{studyId}/blocks")
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 \"name\": \"<string>\",\n \"label\": \"<string>\",\n \"displayLogic\": {\n \"source\": {\n \"type\": \"QUESTION_RESPONSE\",\n \"question\": {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\"\n }\n },\n \"value\": \"<string>\"\n },\n \"skipLogic\": [\n {\n \"when\": {\n \"source\": {\n \"type\": \"QUESTION_RESPONSE\",\n \"question\": {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\"\n }\n },\n \"value\": \"<string>\"\n },\n \"destination\": {\n \"type\": \"END\"\n }\n }\n ],\n \"randomizePosition\": true,\n \"subsetCount\": 2,\n \"displayAsPage\": false\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"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"
}
}
],
"randomizePosition": true,
"subsetCount": 2,
"displayAsPage": true,
"name": "<string>",
"label": "<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
Use API-Key YOUR_API_KEY. The key selects the Production or Development environment.
Headers
Quoted Study version last read from ETag or Study.version. Required on mutating Study writes.
"\"126300\""
Path Parameters
Body
Input for creating a Block or Page in a Study.
Optional stable caller-defined name, unique among Blocks in the Study.
1 - 128Optional display label for the Block.
1 - 500Block or Page display logic. Null clears it. Omission on update preserves the stored value. Question display logic stays on the Question.
- Condition
- All of
- Any of
Show child attributes
Show child attributes
Block or Page skip logic. Null or an empty array clears it. Omission on update preserves the stored value. A Page owns skip logic for its Questions.
20Show child attributes
Show child attributes
Whether this Block moves inside its parent shuffle. Defaults to false. A subset requires every direct child to be randomized.
How many eligible direct children to show each respondent. Null clears the subset. Omission on update preserves the stored value. Eligible children are the ones delivery can leave out: a prior skip destination, display logic, and either side of carry-forward stay in the survey and do not count. The value must be from 1 to one less than that eligible count. Setting it randomizes every direct child.
x >= 1Places the Block before or after an anchor Question or Block. BEFORE a Block uses that Block's slot. AFTER a Block lands after its subtree. With member Questions and a Question anchor, the Block takes the slot immediately before the first member. The anchor Question's Block, or a Block anchor's parent, becomes this Block's parent.
Show child attributes
Show child attributes
When true, the Block is shown as a single Page. Membership may be empty, one Question, or many.
Response
Created
Canonical Block resource.
A single typed condition. Operators that inspect answer state omit value; choice comparisons use immutable Option values.
- Condition
- All of
- Any of
Show child attributes
Show child attributes
Ordered skip rules, limited to 20. An empty array clears skip logic.
20Show child attributes
Show child attributes
x >= 1Was this page helpful?
curl --request POST \
--url https://api.sprig.com/v2/studies/{studyId}/blocks \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--header 'If-Match: <if-match>' \
--data '
{
"name": "<string>",
"label": "<string>",
"displayLogic": {
"source": {
"type": "QUESTION_RESPONSE",
"question": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
}
},
"value": "<string>"
},
"skipLogic": [
{
"when": {
"source": {
"type": "QUESTION_RESPONSE",
"question": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
}
},
"value": "<string>"
},
"destination": {
"type": "END"
}
}
],
"randomizePosition": true,
"subsetCount": 2,
"displayAsPage": false
}
'import requests
url = "https://api.sprig.com/v2/studies/{studyId}/blocks"
payload = {
"name": "<string>",
"label": "<string>",
"displayLogic": {
"source": {
"type": "QUESTION_RESPONSE",
"question": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
}
},
"value": "<string>"
},
"skipLogic": [
{
"when": {
"source": {
"type": "QUESTION_RESPONSE",
"question": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
}
},
"value": "<string>"
},
"destination": { "type": "END" }
}
],
"randomizePosition": True,
"subsetCount": 2,
"displayAsPage": False
}
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({
name: '<string>',
label: '<string>',
displayLogic: {
source: {
type: 'QUESTION_RESPONSE',
question: {id: '3c90c3cc-0d44-4b50-8888-8dd25736052a', name: '<string>'}
},
value: '<string>'
},
skipLogic: [
{
when: {
source: {
type: 'QUESTION_RESPONSE',
question: {id: '3c90c3cc-0d44-4b50-8888-8dd25736052a', name: '<string>'}
},
value: '<string>'
},
destination: {type: 'END'}
}
],
randomizePosition: true,
subsetCount: 2,
displayAsPage: false
})
};
fetch('https://api.sprig.com/v2/studies/{studyId}/blocks', 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}/blocks",
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([
'name' => '<string>',
'label' => '<string>',
'displayLogic' => [
'source' => [
'type' => 'QUESTION_RESPONSE',
'question' => [
'id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'name' => '<string>'
]
],
'value' => '<string>'
],
'skipLogic' => [
[
'when' => [
'source' => [
'type' => 'QUESTION_RESPONSE',
'question' => [
'id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'name' => '<string>'
]
],
'value' => '<string>'
],
'destination' => [
'type' => 'END'
]
]
],
'randomizePosition' => true,
'subsetCount' => 2,
'displayAsPage' => false
]),
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}/blocks"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"label\": \"<string>\",\n \"displayLogic\": {\n \"source\": {\n \"type\": \"QUESTION_RESPONSE\",\n \"question\": {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\"\n }\n },\n \"value\": \"<string>\"\n },\n \"skipLogic\": [\n {\n \"when\": {\n \"source\": {\n \"type\": \"QUESTION_RESPONSE\",\n \"question\": {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\"\n }\n },\n \"value\": \"<string>\"\n },\n \"destination\": {\n \"type\": \"END\"\n }\n }\n ],\n \"randomizePosition\": true,\n \"subsetCount\": 2,\n \"displayAsPage\": false\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}/blocks")
.header("If-Match", "<if-match>")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"label\": \"<string>\",\n \"displayLogic\": {\n \"source\": {\n \"type\": \"QUESTION_RESPONSE\",\n \"question\": {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\"\n }\n },\n \"value\": \"<string>\"\n },\n \"skipLogic\": [\n {\n \"when\": {\n \"source\": {\n \"type\": \"QUESTION_RESPONSE\",\n \"question\": {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\"\n }\n },\n \"value\": \"<string>\"\n },\n \"destination\": {\n \"type\": \"END\"\n }\n }\n ],\n \"randomizePosition\": true,\n \"subsetCount\": 2,\n \"displayAsPage\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sprig.com/v2/studies/{studyId}/blocks")
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 \"name\": \"<string>\",\n \"label\": \"<string>\",\n \"displayLogic\": {\n \"source\": {\n \"type\": \"QUESTION_RESPONSE\",\n \"question\": {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\"\n }\n },\n \"value\": \"<string>\"\n },\n \"skipLogic\": [\n {\n \"when\": {\n \"source\": {\n \"type\": \"QUESTION_RESPONSE\",\n \"question\": {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\"\n }\n },\n \"value\": \"<string>\"\n },\n \"destination\": {\n \"type\": \"END\"\n }\n }\n ],\n \"randomizePosition\": true,\n \"subsetCount\": 2,\n \"displayAsPage\": false\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"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"
}
}
],
"randomizePosition": true,
"subsetCount": 2,
"displayAsPage": true,
"name": "<string>",
"label": "<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>"
}
}
]
}