Update Survey
curl --request PUT \
--url https://{baseurl}/api/v1/management/surveys/{surveyId} \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"name": "Example Survey"
}
'import requests
url = "https://{baseurl}/api/v1/management/surveys/{surveyId}"
payload = { "name": "Example Survey" }
headers = {
"x-api-key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'x-api-key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: 'Example Survey'})
};
fetch('https://{baseurl}/api/v1/management/surveys/{surveyId}', 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://{baseurl}/api/v1/management/surveys/{surveyId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Example Survey'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <x-api-key>"
],
]);
$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://{baseurl}/api/v1/management/surveys/{surveyId}"
payload := strings.NewReader("{\n \"name\": \"Example Survey\"\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("x-api-key", "<x-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.put("https://{baseurl}/api/v1/management/surveys/{surveyId}")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Example Survey\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{baseurl}/api/v1/management/surveys/{surveyId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["x-api-key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Example Survey\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"autoClose": null,
"autoComplete": null,
"blocks": [
{
"elements": [
{
"headline": {
"default": "What would you like to know?"
},
"id": "ovpy6va1hab7fl12n913zua0",
"inputType": "text",
"placeholder": {
"default": "Type your answer here..."
},
"required": true,
"subheader": {
"default": "This is an example survey."
},
"type": "openText"
}
],
"id": "qp8j2k0fx3m9wd1c7b5n4tva",
"name": "Block 1"
},
{
"elements": [
{
"choices": [
{
"id": "xpoxuu3sifk1ee8he67ctf5i",
"label": {
"default": "Sun ☀️"
}
},
{
"id": "hnsovcdmxtcbly6tig1az3qc",
"label": {
"default": "Ocean 🌊"
}
},
{
"id": "kcnelzdxknvwo8fq20d3nrr5",
"label": {
"default": "Palms 🌴"
}
}
],
"headline": {
"default": "What's important on vacay?"
},
"id": "awkn2llljy7a4oulp5t15yec",
"required": true,
"shuffleOption": "none",
"type": "multipleChoiceMulti"
}
],
"id": "rk4v9m2dqz7n0fyt8c3b1xws",
"name": "Block 2"
}
],
"createdAt": "2024-08-05T11:08:27.042Z",
"createdBy": "clfv1zvij0000ru0gunwpy43a",
"delay": 0,
"displayLimit": null,
"displayOption": "displayOnce",
"displayPercentage": null,
"endings": [
{
"buttonLabel": {
"default": "Create your own Survey"
},
"buttonLink": "https://formbricks.com/signup",
"headline": {
"default": "Thank you!"
},
"id": "p73t62dgwq0cvmtt6ug0hmfc",
"subheader": {
"default": "We appreciate your feedback."
},
"type": "endScreen"
}
],
"hiddenFields": {
"enabled": false,
"fieldIds": []
},
"id": "clzgw1k4i0001mny1unf8eggn",
"isVerifyEmailEnabled": false,
"languages": [],
"name": "Example Survey",
"pin": null,
"productOverwrites": null,
"questions": [
{
"headline": {
"default": "What would you like to know?"
},
"id": "ovpy6va1hab7fl12n913zua0",
"inputType": "text",
"placeholder": {
"default": "Type your answer here..."
},
"required": true,
"subheader": {
"default": "This is an example survey."
},
"type": "openText"
},
{
"choices": [
{
"id": "xpoxuu3sifk1ee8he67ctf5i",
"label": {
"default": "Sun ☀️"
}
},
{
"id": "hnsovcdmxtcbly6tig1az3qc",
"label": {
"default": "Ocean 🌊"
}
},
{
"id": "kcnelzdxknvwo8fq20d3nrr5",
"label": {
"default": "Palms 🌴"
}
}
],
"headline": {
"default": "What's important on vacay?"
},
"id": "awkn2llljy7a4oulp5t15yec",
"required": true,
"shuffleOption": "none",
"type": "multipleChoiceMulti"
}
],
"recontactDays": null,
"redirectUrl": null,
"segment": null,
"showLanguageSwitch": null,
"singleUse": {
"enabled": false,
"isEncrypted": true
},
"status": "inProgress",
"styling": null,
"surveyClosedMessage": null,
"triggers": [],
"type": "link",
"updatedAt": "2024-08-05T11:09:21.826Z",
"welcomeCard": {
"enabled": true,
"fileUrl": "",
"headline": {
"default": "Welcome!"
},
"html": {
"default": "<p class=\"fb-editor-paragraph\" dir=\"ltr\"><span style=\"white-space: pre-wrap;\">Thanks for providing your feedback - let's go!</span></p>"
},
"showResponseCount": false,
"timeToFinish": false
},
"workspaceId": "clygwxsbh01v5aga1sdien2th"
}
}{
"code": "bad_request",
"details": {},
"message": "Survey with ID cls79mi7j0000hq9o4dd60xsk not found"
}Management API - Survey
Update Survey
Update an existing survey with new properties. This is also what we’d recommend you to do from the UI for a better visual feedback.
PUT
/
api
/
v1
/
management
/
surveys
/
{surveyId}
Update Survey
curl --request PUT \
--url https://{baseurl}/api/v1/management/surveys/{surveyId} \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"name": "Example Survey"
}
'import requests
url = "https://{baseurl}/api/v1/management/surveys/{surveyId}"
payload = { "name": "Example Survey" }
headers = {
"x-api-key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'x-api-key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: 'Example Survey'})
};
fetch('https://{baseurl}/api/v1/management/surveys/{surveyId}', 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://{baseurl}/api/v1/management/surveys/{surveyId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Example Survey'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <x-api-key>"
],
]);
$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://{baseurl}/api/v1/management/surveys/{surveyId}"
payload := strings.NewReader("{\n \"name\": \"Example Survey\"\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("x-api-key", "<x-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.put("https://{baseurl}/api/v1/management/surveys/{surveyId}")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Example Survey\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{baseurl}/api/v1/management/surveys/{surveyId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["x-api-key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Example Survey\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"autoClose": null,
"autoComplete": null,
"blocks": [
{
"elements": [
{
"headline": {
"default": "What would you like to know?"
},
"id": "ovpy6va1hab7fl12n913zua0",
"inputType": "text",
"placeholder": {
"default": "Type your answer here..."
},
"required": true,
"subheader": {
"default": "This is an example survey."
},
"type": "openText"
}
],
"id": "qp8j2k0fx3m9wd1c7b5n4tva",
"name": "Block 1"
},
{
"elements": [
{
"choices": [
{
"id": "xpoxuu3sifk1ee8he67ctf5i",
"label": {
"default": "Sun ☀️"
}
},
{
"id": "hnsovcdmxtcbly6tig1az3qc",
"label": {
"default": "Ocean 🌊"
}
},
{
"id": "kcnelzdxknvwo8fq20d3nrr5",
"label": {
"default": "Palms 🌴"
}
}
],
"headline": {
"default": "What's important on vacay?"
},
"id": "awkn2llljy7a4oulp5t15yec",
"required": true,
"shuffleOption": "none",
"type": "multipleChoiceMulti"
}
],
"id": "rk4v9m2dqz7n0fyt8c3b1xws",
"name": "Block 2"
}
],
"createdAt": "2024-08-05T11:08:27.042Z",
"createdBy": "clfv1zvij0000ru0gunwpy43a",
"delay": 0,
"displayLimit": null,
"displayOption": "displayOnce",
"displayPercentage": null,
"endings": [
{
"buttonLabel": {
"default": "Create your own Survey"
},
"buttonLink": "https://formbricks.com/signup",
"headline": {
"default": "Thank you!"
},
"id": "p73t62dgwq0cvmtt6ug0hmfc",
"subheader": {
"default": "We appreciate your feedback."
},
"type": "endScreen"
}
],
"hiddenFields": {
"enabled": false,
"fieldIds": []
},
"id": "clzgw1k4i0001mny1unf8eggn",
"isVerifyEmailEnabled": false,
"languages": [],
"name": "Example Survey",
"pin": null,
"productOverwrites": null,
"questions": [
{
"headline": {
"default": "What would you like to know?"
},
"id": "ovpy6va1hab7fl12n913zua0",
"inputType": "text",
"placeholder": {
"default": "Type your answer here..."
},
"required": true,
"subheader": {
"default": "This is an example survey."
},
"type": "openText"
},
{
"choices": [
{
"id": "xpoxuu3sifk1ee8he67ctf5i",
"label": {
"default": "Sun ☀️"
}
},
{
"id": "hnsovcdmxtcbly6tig1az3qc",
"label": {
"default": "Ocean 🌊"
}
},
{
"id": "kcnelzdxknvwo8fq20d3nrr5",
"label": {
"default": "Palms 🌴"
}
}
],
"headline": {
"default": "What's important on vacay?"
},
"id": "awkn2llljy7a4oulp5t15yec",
"required": true,
"shuffleOption": "none",
"type": "multipleChoiceMulti"
}
],
"recontactDays": null,
"redirectUrl": null,
"segment": null,
"showLanguageSwitch": null,
"singleUse": {
"enabled": false,
"isEncrypted": true
},
"status": "inProgress",
"styling": null,
"surveyClosedMessage": null,
"triggers": [],
"type": "link",
"updatedAt": "2024-08-05T11:09:21.826Z",
"welcomeCard": {
"enabled": true,
"fileUrl": "",
"headline": {
"default": "Welcome!"
},
"html": {
"default": "<p class=\"fb-editor-paragraph\" dir=\"ltr\"><span style=\"white-space: pre-wrap;\">Thanks for providing your feedback - let's go!</span></p>"
},
"showResponseCount": false,
"timeToFinish": false
},
"workspaceId": "clygwxsbh01v5aga1sdien2th"
}
}{
"code": "bad_request",
"details": {},
"message": "Survey with ID cls79mi7j0000hq9o4dd60xsk not found"
}Was this page helpful?
⌘I