> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# MediaAttachmentUploadUrl

# Package: aiSiteChat

# Namespace: Messages

# Method link: https://dev.wix.com/docs/api-reference/business-management/ai-site-chat/messages/media-attachment-upload-url.md

## Permission Scopes:
Innovation Lab User: SCOPE.INNOVATION_LAB.USER

## Introduction

Allows site visitor to create upload url to use for uploading a file.

---

## REST API

### Schema

```
 Method: mediaAttachmentUploadUrl
 Description: Allows site visitor to create upload url to use for uploading a file.
 URL: https://www.wixapis.com/wix-assistant-widget/v1/messages/files/generate-upload-url
 Method: GET
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  mimeType
 Method parameters: 
   query param name: fileName | type: fileName | description: File name  | validation: maxLength 100
   query param name: filePath | type: filePath    | validation: maxLength 100
   query param name: mimeType | type: mimeType | description: File type e.g. "image/png". | required: true | validation: maxLength 100
   query param name: parentFolderId | type: parentFolderId    | validation: maxLength 100
 Return type: MediaAttachmentUploadUrlResponse
  - name: uploadUrl | type: string | description:   | validation: format WEB_URL

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: NoMetaSiteId | Description: The call has no site visitor, site member or Wix user identity with a site context, for example an API key or app identity. Call these methods with the site visitor's or site member's identity.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: FileUploadDisabled | Description: Visitor file upload isn't allowed right now. It's allowed when Wix users handle the chat, or when the chat is offline and the site's offline behavior allows file upload.


```

### Examples

### Generate an upload URL for a media attachment
Creates an upload URL the site visitor can use to upload a file to attach to a message.

```curl
curl -X GET \
'https://www.wixapis.com/innovation/widget/v1/messages/files/generate-upload-url?mimeType=image%2Fpng&fileName=receipt.png' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.aiSiteChat.messages.mediaAttachmentUploadUrl(mimeType, options)
 Description: Allows site visitor to create upload url to use for uploading a file.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  mimeType
 Method parameters: 
   param name: mimeType | type: string | description: File type e.g. "image/png". | required: true | validation: maxLength 100
   param name: options | type: MediaAttachmentUploadUrlOptions  none  
        - name: fileName | type: string | description: File name  | validation: maxLength 100
 Return type: PROMISE<MediaAttachmentUploadUrlResponse>
  - name: uploadUrl | type: string | description:   | validation: format WEB_URL

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: NoMetaSiteId | Description: The call has no site visitor, site member or Wix user identity with a site context, for example an API key or app identity. Call these methods with the site visitor's or site member's identity.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: FileUploadDisabled | Description: Visitor file upload isn't allowed right now. It's allowed when Wix users handle the chat, or when the chat is offline and the site's offline behavior allows file upload.


```

### Examples

### Generate an upload URL for a media attachment
```javascript
import { messages } from "@wix/ai-site-chat";

const mimeType = "image/png";

const options = {
  fileName: "receipt.png",
};

async function mediaAttachmentUploadUrl() {
  const response = await messages.mediaAttachmentUploadUrl(mimeType, options);

  return response.uploadUrl;
}

/* Promise resolves to:
 * {
 *   "uploadUrl": "https://upload.wixmp.com/upload/2f6c8d1a-4b7e-4a3c-9f21-6d0e5c8b1a44"
 * }
 */

```

### mediaAttachmentUploadUrl (self-managed)
Self-managed SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { messages } from '@wix/ai-site-chat';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { messages },
  // Include the auth strategy and host as relevant
});


async function mediaAttachmentUploadUrl(mimeType,options) {
  const response = await myWixClient.messages.mediaAttachmentUploadUrl(mimeType,options);
};
```

---