Skip to main content
POST
/
management
/
responses
Create a response
curl --request POST \
  --url https://app.formbricks.com/api/v2/management/responses \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '
{
  "surveyId": "<string>",
  "finished": true,
  "data": {
    "question1": "answer1",
    "question2": 2,
    "question3": [
      "answer3",
      "answer4"
    ],
    "question4": {
      "subquestion1": "answer5"
    }
  },
  "createdAt": "2021-01-01T00:00:00.000Z",
  "updatedAt": "2021-01-01T00:00:00.000Z",
  "displayId": "<string>",
  "singleUseId": "<string>",
  "endingId": "<string>",
  "language": "en",
  "variables": {
    "variable1": "answer1",
    "variable2": 2
  },
  "ttc": {
    "question1": 10,
    "question2": 20
  },
  "meta": {
    "source": "https://example.com",
    "url": "https://example.com",
    "userAgent": {
      "browser": "Chrome",
      "os": "Windows",
      "device": "Desktop"
    },
    "country": "US",
    "action": "click"
  },
  "userId": "<string>"
}
'
import requests

url = "https://app.formbricks.com/api/v2/management/responses"

payload = {
"surveyId": "<string>",
"finished": True,
"data": {
"question1": "answer1",
"question2": 2,
"question3": ["answer3", "answer4"],
"question4": { "subquestion1": "answer5" }
},
"createdAt": "2021-01-01T00:00:00.000Z",
"updatedAt": "2021-01-01T00:00:00.000Z",
"displayId": "<string>",
"singleUseId": "<string>",
"endingId": "<string>",
"language": "en",
"variables": {
"variable1": "answer1",
"variable2": 2
},
"ttc": {
"question1": 10,
"question2": 20
},
"meta": {
"source": "https://example.com",
"url": "https://example.com",
"userAgent": {
"browser": "Chrome",
"os": "Windows",
"device": "Desktop"
},
"country": "US",
"action": "click"
},
"userId": "<string>"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
surveyId: '<string>',
finished: true,
data: {
question1: 'answer1',
question2: 2,
question3: ['answer3', 'answer4'],
question4: {subquestion1: 'answer5'}
},
createdAt: '2021-01-01T00:00:00.000Z',
updatedAt: '2021-01-01T00:00:00.000Z',
displayId: '<string>',
singleUseId: '<string>',
endingId: '<string>',
language: 'en',
variables: {variable1: 'answer1', variable2: 2},
ttc: {question1: 10, question2: 20},
meta: {
source: 'https://example.com',
url: 'https://example.com',
userAgent: {browser: 'Chrome', os: 'Windows', device: 'Desktop'},
country: 'US',
action: 'click'
},
userId: '<string>'
})
};

