mirror of
https://github.com/formbricks/formbricks.git
synced 2025-12-30 18:30:32 -06:00
fix: storage api endpoint openapi spec (#5057)
This commit is contained in:
@@ -294,6 +294,341 @@ const v1ClientEndpoints = {
|
||||
],
|
||||
},
|
||||
},
|
||||
"/{environmentId}/storage": {
|
||||
post: {
|
||||
summary: "Upload Private File",
|
||||
description:
|
||||
"API endpoint for uploading private files. Uploaded files are kept private so that only users with access to the specified environment 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.",
|
||||
tags: ["Client API > File Upload"],
|
||||
parameters: [
|
||||
{
|
||||
in: "path",
|
||||
name: "environmentId",
|
||||
required: true,
|
||||
schema: {
|
||||
type: "string",
|
||||
},
|
||||
description: "The ID of the environment.",
|
||||
},
|
||||
],
|
||||
requestBody: {
|
||||
required: true,
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
surveyId: {
|
||||
type: "string",
|
||||
description: "The ID of the survey associated with the file.",
|
||||
},
|
||||
fileName: {
|
||||
type: "string",
|
||||
description: "The name of the file to be uploaded.",
|
||||
},
|
||||
fileType: {
|
||||
type: "string",
|
||||
description: "The MIME type of the file.",
|
||||
},
|
||||
},
|
||||
required: ["surveyId", "fileName", "fileType"],
|
||||
example: {
|
||||
surveyId: "cm7pr0x2y004o192zmit8cjvb",
|
||||
fileName: "example.jpg",
|
||||
fileType: "image/jpeg",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
responses: {
|
||||
"200": {
|
||||
description: "OK - Returns the signed URL, signing data, updated file name, and file URL.",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
data: {
|
||||
type: "object",
|
||||
properties: {
|
||||
signedUrl: {
|
||||
type: "string",
|
||||
description: "Signed URL for uploading the file to local storage.",
|
||||
},
|
||||
signingData: {
|
||||
type: "object",
|
||||
properties: {
|
||||
signature: {
|
||||
type: "string",
|
||||
description: "Signature for verifying the upload.",
|
||||
},
|
||||
timestamp: {
|
||||
type: "number",
|
||||
description: "Timestamp used in the signature.",
|
||||
},
|
||||
uuid: {
|
||||
type: "string",
|
||||
description: "Unique identifier for the signed upload.",
|
||||
},
|
||||
},
|
||||
},
|
||||
updatedFileName: {
|
||||
type: "string",
|
||||
description: "The updated file name after processing.",
|
||||
},
|
||||
fileUrl: {
|
||||
type: "string",
|
||||
description: "URL where the uploaded file can be accessed.",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
example: {
|
||||
data: {
|
||||
signedUrl: "http://localhost:3000/api/v1/client/cm1ubebtj000614kqe4hs3c67/storage/local",
|
||||
signingData: {
|
||||
signature: "3e51c6f441e646a0c9a47fdcdd25eee9bfac26d5506461d811b9c55cbdd90914",
|
||||
timestamp: 1741693207760,
|
||||
uuid: "f48bcb1aad904f574069a253388024af",
|
||||
},
|
||||
updatedFileName: "halle--fid--b153ba3e-6602-4bb3-bed9-211b5b1ae463.jpg",
|
||||
fileUrl:
|
||||
"http://localhost:3000/storage/cm1ubebtj000614kqe4hs3c67/private/halle--fid--b153ba3e-6602-4bb3-bed9-211b5b1ae463.jpg",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"400": {
|
||||
description: "Bad Request - One or more required fields are missing.",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
error: {
|
||||
type: "string",
|
||||
description: "Detailed error message.",
|
||||
},
|
||||
},
|
||||
example: {
|
||||
error: "fileName is required",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"404": {
|
||||
description: "Not Found - The specified survey or organization does not exist.",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
error: {
|
||||
type: "string",
|
||||
description: "Detailed error message.",
|
||||
},
|
||||
},
|
||||
example: {
|
||||
error: "Survey survey123 not found",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
servers: [
|
||||
{
|
||||
url: "https://app.formbricks.com/api/v2/client",
|
||||
description: "Formbricks API Server",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
"/{environmentId}/storage/local": {
|
||||
post: {
|
||||
summary: "Upload Private File to Local Storage",
|
||||
description:
|
||||
'API endpoint for uploading private files to local storage. The request must include a valid signature, UUID, and timestamp to verify the upload. The file is provided as a Base64 encoded string in the request body. The "Content-Type" header must be set to a valid MIME type, and the file data must be a valid file object (buffer).',
|
||||
tags: ["Client API > File Upload"],
|
||||
parameters: [
|
||||
{
|
||||
in: "path",
|
||||
name: "environmentId",
|
||||
required: true,
|
||||
schema: {
|
||||
type: "string",
|
||||
},
|
||||
description: "The ID of the environment.",
|
||||
},
|
||||
],
|
||||
requestBody: {
|
||||
required: true,
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
surveyId: {
|
||||
type: "string",
|
||||
description: "The ID of the survey associated with the file.",
|
||||
},
|
||||
fileName: {
|
||||
type: "string",
|
||||
description: "The URI encoded file name.",
|
||||
},
|
||||
fileType: {
|
||||
type: "string",
|
||||
description: "The MIME type of the file.",
|
||||
},
|
||||
signature: {
|
||||
type: "string",
|
||||
description: "Signed signature for verifying the file upload.",
|
||||
},
|
||||
uuid: {
|
||||
type: "string",
|
||||
description: "Unique identifier used in the signature validation.",
|
||||
},
|
||||
timestamp: {
|
||||
type: "string",
|
||||
description: "Timestamp used in the signature validation.",
|
||||
},
|
||||
fileBase64String: {
|
||||
type: "string",
|
||||
description:
|
||||
'Base64 encoded string of the file. It should include data type information, e.g. "data:<mime-type>;base64,<base64-encoded-data>".',
|
||||
},
|
||||
},
|
||||
required: [
|
||||
"surveyId",
|
||||
"fileName",
|
||||
"fileType",
|
||||
"signature",
|
||||
"uuid",
|
||||
"timestamp",
|
||||
"fileBase64String",
|
||||
],
|
||||
example: {
|
||||
surveyId: "survey123",
|
||||
fileName: "example.jpg",
|
||||
fileType: "image/jpeg",
|
||||
signature: "signedSignatureValue",
|
||||
uuid: "uniqueUuidValue",
|
||||
timestamp: "1627891234567",
|
||||
fileBase64String: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/...",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
responses: {
|
||||
"200": {
|
||||
description: "OK - File uploaded successfully.",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
message: {
|
||||
type: "string",
|
||||
description: "Success message.",
|
||||
},
|
||||
},
|
||||
example: {
|
||||
message: "File uploaded successfully",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"400": {
|
||||
description: "Bad Request - One or more required fields are missing or the file is too large.",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
error: {
|
||||
type: "string",
|
||||
description: "Detailed error message.",
|
||||
},
|
||||
},
|
||||
example: {
|
||||
error: "fileName is required",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"401": {
|
||||
description: "Unauthorized - Signature validation failed or required signature fields are missing.",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
error: {
|
||||
type: "string",
|
||||
description: "Detailed error message.",
|
||||
},
|
||||
},
|
||||
example: {
|
||||
error: "Unauthorized",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"404": {
|
||||
description: "Not Found - The specified survey or organization does not exist.",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
error: {
|
||||
type: "string",
|
||||
description: "Detailed error message.",
|
||||
},
|
||||
},
|
||||
example: {
|
||||
error: "Survey survey123 not found",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"500": {
|
||||
description: "Internal Server Error - File upload failed.",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
error: {
|
||||
type: "string",
|
||||
description: "Detailed error message.",
|
||||
},
|
||||
},
|
||||
example: {
|
||||
error: "File upload failed",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
servers: [
|
||||
{
|
||||
url: "https://app.formbricks.com/api/v2",
|
||||
description: "Formbricks API Server",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// Read the generated openapi.yml file
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
---
|
||||
openapi: post /api/v1/management/storage/local
|
||||
---
|
||||
@@ -0,0 +1,3 @@
|
||||
---
|
||||
openapi: post /api/v1/management/storage
|
||||
---
|
||||
@@ -5672,6 +5672,343 @@
|
||||
"tags": ["Management API > Response"]
|
||||
}
|
||||
},
|
||||
"/api/v1/management/storage": {
|
||||
"post": {
|
||||
"description": "API endpoint for uploading public files. Uploaded files are public and accessible by anyone. This endpoint requires authentication. It accepts a JSON body with fileName, fileType, environmentId, and optionally allowedFileExtensions to restrict file types. On success, it returns a signed URL for uploading the file to S3 along with a local upload URL.",
|
||||
"parameters": [
|
||||
{
|
||||
"example": "{{apiKey}}",
|
||||
"in": "header",
|
||||
"name": "x-api-key",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"example": {
|
||||
"allowedFileExtensions": ["png", "jpg", "jpeg"],
|
||||
"environmentId": "env123",
|
||||
"fileName": "profile.png",
|
||||
"fileType": "image/png"
|
||||
},
|
||||
"schema": {
|
||||
"properties": {
|
||||
"allowedFileExtensions": {
|
||||
"description": "Optional. List of allowed file extensions.",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"environmentId": {
|
||||
"description": "The ID of the environment.",
|
||||
"type": "string"
|
||||
},
|
||||
"fileName": {
|
||||
"description": "The name of the file to be uploaded.",
|
||||
"type": "string"
|
||||
},
|
||||
"fileType": {
|
||||
"description": "The MIME type of the file.",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": ["fileName", "fileType", "environmentId"],
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"example": {
|
||||
"data": {
|
||||
"fileUrl": "http://localhost:3000/storage/cm1ubebtj000614kqe4hs3c67/public/profile--fid--abc123.png",
|
||||
"localUrl": "http://localhost:3000/storage/cm1ubebtj000614kqe4hs3c67/public/profile.png",
|
||||
"signedUrl": "http://localhost:3000/api/v1/client/cm1ubebtj000614kqe4hs3c67/storage/public",
|
||||
"updatedFileName": "profile--fid--abc123.png"
|
||||
}
|
||||
},
|
||||
"schema": {
|
||||
"properties": {
|
||||
"data": {
|
||||
"properties": {
|
||||
"fileUrl": {
|
||||
"description": "URL where the uploaded file can be accessed.",
|
||||
"type": "string"
|
||||
},
|
||||
"localUrl": {
|
||||
"description": "URL for uploading the file to local storage.",
|
||||
"type": "string"
|
||||
},
|
||||
"signedUrl": {
|
||||
"description": "Signed URL for uploading the file to S3.",
|
||||
"type": "string"
|
||||
},
|
||||
"updatedFileName": {
|
||||
"description": "The updated file name after processing.",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "OK - Returns the signed URL, updated file name, and file URL."
|
||||
},
|
||||
"400": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"example": {
|
||||
"error": "fileName is required"
|
||||
},
|
||||
"schema": {
|
||||
"properties": {
|
||||
"error": {
|
||||
"description": "Detailed error message.",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Bad Request - Missing required fields or invalid file extension."
|
||||
},
|
||||
"401": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"example": {
|
||||
"error": "Not authenticated"
|
||||
},
|
||||
"schema": {
|
||||
"properties": {
|
||||
"error": {
|
||||
"description": "Detailed error message.",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Unauthorized - Authentication failed or user not logged in."
|
||||
},
|
||||
"403": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"example": {
|
||||
"error": "User does not have access to environment env123"
|
||||
},
|
||||
"schema": {
|
||||
"properties": {
|
||||
"error": {
|
||||
"description": "Detailed error message.",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Forbidden - User does not have access to the specified environment."
|
||||
}
|
||||
},
|
||||
"summary": "Upload Public File",
|
||||
"tags": ["Management API > Storage"]
|
||||
}
|
||||
},
|
||||
"/api/v1/management/storage/local": {
|
||||
"post": {
|
||||
"description": "Management API endpoint for uploading public files to local storage. This endpoint requires authentication. File metadata is provided via headers (X-File-Type, X-File-Name, X-Environment-ID, X-Signature, X-UUID, X-Timestamp) and the file is provided as a multipart/form-data file field named \"file\". The \"Content-Type\" header must be set to a valid MIME type.",
|
||||
"parameters": [
|
||||
{
|
||||
"example": "{{apiKey}}",
|
||||
"in": "header",
|
||||
"name": "x-api-key",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "MIME type of the file. Must be a valid MIME type.",
|
||||
"in": "header",
|
||||
"name": "X-File-Type",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "URI encoded file name.",
|
||||
"in": "header",
|
||||
"name": "X-File-Name",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "ID of the environment.",
|
||||
"in": "header",
|
||||
"name": "X-Environment-ID",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Signature for verifying the request.",
|
||||
"in": "header",
|
||||
"name": "X-Signature",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Unique identifier for the signed upload.",
|
||||
"in": "header",
|
||||
"name": "X-UUID",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Timestamp used for the signature.",
|
||||
"in": "header",
|
||||
"name": "X-Timestamp",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"multipart/form-data": {
|
||||
"schema": {
|
||||
"properties": {
|
||||
"file": {
|
||||
"description": "The file to be uploaded as a valid file object (buffer).",
|
||||
"format": "binary",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": ["file"],
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"example": {
|
||||
"data": {
|
||||
"message": "File uploaded successfully"
|
||||
}
|
||||
},
|
||||
"schema": {
|
||||
"properties": {
|
||||
"data": {
|
||||
"properties": {
|
||||
"message": {
|
||||
"description": "Success message.",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "OK - File uploaded successfully."
|
||||
},
|
||||
"400": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"example": {
|
||||
"error": "fileType is required"
|
||||
},
|
||||
"schema": {
|
||||
"properties": {
|
||||
"error": {
|
||||
"description": "Detailed error message.",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Bad Request - Missing required fields, invalid header values, or file issues."
|
||||
},
|
||||
"401": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"example": {
|
||||
"error": "Not authenticated"
|
||||
},
|
||||
"schema": {
|
||||
"properties": {
|
||||
"error": {
|
||||
"description": "Detailed error message.",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Unauthorized - Authentication failed, invalid signature, or user not authorized."
|
||||
},
|
||||
"500": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"example": {
|
||||
"error": "File upload failed"
|
||||
},
|
||||
"schema": {
|
||||
"properties": {
|
||||
"error": {
|
||||
"description": "Detailed error message.",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Internal Server Error - File upload failed due to server error."
|
||||
}
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
"description": "Formbricks API Server",
|
||||
"url": "https://app.formbricks.com/api/v1"
|
||||
}
|
||||
],
|
||||
"summary": "Upload Public File to Local Storage",
|
||||
"tags": ["Management API > Storage"]
|
||||
}
|
||||
},
|
||||
"/api/v1/management/surveys": {
|
||||
"get": {
|
||||
"description": "Fetches all existing surveys",
|
||||
|
||||
@@ -21,18 +21,12 @@ tags:
|
||||
description: Operations for managing storage.
|
||||
- name: Client API > File Upload
|
||||
description: Operations for uploading files.
|
||||
|
||||
paths:
|
||||
/{environmentId}/responses/{responseId}:
|
||||
/responses/{responseId}:
|
||||
put:
|
||||
description: Update an existing response for example when you want to mark a
|
||||
response as finished or you want to change an existing response's value.
|
||||
parameters:
|
||||
- in: path
|
||||
name: environmentId
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
- in: path
|
||||
name: responseId
|
||||
required: true
|
||||
@@ -332,7 +326,8 @@ paths:
|
||||
fileType: image/jpeg
|
||||
responses:
|
||||
"200":
|
||||
description: OK - Returns the signed URL, signing data, updated file name, and file URL.
|
||||
description: OK - Returns the signed URL, signing data, updated file name, and
|
||||
file URL.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
@@ -364,13 +359,13 @@ paths:
|
||||
description: URL where the uploaded file can be accessed.
|
||||
example:
|
||||
data:
|
||||
signedUrl: "http://localhost:3000/api/v1/client/cm1ubebtj000614kqe4hs3c67/storage/local"
|
||||
signedUrl: http://localhost:3000/api/v1/client/cm1ubebtj000614kqe4hs3c67/storage/local
|
||||
signingData:
|
||||
signature: "3e51c6f441e646a0c9a47fdcdd25eee9bfac26d5506461d811b9c55cbdd90914"
|
||||
signature: 3e51c6f441e646a0c9a47fdcdd25eee9bfac26d5506461d811b9c55cbdd90914
|
||||
timestamp: 1741693207760
|
||||
uuid: "f48bcb1aad904f574069a253388024af"
|
||||
updatedFileName: "halle--fid--b153ba3e-6602-4bb3-bed9-211b5b1ae463.jpg"
|
||||
fileUrl: "http://localhost:3000/storage/cm1ubebtj000614kqe4hs3c67/private/halle--fid--b153ba3e-6602-4bb3-bed9-211b5b1ae463.jpg"
|
||||
uuid: f48bcb1aad904f574069a253388024af
|
||||
updatedFileName: halle--fid--b153ba3e-6602-4bb3-bed9-211b5b1ae463.jpg
|
||||
fileUrl: http://localhost:3000/storage/cm1ubebtj000614kqe4hs3c67/private/halle--fid--b153ba3e-6602-4bb3-bed9-211b5b1ae463.jpg
|
||||
"400":
|
||||
description: Bad Request - One or more required fields are missing.
|
||||
content:
|
||||
@@ -402,9 +397,11 @@ paths:
|
||||
post:
|
||||
summary: Upload Private File to Local Storage
|
||||
description: >
|
||||
API endpoint for uploading private files to local storage. The request must include a valid signature,
|
||||
UUID, and timestamp to verify the upload. The file is provided as a Base64 encoded string in the request body.
|
||||
The "Content-Type" header must be set to a valid MIME type, and the file data must be a valid file object (buffer).
|
||||
API endpoint for uploading private files to local storage. The request
|
||||
must include a valid signature, UUID, and timestamp to verify the
|
||||
upload. The file is provided as a Base64 encoded string in the request
|
||||
body. The "Content-Type" header must be set to a valid MIME type, and
|
||||
the file data must be a valid file object (buffer).
|
||||
tags:
|
||||
- Client API > File Upload
|
||||
parameters:
|
||||
@@ -442,8 +439,9 @@ paths:
|
||||
fileBase64String:
|
||||
type: string
|
||||
description: >
|
||||
Base64 encoded string of the file. It should include data type information,
|
||||
e.g. "data:<mime-type>;base64,<base64-encoded-data>".
|
||||
Base64 encoded string of the file. It should include data
|
||||
type information, e.g.
|
||||
"data:<mime-type>;base64,<base64-encoded-data>".
|
||||
required:
|
||||
- surveyId
|
||||
- fileName
|
||||
@@ -453,13 +451,13 @@ paths:
|
||||
- timestamp
|
||||
- fileBase64String
|
||||
example:
|
||||
surveyId: "survey123"
|
||||
fileName: "example.jpg"
|
||||
fileType: "image/jpeg"
|
||||
signature: "signedSignatureValue"
|
||||
uuid: "uniqueUuidValue"
|
||||
surveyId: survey123
|
||||
fileName: example.jpg
|
||||
fileType: image/jpeg
|
||||
signature: signedSignatureValue
|
||||
uuid: uniqueUuidValue
|
||||
timestamp: "1627891234567"
|
||||
fileBase64String: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/..."
|
||||
fileBase64String: data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/...
|
||||
responses:
|
||||
"200":
|
||||
description: OK - File uploaded successfully.
|
||||
@@ -472,9 +470,10 @@ paths:
|
||||
type: string
|
||||
description: Success message.
|
||||
example:
|
||||
message: "File uploaded successfully"
|
||||
message: File uploaded successfully
|
||||
"400":
|
||||
description: Bad Request - One or more required fields are missing or the file is too large.
|
||||
description: Bad Request - One or more required fields are missing or the file
|
||||
is too large.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
@@ -484,9 +483,10 @@ paths:
|
||||
type: string
|
||||
description: Detailed error message.
|
||||
example:
|
||||
error: "fileName is required"
|
||||
error: fileName is required
|
||||
"401":
|
||||
description: Unauthorized - Signature validation failed or required signature fields are missing.
|
||||
description: Unauthorized - Signature validation failed or required signature
|
||||
fields are missing.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
@@ -496,7 +496,7 @@ paths:
|
||||
type: string
|
||||
description: Detailed error message.
|
||||
example:
|
||||
error: "Unauthorized"
|
||||
error: Unauthorized
|
||||
"404":
|
||||
description: Not Found - The specified survey or organization does not exist.
|
||||
content:
|
||||
@@ -508,7 +508,7 @@ paths:
|
||||
type: string
|
||||
description: Detailed error message.
|
||||
example:
|
||||
error: "Survey survey123 not found"
|
||||
error: Survey survey123 not found
|
||||
"500":
|
||||
description: Internal Server Error - File upload failed.
|
||||
content:
|
||||
@@ -520,10 +520,60 @@ paths:
|
||||
type: string
|
||||
description: Detailed error message.
|
||||
example:
|
||||
error: "File upload failed"
|
||||
error: File upload failed
|
||||
servers:
|
||||
- url: https://app.formbricks.com/api/v2
|
||||
description: Formbricks API Server
|
||||
/{environmentId}/responses/{responseId}:
|
||||
put:
|
||||
description: Update an existing response for example when you want to mark a
|
||||
response as finished or you want to change an existing response's value.
|
||||
parameters:
|
||||
- in: path
|
||||
name: environmentId
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
- in: path
|
||||
name: responseId
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
example:
|
||||
data:
|
||||
tcgls0063n8ri7dtrbnepcmz: Who? Who? Who?
|
||||
finished: true
|
||||
type: object
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/json:
|
||||
example:
|
||||
data: {}
|
||||
schema:
|
||||
type: object
|
||||
description: OK
|
||||
"404":
|
||||
content:
|
||||
application/json:
|
||||
example:
|
||||
code: not_found
|
||||
details:
|
||||
resource_type: Response
|
||||
message: Response not found
|
||||
schema:
|
||||
type: object
|
||||
description: Not Found
|
||||
summary: Update Response
|
||||
tags:
|
||||
- Client API > Response
|
||||
servers:
|
||||
- url: https://app.formbricks.com/api/v2/client
|
||||
description: Formbricks Client
|
||||
/responses:
|
||||
get:
|
||||
security:
|
||||
@@ -1372,230 +1422,6 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/survey"
|
||||
/api/v2/management/storage:
|
||||
post:
|
||||
security:
|
||||
- apiKeyAuth: []
|
||||
summary: Upload Public File
|
||||
description: >
|
||||
API endpoint for uploading public files. Uploaded files are public and accessible by anyone.
|
||||
This endpoint requires authentication. It accepts a JSON body with fileName, fileType, environmentId,
|
||||
and optionally allowedFileExtensions to restrict file types. On success, it returns a signed URL for uploading
|
||||
the file to S3 along with a local upload URL.
|
||||
tags:
|
||||
- Management API > Storage
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
fileName:
|
||||
type: string
|
||||
description: The name of the file to be uploaded.
|
||||
fileType:
|
||||
type: string
|
||||
description: The MIME type of the file.
|
||||
environmentId:
|
||||
type: string
|
||||
description: The ID of the environment.
|
||||
allowedFileExtensions:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
description: Optional. List of allowed file extensions.
|
||||
required:
|
||||
- fileName
|
||||
- fileType
|
||||
- environmentId
|
||||
example:
|
||||
fileName: "profile.png"
|
||||
fileType: "image/png"
|
||||
environmentId: "env123"
|
||||
allowedFileExtensions: ["png", "jpg", "jpeg"]
|
||||
responses:
|
||||
"200":
|
||||
description: OK - Returns the signed URL, updated file name, and file URL.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
data:
|
||||
type: object
|
||||
properties:
|
||||
signedUrl:
|
||||
type: string
|
||||
description: Signed URL for uploading the file to S3.
|
||||
localUrl:
|
||||
type: string
|
||||
description: URL for uploading the file to local storage.
|
||||
updatedFileName:
|
||||
type: string
|
||||
description: The updated file name after processing.
|
||||
fileUrl:
|
||||
type: string
|
||||
description: URL where the uploaded file can be accessed.
|
||||
example:
|
||||
data:
|
||||
signedUrl: "http://localhost:3000/api/v1/client/cm1ubebtj000614kqe4hs3c67/storage/public"
|
||||
localUrl: "http://localhost:3000/storage/cm1ubebtj000614kqe4hs3c67/public/profile.png"
|
||||
updatedFileName: "profile--fid--abc123.png"
|
||||
fileUrl: "http://localhost:3000/storage/cm1ubebtj000614kqe4hs3c67/public/profile--fid--abc123.png"
|
||||
"400":
|
||||
description: Bad Request - Missing required fields or invalid file extension.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
error:
|
||||
type: string
|
||||
description: Detailed error message.
|
||||
example:
|
||||
error: "fileName is required"
|
||||
"401":
|
||||
description: Unauthorized - Authentication failed or user not logged in.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
error:
|
||||
type: string
|
||||
description: Detailed error message.
|
||||
example:
|
||||
error: "Not authenticated"
|
||||
"403":
|
||||
description: Forbidden - User does not have access to the specified environment.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
error:
|
||||
type: string
|
||||
description: Detailed error message.
|
||||
example:
|
||||
error: "User does not have access to environment env123"
|
||||
/api/v2/management/storage/local:
|
||||
put:
|
||||
summary: Upload Public File to Local Storage
|
||||
security:
|
||||
- apiKeyAuth: []
|
||||
description: >
|
||||
Management API endpoint for uploading public files to local storage. This endpoint requires authentication.
|
||||
File metadata is provided via headers (X-File-Type, X-File-Name, X-Environment-ID, X-Signature, X-UUID, X-Timestamp)
|
||||
and the file is provided as a multipart/form-data file field named "file". The "Content-Type" header must be set to a valid MIME type.
|
||||
tags:
|
||||
- Management API > Storage
|
||||
parameters:
|
||||
- in: header
|
||||
name: X-File-Type
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: "MIME type of the file. Must be a valid MIME type."
|
||||
- in: header
|
||||
name: X-File-Name
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: "URI encoded file name."
|
||||
- in: header
|
||||
name: X-Environment-ID
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: "ID of the environment."
|
||||
- in: header
|
||||
name: X-Signature
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: "Signature for verifying the request."
|
||||
- in: header
|
||||
name: X-UUID
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: "Unique identifier for the signed upload."
|
||||
- in: header
|
||||
name: X-Timestamp
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: "Timestamp used for the signature."
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
multipart/form-data:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
file:
|
||||
type: string
|
||||
format: binary
|
||||
description: "The file to be uploaded as a valid file object (buffer)."
|
||||
required:
|
||||
- file
|
||||
responses:
|
||||
"200":
|
||||
description: OK - File uploaded successfully.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
data:
|
||||
type: object
|
||||
properties:
|
||||
message:
|
||||
type: string
|
||||
description: Success message.
|
||||
example:
|
||||
data:
|
||||
message: "File uploaded successfully"
|
||||
"400":
|
||||
description: Bad Request - Missing required fields, invalid header values, or file issues.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
error:
|
||||
type: string
|
||||
description: Detailed error message.
|
||||
example:
|
||||
error: "fileType is required"
|
||||
"401":
|
||||
description: Unauthorized - Authentication failed, invalid signature, or user not authorized.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
error:
|
||||
type: string
|
||||
description: Detailed error message.
|
||||
example:
|
||||
error: "Not authenticated"
|
||||
"500":
|
||||
description: Internal Server Error - File upload failed due to server error.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
error:
|
||||
type: string
|
||||
description: Detailed error message.
|
||||
example:
|
||||
error: "File upload failed"
|
||||
servers:
|
||||
- url: https://app.formbricks.com/api/v2
|
||||
description: Formbricks API Server
|
||||
components:
|
||||
securitySchemes:
|
||||
apiKeyAuth:
|
||||
|
||||
@@ -21,5 +21,5 @@ sonar.scm.exclusions.disabled=false
|
||||
sonar.sourceEncoding=UTF-8
|
||||
|
||||
# Coverage
|
||||
sonar.coverage.exclusions=**/*.test.*,**/*.spec.*,**/constants.ts,**/route.ts,modules/**/types/**,**/*.stories.*,**/mocks/**,**/openapi.ts,**/openapi-document.ts,playwright/**
|
||||
sonar.cpd.exclusions=**/*.test.*,**/*.spec.*,**/constants.ts,**/route.ts,modules/**/types/**,**/openapi.ts,**/openapi-document.ts
|
||||
sonar.coverage.exclusions=**/*.test.*,**/*.spec.*,**/*.mdx,**/constants.ts,**/route.ts,modules/**/types/**,**/*.stories.*,**/mocks/**,**/openapi.ts,**/openapi-document.ts,playwright/**,scripts/merge-client-endpoints.ts
|
||||
sonar.cpd.exclusions=**/*.test.*,**/*.spec.*,**/*.mdx,**/constants.ts,**/route.ts,modules/**/types/**,**/openapi.ts,**/openapi-document.ts,scripts/merge-client-endpoints.ts
|
||||
|
||||
Reference in New Issue
Block a user