Upload Private File
curl --request POST \
--url https://app.formbricks.com/api/v2/client/{workspaceId}/storage \
--header 'Content-Type: application/json' \
--data '
{
"surveyId": "cm7pr0x2y004o192zmit8cjvb",
"fileName": "example.jpg",
"fileType": "image/jpeg"
}
'import requests
url = "https://app.formbricks.com/api/v2/client/{workspaceId}/storage"
payload = {
"surveyId": "cm7pr0x2y004o192zmit8cjvb",
"fileName": "example.jpg",
"fileType": "image/jpeg"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
surveyId: 'cm7pr0x2y004o192zmit8cjvb',
fileName: 'example.jpg',
fileType: 'image/jpeg'
})
};
fetch('https://app.formbricks.com/api/v2/client/{workspaceId}/storage', 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/client/{workspaceId}/storage",
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' => 'cm7pr0x2y004o192zmit8cjvb',
'fileName' => 'example.jpg',
'fileType' => 'image/jpeg'
]),
CURLOPT_HTTPHEADER => [
"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://app.formbricks.com/api/v2/client/{workspaceId}/storage"
payload := strings.NewReader("{\n \"surveyId\": \"cm7pr0x2y004o192zmit8cjvb\",\n \"fileName\": \"example.jpg\",\n \"fileType\": \"image/jpeg\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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/client/{workspaceId}/storage")
.header("Content-Type", "application/json")
.body("{\n \"surveyId\": \"cm7pr0x2y004o192zmit8cjvb\",\n \"fileName\": \"example.jpg\",\n \"fileType\": \"image/jpeg\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.formbricks.com/api/v2/client/{workspaceId}/storage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"surveyId\": \"cm7pr0x2y004o192zmit8cjvb\",\n \"fileName\": \"example.jpg\",\n \"fileType\": \"image/jpeg\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"signedUrl": "https://s3.example.com/bucket",
"presignedFields": {
"key": "uploads/env-id/private/file--fid--uuid.jpg",
"policy": "<base64-policy>",
"x-amz-algorithm": "AWS4-HMAC-SHA256"
},
"updatedFileName": "file--fid--b153ba3e-6602-4bb3-bed9-211b5b1ae463.jpg",
"fileUrl": "https://app.formbricks.com/storage/cm1ubebtj000614kqe4hs3c67/private/file--fid--b153ba3e-6602-4bb3-bed9-211b5b1ae463.jpg"
}
}{
"error": "fileName is required"
}{
"error": "Survey survey123 not found"
}Client API - File Upload
Upload Private File
API endpoint for uploading private files. Uploaded files are kept private so that only users with access to the specified Workspace can retrieve them. The endpoint validates the survey ID, file name, and file type from the request body, and returns a signed URL for S3 uploads along with a local upload URL. Note - Environments are deprecated. Use Workspace/workspaceId terminology.
POST
/
client
/
{workspaceId}
/
storage
Upload Private File
curl --request POST \
--url https://app.formbricks.com/api/v2/client/{workspaceId}/storage \
--header 'Content-Type: application/json' \
--data '
{
"surveyId": "cm7pr0x2y004o192zmit8cjvb",
"fileName": "example.jpg",
"fileType": "image/jpeg"
}
'import requests
url = "https://app.formbricks.com/api/v2/client/{workspaceId}/storage"
payload = {
"surveyId": "cm7pr0x2y004o192zmit8cjvb",
"fileName": "example.jpg",
"fileType": "image/jpeg"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
surveyId: 'cm7pr0x2y004o192zmit8cjvb',
fileName: 'example.jpg',
fileType: 'image/jpeg'
})
};
fetch('https://app.formbricks.com/api/v2/client/{workspaceId}/storage', 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/client/{workspaceId}/storage",
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' => 'cm7pr0x2y004o192zmit8cjvb',
'fileName' => 'example.jpg',
'fileType' => 'image/jpeg'
]),
CURLOPT_HTTPHEADER => [
"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://app.formbricks.com/api/v2/client/{workspaceId}/storage"
payload := strings.NewReader("{\n \"surveyId\": \"cm7pr0x2y004o192zmit8cjvb\",\n \"fileName\": \"example.jpg\",\n \"fileType\": \"image/jpeg\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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/client/{workspaceId}/storage")
.header("Content-Type", "application/json")
.body("{\n \"surveyId\": \"cm7pr0x2y004o192zmit8cjvb\",\n \"fileName\": \"example.jpg\",\n \"fileType\": \"image/jpeg\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.formbricks.com/api/v2/client/{workspaceId}/storage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"surveyId\": \"cm7pr0x2y004o192zmit8cjvb\",\n \"fileName\": \"example.jpg\",\n \"fileType\": \"image/jpeg\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"signedUrl": "https://s3.example.com/bucket",
"presignedFields": {
"key": "uploads/env-id/private/file--fid--uuid.jpg",
"policy": "<base64-policy>",
"x-amz-algorithm": "AWS4-HMAC-SHA256"
},
"updatedFileName": "file--fid--b153ba3e-6602-4bb3-bed9-211b5b1ae463.jpg",
"fileUrl": "https://app.formbricks.com/storage/cm1ubebtj000614kqe4hs3c67/private/file--fid--b153ba3e-6602-4bb3-bed9-211b5b1ae463.jpg"
}
}{
"error": "fileName is required"
}{
"error": "Survey survey123 not found"
}Path Parameters
The ID of the Workspace. Deprecated alias environmentId.
Body
application/json
Response
OK - Returns the signed URL, presigned fields, updated file name, and file URL.
Show child attributes
Show child attributes
Was this page helpful?
⌘I