fetch('https://app.formbricks.com/api/v2/management/responses', 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://app.formbricks.com/api/v2/management/responses",
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([
'surveyId' => '<string>',
'finished' => true,
'data' => [
'question1' => 'answer1',
'question2' => 2,
'question3' => [
'answer3',
'answer4'
],
'question4' => [
'subquestion1' => 'answer5'
]
],
'createdAt' => '2021-01-01T00:00:00.000Z',
'updatedAt' => '2021-01-01T00:00:00.000Z',
'displayId' => '<string>',
'singleUseId' => '<string>',
'endingId' => '<string>',
'language' => 'en',
'variables' => [
'variable1' => 'answer1',
'variable2' => 2
],
'ttc' => [
'question1' => 10,
'question2' => 20
],
'meta' => [
'source' => 'https://example.com',
'url' => 'https://example.com',
'userAgent' => [
'browser' => 'Chrome',
'os' => 'Windows',
'device' => 'Desktop'
],
'country' => 'US',
'action' => 'click'
],
'userId' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <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://app.formbricks.com/api/v2/management/responses"

payload := strings.NewReader("{\n \"surveyId\": \"<string>\",\n \"finished\": true,\n \"data\": {\n \"question1\": \"answer1\",\n \"question2\": 2,\n \"question3\": [\n \"answer3\",\n \"answer4\"\n ],\n \"question4\": {\n \"subquestion1\": \"answer5\"\n }\n },\n \"createdAt\": \"2021-01-01T00:00:00.000Z\",\n \"updatedAt\": \"2021-01-01T00:00:00.000Z\",\n \"displayId\": \"<string>\",\n \"singleUseId\": \"<string>\",\n \"endingId\": \"<string>\",\n \"language\": \"en\",\n \"variables\": {\n \"variable1\": \"answer1\",\n \"variable2\": 2\n },\n \"ttc\": {\n \"question1\": 10,\n \"question2\": 20\n },\n \"meta\": {\n \"source\": \"https://example.com\",\n \"url\": \"https://example.com\",\n \"userAgent\": {\n \"browser\": \"Chrome\",\n \"os\": \"Windows\",\n \"device\": \"Desktop\"\n },\n \"country\": \"US\",\n \"action\": \"click\"\n },\n \"userId\": \"<string>\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("x-api-key", "<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://app.formbricks.com/api/v2/management/responses")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"surveyId\": \"<string>\",\n \"finished\": true,\n \"data\": {\n \"question1\": \"answer1\",\n \"question2\": 2,\n \"question3\": [\n \"answer3\",\n \"answer4\"\n ],\n \"question4\": {\n \"subquestion1\": \"answer5\"\n }\n },\n \"createdAt\": \"2021-01-01T00:00:00.000Z\",\n \"updatedAt\": \"2021-01-01T00:00:00.000Z\",\n \"displayId\": \"<string>\",\n \"singleUseId\": \"<string>\",\n \"endingId\": \"<string>\",\n \"language\": \"en\",\n \"variables\": {\n \"variable1\": \"answer1\",\n \"variable2\": 2\n },\n \"ttc\": {\n \"question1\": 10,\n \"question2\": 20\n },\n \"meta\": {\n \"source\": \"https://example.com\",\n \"url\": \"https://example.com\",\n \"userAgent\": {\n \"browser\": \"Chrome\",\n \"os\": \"Windows\",\n \"device\": \"Desktop\"\n },\n \"country\": \"US\",\n \"action\": \"click\"\n },\n \"userId\": \"<string>\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://app.formbricks.com/api/v2/management/responses")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"surveyId\": \"<string>\",\n \"finished\": true,\n \"data\": {\n \"question1\": \"answer1\",\n \"question2\": 2,\n \"question3\": [\n \"answer3\",\n \"answer4\"\n ],\n \"question4\": {\n \"subquestion1\": \"answer5\"\n }\n },\n \"createdAt\": \"2021-01-01T00:00:00.000Z\",\n \"updatedAt\": \"2021-01-01T00:00:00.000Z\",\n \"displayId\": \"<string>\",\n \"singleUseId\": \"<string>\",\n \"endingId\": \"<string>\",\n \"language\": \"en\",\n \"variables\": {\n \"variable1\": \"answer1\",\n \"variable2\": 2\n },\n \"ttc\": {\n \"question1\": 10,\n \"question2\": 20\n },\n \"meta\": {\n \"source\": \"https://example.com\",\n \"url\": \"https://example.com\",\n \"userAgent\": {\n \"browser\": \"Chrome\",\n \"os\": \"Windows\",\n \"device\": \"Desktop\"\n },\n \"country\": \"US\",\n \"action\": \"click\"\n },\n \"userId\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body
{
  "id": "<string>",
  "createdAt": "2021-01-01T00:00:00.000Z",
  "updatedAt": "2021-01-01T00:00:00.000Z",
  "finished": true,
  "surveyId": "<string>",
  "contactId": "<string>",
  "endingId": "<string>",
  "data": {
    "question1": "answer1",
    "question2": 2,
    "question3": [
      "answer3",
      "answer4"
    ],
    "question4": {
      "subquestion1": "answer5"
    }
  },
  "variables": {
    "variable1": "answer1",
    "variable2": 2
  },
  "ttc": {
    "question1": 10,
    "question2": 20
  },
  "meta": {
    "source": "https://example.com",
    "url": "https://example.com",
    "userAgent": {
      "browser": "Chrome",
      "os": "Windows",
      "device": "Desktop"
    },
    "country": "US",
    "action": "click"
  },
  "contactAttributes": {
    "attribute1": "value1",
    "attribute2": "value2"
  },
  "singleUseId": "<string>",
  "language": "en",
  "displayId": "<string>"
}

Authorizations

x-api-key
string
header
required

Use your Formbricks x-api-key to authenticate.

Body

application/json

The response to create

surveyId
string
required

The ID of the survey

finished
boolean
required

Whether the response is finished

Example:

true

data
object
required

The data of the response

Example:
{
"question1": "answer1",
"question2": 2,
"question3": ["answer3", "answer4"],
"question4": { "subquestion1": "answer5" }
}
createdAt
string

The date and time the response was created

Example:

"2021-01-01T00:00:00.000Z"

updatedAt
string

The date and time the response was last updated

Example:

"2021-01-01T00:00:00.000Z"

displayId
string | null

The display ID of the response

singleUseId
string | null

The single use ID of the response

endingId
string | null

The ID of the ending

language
string | null

The language of the response

Example:

"en"

variables
object

The variables of the response

Example:
{ "variable1": "answer1", "variable2": 2 }
ttc
object

The TTC of the response

Example:
{ "question1": 10, "question2": 20 }
meta
object

The meta data of the response

Example:
{
"source": "https://example.com",
"url": "https://example.com",
"userAgent": {
"browser": "Chrome",
"os": "Windows",
"device": "Desktop"
},
"country": "US",
"action": "click"
}
userId
string

Response

201 - application/json

Response created successfully.

id
string

The ID of the response

createdAt
string

The date and time the response was created

Example:

"2021-01-01T00:00:00.000Z"

updatedAt
string

The date and time the response was last updated

Example:

"2021-01-01T00:00:00.000Z"

finished
boolean

Whether the response is finished

Example:

true

surveyId
string

The ID of the survey

contactId
string | null

The ID of the contact

endingId
string | null

The ID of the ending

data
object

The data of the response

Example:
{
"question1": "answer1",
"question2": 2,
"question3": ["answer3", "answer4"],
"question4": { "subquestion1": "answer5" }
}
variables
object

The variables of the response

Example:
{ "variable1": "answer1", "variable2": 2 }
ttc
object

The TTC of the response

Example:
{ "question1": 10, "question2": 20 }
meta
object

The meta data of the response

Example:
{
"source": "https://example.com",
"url": "https://example.com",
"userAgent": {
"browser": "Chrome",
"os": "Windows",
"device": "Desktop"
},
"country": "US",
"action": "click"
}
contactAttributes
object | null

The attributes of the contact

Example:
{
"attribute1": "value1",
"attribute2": "value2"
}
singleUseId
string | null

The single use ID of the response

language
string | null

The language of the response

Example:

"en"

displayId
string | null

The display ID of the response