> 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`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # GenerateAttachmentUploadUrl # Package: attachments # Namespace: ContactAttachmentsServiceV4 # Method link: https://dev.wix.com/docs/api-reference/crm/members-contacts/contacts/attachments/attachment-v4/generate-attachment-upload-url.md ## Permission Scopes: Manage Contact Attachments: SCOPE.DC-CONTACTS.MANAGE-CONTACT-ATTACHMENTS ## Introduction Generates an upload URL for uploading a file as an attachment to a specified contact. To learn how to use the generated upload URL in the response to upload an attachment file, see the [Upload API](https://dev.wix.com/docs/rest/assets/media/media-manager/files/upload-api.md). --- ## REST API ### Schema ``` Method: generateAttachmentUploadUrl Description: Generates an upload URL for uploading a file as an attachment to a specified contact. To learn how to use the generated upload URL in the response to upload an attachment file, see the [Upload API](https://dev.wix.com/docs/rest/assets/media/media-manager/files/upload-api.md). URL: https://www.wixapis.com/contacts/v4/attachments/{contactId}/upload-url Method: POST # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: fileName, mimeType Method parameters: param name: fileName | type: fileName | description: File name of the attachment including the extension, for example, `contact-cv.pdf`. | required: true param name: mimeType | type: mimeType | description: Mime type of the attachment file, for example, `application/pdf`. See [supported mime types](https://dev.wix.com/docs/rest/crm/members-contacts/contacts/attachments/attachment-v4/supported-mime-types.md). | required: true Return type: GenerateAttachmentUploadUrlResponse - name: uploadUrl | type: string | description: The URL for uploading a file as an attachment to the contact. ``` ### Examples ### GenerateAttachmentUploadUrl ```curl ~~~cURL curl -X POST \ 'https://www.wixapis.com/contacts/v4/attachments/513c1bfc-61b6-427d-a7f8-ceeedb1eb763/upload-url' \ -H 'Authorization: ' \ --data-binary '{ "contactId": "513c1bfc-61b6-427d-a7f8-ceeedb1eb763", "fileName": "my-data.csv", "mimeType": "text/csv" }' ~~~ ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.attachments.ContactAttachmentsServiceV4.generateAttachmentUploadUrl(contactId, fileName, options) Description: Generates an upload URL for uploading a file as an attachment to a specified contact. To learn how to use the generated upload URL in the response to upload an attachment file, see the [Upload API](https://dev.wix.com/docs/rest/assets/media/media-manager/files/upload-api.md). # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: contactId, fileName, options.mimeType, options Method parameters: param name: contactId | type: string | description: GUID of the contact for whom the attachment is being uploaded. | required: true param name: fileName | type: string | description: File name of the attachment including the extension, for example, `contact-cv.pdf`. | required: true param name: options | type: GenerateAttachmentUploadUrlOptions none | required: true - name: mimeType | type: string | description: Mime type of the attachment file, for example, `application/pdf`. See [supported mime types](https://dev.wix.com/docs/rest/crm/members-contacts/contacts/attachments/attachment-v4/supported-mime-types.md). | required: true Return type: PROMISE - name: uploadUrl | type: string | description: The URL for uploading a file as an attachment to the contact. ``` ### Examples ### Generate attachment upload URL ```javascript // @description: Generates a secure upload URL for uploading a file as an attachment to a contact. import { attachments } from "@wix/crm"; async function generateAttachmentUploadUrlExample() { const contactId = "513c1bfc-61b6-427d-a7f8-ceeedb1eb763"; const fileName = "my-data.csv"; const response = await attachments.generateAttachmentUploadUrl(contactId, fileName, { mimeType: "text/csv", }); return response; } /* Promise resolves to: * { * uploadUrl: string * } */ ``` ### generateAttachmentUploadUrl (self-hosted) Self-hosted 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 { attachments } from '@wix/crm'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { attachments }, // Include the auth strategy and host as relevant }); async function generateAttachmentUploadUrl(contactId,fileName,options) { const response = await myWixClient.attachments.generateAttachmentUploadUrl(contactId,fileName,options); }; ``` ---