Skip to main content
POST
/
v2
/
generate-upload-url
Generate upload URL
curl --request POST \
  --url https://typebot.io/api/v2/generate-upload-url \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "sessionId": "<string>",
  "fileName": "<string>",
  "fileType": "<string>"
}
'
{
  "presignedUrl": "<string>",
  "formData": {},
  "fileUrl": "<string>"
}
The presignedUrl and formData fields can be then used to upload the file to the S3 bucket, directly from the browser if necessary. Here is an example:
// data contains the presignedUrl and formData fields from the response

let upload

if (data.formData && Object.keys(data.formData).length > 0) {
  const formData = new FormData()
  Object.entries(data.formData).forEach(([key, value]) => {
    formData.append(key, value)
  })
  formData.append('file', file)

  upload = await fetch(data.presignedUrl, {
    method: 'POST',
    body: formData,
  })
} else {
  upload = await fetch(data.presignedUrl, {
    method: 'PUT',
    body: file,
    headers: {
      'Content-Type': file.type,
    },
  })
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
sessionId
string
required
fileName
string
required
fileType
string

Response

Successful response

presignedUrl
string
required
formData
object
required
fileUrl
string
required