> ## Documentation Index
> Fetch the complete documentation index at: https://docs.typebot.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate upload URL

> Used to upload anything from the client to S3 bucket

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:

```js theme={null}
// 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,
    },
  })
}
```


## OpenAPI

````yaml openapi/viewer.json POST /v3/generate-upload-url
openapi: 3.1.1
info:
  title: Chat API
  version: 3.0.0
servers:
  - url: https://typebot.io/api
security: []
externalDocs:
  url: https://docs.typebot.com/api-reference
paths:
  /v3/generate-upload-url:
    post:
      tags:
        - File upload
      summary: Generate upload URL
      description: Used to upload anything from the client to S3 bucket
      operationId: generateUploadUrl
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                sessionId:
                  type: string
                blockId:
                  type: string
                fileName:
                  type: string
                fileType:
                  type: string
                fileSize:
                  type: number
              required:
                - sessionId
                - blockId
                - fileName
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  presignedUrl:
                    type: string
                  formData:
                    type: object
                    propertyNames:
                      type: string
                    additionalProperties:
                      type: string
                  fileType:
                    type: string
                  maxFileSize:
                    type: number
                  fileUrl:
                    type: string
                required:
                  - presignedUrl
                  - formData
                  - fileUrl
        '400':
          description: '400'
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      defined:
                        const: true
                      code:
                        const: BAD_REQUEST
                      status:
                        const: 400
                      message:
                        type: string
                        default: Bad Request
                      data: {}
                    required:
                      - defined
                      - code
                      - status
                      - message
                  - type: object
                    properties:
                      defined:
                        const: false
                      code:
                        type: string
                      status:
                        type: number
                      message:
                        type: string
                      data: {}
                    required:
                      - defined
                      - code
                      - status
                      - message
        '401':
          description: '401'
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      defined:
                        const: true
                      code:
                        const: UNAUTHORIZED
                      status:
                        const: 401
                      message:
                        type: string
                        default: Unauthorized
                      data: {}
                    required:
                      - defined
                      - code
                      - status
                      - message
                  - type: object
                    properties:
                      defined:
                        const: false
                      code:
                        type: string
                      status:
                        type: number
                      message:
                        type: string
                      data: {}
                    required:
                      - defined
                      - code
                      - status
                      - message
        '403':
          description: '403'
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      defined:
                        const: true
                      code:
                        const: FORBIDDEN
                      status:
                        const: 403
                      message:
                        type: string
                        default: Forbidden
                      data: {}
                    required:
                      - defined
                      - code
                      - status
                      - message
                  - type: object
                    properties:
                      defined:
                        const: false
                      code:
                        type: string
                      status:
                        type: number
                      message:
                        type: string
                      data: {}
                    required:
                      - defined
                      - code
                      - status
                      - message
        '404':
          description: '404'
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      defined:
                        const: true
                      code:
                        const: NOT_FOUND
                      status:
                        const: 404
                      message:
                        type: string
                        default: Not Found
                      data: {}
                    required:
                      - defined
                      - code
                      - status
                      - message
                  - type: object
                    properties:
                      defined:
                        const: false
                      code:
                        type: string
                      status:
                        type: number
                      message:
                        type: string
                      data: {}
                    required:
                      - defined
                      - code
                      - status
                      - message
        '500':
          description: '500'
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      defined:
                        const: true
                      code:
                        const: INTERNAL_SERVER_ERROR
                      status:
                        const: 500
                      message:
                        type: string
                        default: Internal Server Error
                      data: {}
                    required:
                      - defined
                      - code
                      - status
                      - message
                  - type: object
                    properties:
                      defined:
                        const: false
                      code:
                        type: string
                      status:
                        type: number
                      message:
                        type: string
                      data: {}
                    required:
                      - defined
                      - code
                      - status
                      - message

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.