curl --request PATCH \
--url https://api.statisfy.com/v1/surveys/{survey_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"creator": null,
"definition": {
"pages": [
{
"elements": [
{
"isRequired": true,
"name": "nps",
"rateMax": 10,
"rateMin": 0,
"title": "How likely are you to recommend us?",
"type": "rating"
},
{
"name": "reason",
"title": "What is the main reason for your score?",
"type": "comment"
}
],
"name": "page1"
}
]
},
"description": null,
"email": null,
"state": null,
"theme": null,
"title": null,
"type": null
}
'import requests
url = "https://api.statisfy.com/v1/surveys/{survey_id}"
payload = {
"creator": None,
"definition": { "pages": [
{
"elements": [
{
"isRequired": True,
"name": "nps",
"rateMax": 10,
"rateMin": 0,
"title": "How likely are you to recommend us?",
"type": "rating"
},
{
"name": "reason",
"title": "What is the main reason for your score?",
"type": "comment"
}
],
"name": "page1"
}
] },
"description": None,
"email": None,
"state": None,
"theme": None,
"title": None,
"type": None
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
creator: null,
definition: {
pages: [
{
elements: [
{
isRequired: true,
name: 'nps',
rateMax: 10,
rateMin: 0,
title: 'How likely are you to recommend us?',
type: 'rating'
},
{
name: 'reason',
title: 'What is the main reason for your score?',
type: 'comment'
}
],
name: 'page1'
}
]
},
description: null,
email: null,
state: null,
theme: null,
title: null,
type: null
})
};
fetch('https://api.statisfy.com/v1/surveys/{survey_id}', 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.statisfy.com/v1/surveys/{survey_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'creator' => null,
'definition' => [
'pages' => [
[
'elements' => [
[
'isRequired' => true,
'name' => 'nps',
'rateMax' => 10,
'rateMin' => 0,
'title' => 'How likely are you to recommend us?',
'type' => 'rating'
],
[
'name' => 'reason',
'title' => 'What is the main reason for your score?',
'type' => 'comment'
]
],
'name' => 'page1'
]
]
],
'description' => null,
'email' => null,
'state' => null,
'theme' => null,
'title' => null,
'type' => null
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.statisfy.com/v1/surveys/{survey_id}"
payload := strings.NewReader("{\n \"creator\": null,\n \"definition\": {\n \"pages\": [\n {\n \"elements\": [\n {\n \"isRequired\": true,\n \"name\": \"nps\",\n \"rateMax\": 10,\n \"rateMin\": 0,\n \"title\": \"How likely are you to recommend us?\",\n \"type\": \"rating\"\n },\n {\n \"name\": \"reason\",\n \"title\": \"What is the main reason for your score?\",\n \"type\": \"comment\"\n }\n ],\n \"name\": \"page1\"\n }\n ]\n },\n \"description\": null,\n \"email\": null,\n \"state\": null,\n \"theme\": null,\n \"title\": null,\n \"type\": null\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.patch("https://api.statisfy.com/v1/surveys/{survey_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"creator\": null,\n \"definition\": {\n \"pages\": [\n {\n \"elements\": [\n {\n \"isRequired\": true,\n \"name\": \"nps\",\n \"rateMax\": 10,\n \"rateMin\": 0,\n \"title\": \"How likely are you to recommend us?\",\n \"type\": \"rating\"\n },\n {\n \"name\": \"reason\",\n \"title\": \"What is the main reason for your score?\",\n \"type\": \"comment\"\n }\n ],\n \"name\": \"page1\"\n }\n ]\n },\n \"description\": null,\n \"email\": null,\n \"state\": null,\n \"theme\": null,\n \"title\": null,\n \"type\": null\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.statisfy.com/v1/surveys/{survey_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"creator\": null,\n \"definition\": {\n \"pages\": [\n {\n \"elements\": [\n {\n \"isRequired\": true,\n \"name\": \"nps\",\n \"rateMax\": 10,\n \"rateMin\": 0,\n \"title\": \"How likely are you to recommend us?\",\n \"type\": \"rating\"\n },\n {\n \"name\": \"reason\",\n \"title\": \"What is the main reason for your score?\",\n \"type\": \"comment\"\n }\n ],\n \"name\": \"page1\"\n }\n ]\n },\n \"description\": null,\n \"email\": null,\n \"state\": null,\n \"theme\": null,\n \"title\": null,\n \"type\": null\n}"
response = http.request(request)
puts response.read_body{
"created_at": "2023-11-07T05:31:56Z",
"definition": {},
"description": "<string>",
"email": {
"editor": "simple",
"html": "<string>",
"sender_email": "<string>",
"sender_name": "<string>",
"subject": "<string>"
},
"id": "<string>",
"state": "draft",
"theme": {},
"title": "<string>",
"type": "<string>",
"updated_at": "2023-11-07T05:31:56Z"
}Change or publish a survey
Changes what you send of a draft survey: its title, type, description, questions, theme or email, and publishes it with state: published. A published survey is locked (a 409): duplicate it to change it. A title another survey has, a deleted one included, returns 409. Publishing without an email or a question returns 422.
curl --request PATCH \
--url https://api.statisfy.com/v1/surveys/{survey_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"creator": null,
"definition": {
"pages": [
{
"elements": [
{
"isRequired": true,
"name": "nps",
"rateMax": 10,
"rateMin": 0,
"title": "How likely are you to recommend us?",
"type": "rating"
},
{
"name": "reason",
"title": "What is the main reason for your score?",
"type": "comment"
}
],
"name": "page1"
}
]
},
"description": null,
"email": null,
"state": null,
"theme": null,
"title": null,
"type": null
}
'import requests
url = "https://api.statisfy.com/v1/surveys/{survey_id}"
payload = {
"creator": None,
"definition": { "pages": [
{
"elements": [
{
"isRequired": True,
"name": "nps",
"rateMax": 10,
"rateMin": 0,
"title": "How likely are you to recommend us?",
"type": "rating"
},
{
"name": "reason",
"title": "What is the main reason for your score?",
"type": "comment"
}
],
"name": "page1"
}
] },
"description": None,
"email": None,
"state": None,
"theme": None,
"title": None,
"type": None
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
creator: null,
definition: {
pages: [
{
elements: [
{
isRequired: true,
name: 'nps',
rateMax: 10,
rateMin: 0,
title: 'How likely are you to recommend us?',
type: 'rating'
},
{
name: 'reason',
title: 'What is the main reason for your score?',
type: 'comment'
}
],
name: 'page1'
}
]
},
description: null,
email: null,
state: null,
theme: null,
title: null,
type: null
})
};
fetch('https://api.statisfy.com/v1/surveys/{survey_id}', 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.statisfy.com/v1/surveys/{survey_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'creator' => null,
'definition' => [
'pages' => [
[
'elements' => [
[
'isRequired' => true,
'name' => 'nps',
'rateMax' => 10,
'rateMin' => 0,
'title' => 'How likely are you to recommend us?',
'type' => 'rating'
],
[
'name' => 'reason',
'title' => 'What is the main reason for your score?',
'type' => 'comment'
]
],
'name' => 'page1'
]
]
],
'description' => null,
'email' => null,
'state' => null,
'theme' => null,
'title' => null,
'type' => null
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.statisfy.com/v1/surveys/{survey_id}"
payload := strings.NewReader("{\n \"creator\": null,\n \"definition\": {\n \"pages\": [\n {\n \"elements\": [\n {\n \"isRequired\": true,\n \"name\": \"nps\",\n \"rateMax\": 10,\n \"rateMin\": 0,\n \"title\": \"How likely are you to recommend us?\",\n \"type\": \"rating\"\n },\n {\n \"name\": \"reason\",\n \"title\": \"What is the main reason for your score?\",\n \"type\": \"comment\"\n }\n ],\n \"name\": \"page1\"\n }\n ]\n },\n \"description\": null,\n \"email\": null,\n \"state\": null,\n \"theme\": null,\n \"title\": null,\n \"type\": null\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.patch("https://api.statisfy.com/v1/surveys/{survey_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"creator\": null,\n \"definition\": {\n \"pages\": [\n {\n \"elements\": [\n {\n \"isRequired\": true,\n \"name\": \"nps\",\n \"rateMax\": 10,\n \"rateMin\": 0,\n \"title\": \"How likely are you to recommend us?\",\n \"type\": \"rating\"\n },\n {\n \"name\": \"reason\",\n \"title\": \"What is the main reason for your score?\",\n \"type\": \"comment\"\n }\n ],\n \"name\": \"page1\"\n }\n ]\n },\n \"description\": null,\n \"email\": null,\n \"state\": null,\n \"theme\": null,\n \"title\": null,\n \"type\": null\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.statisfy.com/v1/surveys/{survey_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"creator\": null,\n \"definition\": {\n \"pages\": [\n {\n \"elements\": [\n {\n \"isRequired\": true,\n \"name\": \"nps\",\n \"rateMax\": 10,\n \"rateMin\": 0,\n \"title\": \"How likely are you to recommend us?\",\n \"type\": \"rating\"\n },\n {\n \"name\": \"reason\",\n \"title\": \"What is the main reason for your score?\",\n \"type\": \"comment\"\n }\n ],\n \"name\": \"page1\"\n }\n ]\n },\n \"description\": null,\n \"email\": null,\n \"state\": null,\n \"theme\": null,\n \"title\": null,\n \"type\": null\n}"
response = http.request(request)
puts response.read_body{
"created_at": "2023-11-07T05:31:56Z",
"definition": {},
"description": "<string>",
"email": {
"editor": "simple",
"html": "<string>",
"sender_email": "<string>",
"sender_name": "<string>",
"subject": "<string>"
},
"id": "<string>",
"state": "draft",
"theme": {},
"title": "<string>",
"type": "<string>",
"updated_at": "2023-11-07T05:31:56Z"
}Authorizations
An API key, sent as Authorization: Bearer stfy_live_…. See Authentication for how to get one and which scopes it needs.
Body
The survey's questions and pages: the SurveyJS JSON the app's survey builder saves (https://help.statisfy.com/rest-api/survey_definition). Elements sit in pages[].elements (or top-level elements) and in panels' elements; panels nest at most 10 deep. An element's type is one of boolean, checkbox, comment, dropdown, expression, file, html, image, imagepicker, matrix, matrixdropdown, matrixdynamic, multipletext, panel, paneldynamic, radiogroup, ranking, rating, signaturepad, tagbox, text. A question's name is the key its answers carry, so every question needs one and names must be unique. At most 1,000,000 characters as JSON. HTML in it (html elements, completedHtml) is stored as sent and cleaned where the survey renders
{
"pages": [
{
"elements": [
{
"isRequired": true,
"name": "nps",
"rateMax": 10,
"rateMin": 0,
"title": "How likely are you to recommend us?",
"type": "rating"
},
{
"name": "reason",
"title": "What is the main reason for your score?",
"type": "comment"
}
],
"name": "page1"
}
]
}
The SurveyJS theme JSON the app's survey builder saves (https://help.statisfy.com/rest-api/survey_definition#theme)
Response
Successful Response
The survey's questions and pages: the SurveyJS JSON the app's survey builder saves (https://help.statisfy.com/rest-api/survey_definition). Elements sit in pages[].elements (or top-level elements) and in panels' elements; panels nest at most 10 deep. An element's type is one of boolean, checkbox, comment, dropdown, expression, file, html, image, imagepicker, matrix, matrixdropdown, matrixdynamic, multipletext, panel, paneldynamic, radiogroup, ranking, rating, signaturepad, tagbox, text. A question's name is the key its answers carry, so every question needs one and names must be unique. At most 1,000,000 characters as JSON. HTML in it (html elements, completedHtml) is stored as sent and cleaned where the survey renders
The SurveyJS theme JSON the app's survey builder saves (https://help.statisfy.com/rest-api/survey_definition#theme)
Was this page helpful?