### Go example to get responses Source: https://formbricks.com/docs/api-v2-reference/management-api--responses/get-responses Uses the net/http package to send a GET request with the API key header and prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://app.formbricks.com/api/v2/management/responses?limit=50&sortBy=createdAt&order=desc" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("x-api-key", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Go example for getting survey links Source: https://formbricks.com/docs/api-v2-reference/management-api--surveys--contact-links/get-survey-links-for-contacts-in-a-segment Uses the net/http package to send a GET request with the x-api-key header and prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://app.formbricks.com/api/v2/management/surveys/{surveyId}/contact-links/segments/{segmentId}?limit=50" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("x-api-key", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Kubernetes Setup: Helm install command Source: https://formbricks.com/docs/self-hosting/setup/cluster-setup Installs Formbricks using the OCI chart from charts/formbricks. Use the dedicated Kubernetes deployment guide for the full installation flow. ```bash helm install formbricks oci://ghcr.io/formbricks/helm-charts/formbricks \ -n formbricks \ --create-namespace \ -f values.yaml ``` -------------------------------- ### Go example to get users Source: https://formbricks.com/docs/api-v2-reference/organizations-api--users/get-users Uses the net/http package to send a GET request to the Formbricks API. Adds the x-api-key header and prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://app.formbricks.com/api/v2/organizations/{organizationId}/users?limit=50&sortBy=createdAt&order=desc" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("x-api-key", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Bundled RustFS Setup Output Source: https://formbricks.com/docs/self-hosting/configuration/file-uploads Example output shown after the bundled RustFS setup completes, displaying the generated access key and confirming the bucket was created. ```plaintext ๐Ÿ—„๏ธ RustFS Storage Setup Complete: โ€ข Access Key: formbricks-service-a1b2c3d4 โ€ข Bucket: formbricks-uploads (โœ… automatically created) ``` -------------------------------- ### Ruby example to get responses Source: https://formbricks.com/docs/api-v2-reference/management-api--responses/get-responses Uses Net::HTTP to send a GET request with the API key header and prints the response body. ```ruby require 'uri' require 'net/http' url = URI("https://app.formbricks.com/api/v2/management/responses?limit=50&sortBy=createdAt&order=desc") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["x-api-key"] = '' response = http.request(request) puts response.read_body ``` -------------------------------- ### Ruby example for getting survey links Source: https://formbricks.com/docs/api-v2-reference/management-api--surveys--contact-links/get-survey-links-for-contacts-in-a-segment Uses Net::HTTP to perform a GET request with the x-api-key header and prints the response body. ```ruby require 'uri' require 'net/http' url = URI("https://app.formbricks.com/api/v2/management/surveys/{surveyId}/contact-links/segments/{segmentId}?limit=50") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["x-api-key"] = '' response = http.request(request) puts response.read_body ``` -------------------------------- ### Ruby example to get users Source: https://formbricks.com/docs/api-v2-reference/organizations-api--users/get-users Uses Net::HTTP to send a GET request to the Formbricks API. Sets the x-api-key header and prints the response body. ```ruby require 'uri' require 'net/http' url = URI("https://app.formbricks.com/api/v2/organizations/{organizationId}/users?limit=50&sortBy=createdAt&order=desc") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["x-api-key"] = '' response = http.request(request) puts response.read_body ``` -------------------------------- ### Prepare AuthZed for existing one-click installation Source: https://formbricks.com/docs/self-hosting/setup/one-click Starts the PostgreSQL and SpiceDB services, then runs the AuthZed preparation command with the required flags. This is part of the migration steps to add SpiceDB to an existing installation before upgrading to a release that uses AuthZed. ```bash docker compose up -d --wait postgres spicedb docker compose --profile authzed-ops run --rm --no-deps \ --entrypoint formbricks-authzed-prepare authzed-ops \ --backup-confirmed --writers-stopped ``` -------------------------------- ### One-click setup script output Source: https://formbricks.com/docs/self-hosting/setup/one-click Example output from the Formbricks one-click setup script on Ubuntu 24.04 LTS. It shows the interactive prompts for domain name, HTTPS certificate, email, HSTS, and email service, followed by the Docker Compose startup and final success message. ```text ๐Ÿš€ Executing default step of installing Formbricks ๐Ÿงฑ Welcome to the Formbricks Setup Script ๐Ÿ›ธ Fasten your seatbelts! We're setting up your Formbricks environment on your Ubuntu 24.04 LTS server. ๐Ÿงน Time to sweep away any old Docker installations. ๐Ÿ”„ Updating your package list. ๐Ÿ“ฆ Installing the necessary dependencies. ๐Ÿ”‘ Adding Docker's official GPG key and setting up the stable repository. File '/etc/apt/keyrings/docker.gpg' exists. Overwrite? (y/N) y ๐Ÿ”„ Updating your package list again. ๐Ÿณ Installing Docker. ๐Ÿš€ Testing your Docker installation. ๐ŸŽ‰ Docker is installed! ๐Ÿณ Adding your user to the Docker group to avoid using sudo with docker commands. ๐ŸŽ‰ Hooray! Docker is all set and ready to go. You're now ready to run your Formbricks instance! ๐Ÿ“ Created Formbricks Quickstart directory at ./formbricks. ๐Ÿ”— Please enter your domain name for the SSL certificate (๐Ÿšจ do NOT enter the protocol (http/https/etc)): my.hosted.url.com ๐Ÿ”— Do you want us to set up an HTTPS certificate for you? [Y/n] Y ๐Ÿ”— Please make sure that the domain points to the server's IP address and that ports 80 & 443 are open in your server's firewall. Is everything set up? [Y/n] Y ๐Ÿ’ก Please enter your email address for the SSL certificate: docs@formbricks.com ๐Ÿ”— Do you want to enforce HTTPS (HSTS)? [Y/n] Y ๐Ÿš— Configuring Traefik... ๐Ÿ’ก Created traefik.yaml and traefik-dynamic.yaml file. ๐Ÿ’ก Created acme.json file with correct permissions. ๐Ÿ“ง Do you want to set up the email service? You will need SMTP credentials for the same! [y/N] N ๐Ÿ“ฅ Downloading docker-compose.yml from Formbricks GitHub repository... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 6632 100 6632 0 0 24280 0 --:--:-- --:--:-- --:--:-- 24382 ๐Ÿš™ Updating docker-compose.yml with your custom inputs... ๐Ÿš— NEXTAUTH_SECRET updated successfully! ๐Ÿš— ENCRYPTION_KEY updated successfully! ๐Ÿš— CRON_SECRET updated successfully! [+] Running 4/4 โœ” Network formbricks_default Created 0.2s โœ” Container formbricks-postgres-1 Started 1.0s โœ” Container formbricks-formbricks-1 Started 1.6s โœ” Container traefik Started 2.8s ๐Ÿ”— To edit more variables and deeper config, go to the formbricks/docker-compose.yml, edit the file, and restart the container! ๐Ÿšจ Make sure you have set up the DNS records as well as inbound rules for the domain name and IP address of this instance. ๐ŸŽ‰ All done! Please setup your Formbricks instance by visiting your domain at https://my.hosted.url.com. You can check the status of Formbricks & Traefik with 'cd formbricks && sudo docker compose ps.' ``` -------------------------------- ### GET management contact-attribute-keys (alternate client examples) Source: https://formbricks.com/docs/api-v2-reference/management-api--contact-attribute-keys/get-contact-attribute-keys Alternative client examples for the same GET request as the primary cURL snippet zin the documentation. These variations (Python, JavaScript, PHP, Go, Java) each perform an HTTP GET call to the same endpoint with the required x-api-key header. The Java example uses Unirest library. ```shell curl --request GET \ --url 'https://app.formbricks.com/api/v2/management/contact-attribute-keys?limit=50&sortBy=createdAt&order=desc' \ --header 'x-api-key: ' ``` ```python import requests url = "https://app.formbricks.com/api/v2/management/contact-attribute-keys?limit=50&sortBy=createdAt&order=desc" headers = {"x-api-key": ""} response = requests.get(url, headers=headers) print(response.text) ``` ```javascript const options = {method: 'GET', headers: {'x-api-key': ''}}; fetch('https://app.formbricks.com/api/v2/management/contact-attribute-keys?limit=50&sortBy=createdAt&order=desc', options) .then(res => res.json()) .then(res => console.log(res)) .catch(err => console.error(err)); ``` ```php "https://app.formbricks.com/api/v2/management/contact-attribute-keys?limit=50&sortBy=createdAt&order=desc", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => [ "x-api-key: " ], ]); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } ``` ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://app.formbricks.com/api/v2/management/contact-attribute-keys?limit=50&sortBy=createdAt&order=desc" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("x-api-key", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` ```java HttpResponse response = Unirest.get("https://app.formbricks.com/api/v2/management/contact-attribute-keys?limit=50&sortBy=createdAt&order=desc") .header("x-api-key", "") .asString(); ``` -------------------------------- ### Python requests example for getting survey links Source: https://formbricks.com/docs/api-v2-reference/management-api--surveys--contact-links/get-survey-links-for-contacts-in-a-segment Uses the requests library to perform a GET request. Prints the response text. ```python import requests url = "https://app.formbricks.com/api/v2/management/surveys/{surveyId}/contact-links/segments/{segmentId}?limit=50" headers = {"x-api-key": ""} response = requests.get(url, headers=headers) print(response.text) ``` -------------------------------- ### 200 response example for get workspace state Source: https://formbricks.com/docs/api-v2-reference/client-api--workspace/get-workspace-state Example JSON response returned by the endpoint when the request succeeds. Contains workspaceId, environmentId, and state. ```json { "workspaceId": "ws_01h2xce9q8p3w4x5y6z7a8b9c0", "environmentId": "env_01h2xce9q8p3w4x5y6z7a8b9c0", "state": "active" } ``` -------------------------------- ### Create and enter a new directory for Formbricks Source: https://formbricks.com/docs/self-hosting/setup/docker Run these commands to create and enter a new directory named formbricks-quickstart. ```bash mkdir formbricks-quickstart && cd formbricks-quickstart ``` -------------------------------- ### Navigate to the Formbricks folder Source: https://formbricks.com/docs/self-hosting/configuration/custom-ssl Move into the formbricks/ directory to begin the custom SSL setup. ```bash cd formbricks ``` -------------------------------- ### Start Formbricks dev environment Source: https://formbricks.com/docs/development/technical-handbook/mcp-server Starts the database, applies migrations, and launches the web dev server. Restart the dev server after tool registration changes because the MCP server is built once at module scope by createMcpHandler and hot reload does not pick up tool changes. ```shell pnpm db:up pnpm db:migrate:dev pnpm --filter @formbricks/web dev ``` -------------------------------- ### Go example to create or identify user Source: https://formbricks.com/docs/api-v2-reference/client-api--user/create-or-identify-user Uses net/http to send a POST request with a JSON string payload. Prints the response body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://app.formbricks.com/api/v2/client/{workspaceId}/user" payload := strings.NewReader("{\n \"userId\": \"user123\",\n \"attributes\": {}\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)) } ``` -------------------------------- ### Java Unirest example for getting survey links Source: https://formbricks.com/docs/api-v2-reference/management-api--surveys--contact-links/get-survey-links-for-contacts-in-a-segment Uses the Unirest library to send a GET request with the x-api-key header and returns the response as a string. ```java HttpResponse response = Unirest.get("https://app.formbricks.com/api/v2/management/surveys/{surveyId}/contact-links/segments/{segmentId}?limit=50") .header("x-api-key", "") .asString(); ``` -------------------------------- ### Start the local development stack with docker-compose.dev.yml Source: https://formbricks.com/docs/self-hosting/setup/docker Run this command from the repository root to start the development stack, which includes PostgreSQL, Valkey, Mailhog, RustFS, a permissions helper, a bucket bootstrap job, Formbricks Hub, and a local Cube instance. ```bash docker compose -f docker-compose.dev.yml up -d ``` -------------------------------- ### Java Unirest GET for personalized survey link Source: https://formbricks.com/docs/api-v2-reference/management-api--surveys--contact-links/get-personalized-survey-link-for-a-contact Java example using Unirest to GET a personalized survey link. Returns an HttpResponse. ```java HttpResponse response = Unirest.get("https://app.formbricks.com/api/v2/management/surveys/{surveyId}/contact-links/contacts/{contactId}/") .header("x-api-key", "") .asString(); ``` -------------------------------- ### Python requests example to get responses Source: https://formbricks.com/docs/api-v2-reference/management-api--responses/get-responses Uses the requests library to perform a GET request with the API key header and prints the response text. ```python import requests url = "https://app.formbricks.com/api/v2/management/responses?limit=50&sortBy=createdAt&order=desc" headers = {"x-api-key": ""} response = requests.get(url, headers=headers) print(response.text) ``` -------------------------------- ### One-Click Setup Script: Bundled RustFS Storage Prompt Source: https://formbricks.com/docs/self-hosting/configuration/file-uploads Choose this option for a self-hosted S3-compatible storage that runs alongside Formbricks. Critical: configure a subdomain (e.g., files.yourdomain.com) pointing to your server's IP address before proceeding. The script generates separate RustFS admin and Formbricks service credentials, creates the storage bucket, configures SSL certificates, configures Traefik routing, and stores credentials in ./formbricks/.env with restricted permissions. ```text ๐Ÿ—„๏ธ Do you want to use an external S3-compatible storage (AWS S3/DO Spaces/etc.)? [y/N] n ๐Ÿ”— Enter the files subdomain for object storage (e.g., files.yourdomain.com): files.yourdomain.com ``` -------------------------------- ### 200 response for Get roles Source: https://formbricks.com/docs/api-v2-reference/roles/get-roles Example 200 response for the Get roles endpoint. The data field is an array of strings, with the allowed value "owner". ```json { "data": [ "owner" ] } ``` -------------------------------- ### Go example for uploading private file Source: https://formbricks.com/docs/api-v2-reference/client-api--file-upload/upload-private-file Uses net/http to POST the file metadata and prints the response body. ```go 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)) } ``` -------------------------------- ### PHP cURL example for getting survey links Source: https://formbricks.com/docs/api-v2-reference/management-api--surveys--contact-links/get-survey-links-for-contacts-in-a-segment Uses PHP cURL to perform a GET request with the x-api-key header. Outputs the response or an error message. ```php "https://app.formbricks.com/api/v2/management/surveys/{surveyId}/contact-links/segments/{segmentId}?limit=50", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => [ "x-api-key: " ], ]); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } ``` -------------------------------- ### Compose startup order for SpiceDB and Formbricks Source: https://formbricks.com/docs/self-hosting/advanced/authzed-operations Shows the ordered startup of the released Compose stack: PostgreSQL, then the SpiceDB bootstrap and migration services, then SpiceDB itself, and finally the Formbricks migration and the one-shot `authzed-initialize` service. The bootstrap and migration steps are idempotent, and migration and serving always use the same `SPICEDB_IMAGE_REF`. ```text postgres โ†’ authzed-db-bootstrap โ†’ spicedb-migrate โ†’ spicedb postgres โ†’ formbricks-migrate spicedb + formbricks-migrate โ†’ authzed-initialize ``` -------------------------------- ### Run AuthZed upgrade preparation and check commands Source: https://formbricks.com/docs/self-hosting/advanced/authzed-operations Run these commands while maintenance is active. `prepare` verifies configuration and datastore readiness, applies an empty or matching canonical schema, drains the outbox, reconciles relationships, and runs a final audit. `check` is read-only and exits 0 only when all conditions are met; exit 2 means the release is blocked, exit 1 means configuration or operation failure. ```bash formbricks-authzed upgrade prepare formbricks-authzed upgrade check ``` -------------------------------- ### Go GET request for personalized survey link Source: https://formbricks.com/docs/api-v2-reference/management-api--surveys--contact-links/get-personalized-survey-link-for-a-contact Go example using net/http to GET a personalized survey link. Reads and prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://app.formbricks.com/api/v2/management/surveys/{surveyId}/contact-links/contacts/{contactId}/" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("x-api-key", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Inspect logs for common startup issues Source: https://formbricks.com/docs/self-hosting/setup/docker Inspect logs for services that commonly explain startup issues, including migrations, the main app, and Cube. ```bash docker compose logs --tail=200 formbricks-migrate hub-migrate formbricks hub cube docker compose logs --tail=200 postgres redis ``` -------------------------------- ### JavaScript fetch GET for personalized survey link Source: https://formbricks.com/docs/api-v2-reference/management-api--surveys--contact-links/get-personalized-survey-link-for-a-contact JavaScript example using fetch to GET a personalized survey link. Handles JSON response and errors. ```javascript const options = {method: 'GET', headers: {'x-api-key': ''}}; fetch('https://app.formbricks.com/api/v2/management/surveys/{surveyId}/contact-links/contacts/{contactId}/', options) .then(res => res.json()) .then(res => console.log(res)) .catch(err => console.error(err)); ``` -------------------------------- ### Java Unirest example to get responses Source: https://formbricks.com/docs/api-v2-reference/management-api--responses/get-responses Uses the Unirest HTTP library to send a GET request with the API key header and returns the response as a string. ```java HttpResponse response = Unirest.get("https://app.formbricks.com/api/v2/management/responses?limit=50&sortBy=createdAt&order=desc") .header("x-api-key", "") .asString(); ``` -------------------------------- ### Go example for workspace teams Source: https://formbricks.com/docs/api-v2-reference/organizations-api--workspace-teams/get-workspace-teams Uses net/http to GET workspace teams with the x-api-key header. Reads and prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://app.formbricks.com/api/v2/organizations/{organizationId}/workspace-teams?limit=50&sortBy=createdAt&order=desc" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("x-api-key", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### PHP cURL example to get responses Source: https://formbricks.com/docs/api-v2-reference/management-api--responses/get-responses Uses PHP cURL to send a GET request with the API key header, handling errors and printing the response. ```php "https://app.formbricks.com/api/v2/management/responses?limit=50&sortBy=createdAt&order=desc", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => [ "x-api-key: " ], ]); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } ``` -------------------------------- ### Install Formbricks with npm Source: https://formbricks.com/docs/surveys/website-app-surveys/framework-guides Install the Formbricks JavaScript SDK and Zod using npm. ```bash npm install @formbricks/js zod ``` -------------------------------- ### JavaScript fetch example to get responses Source: https://formbricks.com/docs/api-v2-reference/management-api--responses/get-responses Uses the fetch API to send a GET request with the API key header, then logs the JSON response or error. ```javascript const options = {method: 'GET', headers: {'x-api-key': ''}}; fetch('https://app.formbricks.com/api/v2/management/responses?limit=50&sortBy=createdAt&order=desc', options) .then(res => res.json()) .then(res => console.log(res)) .catch(err => console.error(err)); ```