> 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 # ListAttachments # Package: attachments # Namespace: ContactAttachmentsServiceV4 # Method link: https://dev.wix.com/docs/api-reference/crm/members-contacts/contacts/attachments/attachment-v4/list-attachments.md ## Permission Scopes: Manage Contact Attachments: SCOPE.DC-CONTACTS.MANAGE-CONTACT-ATTACHMENTS ## Introduction Retrieves a list of attachments associated with a specified contact. --- ## REST API ### Schema ``` Method: listAttachments Description: Retrieves a list of attachments associated with a specified contact. URL: https://www.wixapis.com/contacts/v4/attachments/{contactId} Method: GET # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: contactId Method parameters: param name: contactId | type: none | required: true param name: paging | type: Paging - name: limit | type: integer | description: Number of items to return. Default: `100` Max: `100` - name: offset | type: integer | description: Number of items to skip in the current sort order. Return type: ListAttachmentsResponse - name: attachments | type: array | description: List of attachments for the specified contact. - ONE-OF: - name: image | type: Image | description: Image details when the attachment type is `IMAGE`. - name: id | type: string | description: WixMedia image GUID. - name: url | type: string | description: Image URL. - name: height | type: integer | description: Original image height. - name: width | type: integer | description: Original image width. - name: altText | type: string | description: Image alt text. Optional. - name: urlExpirationDate | type: string | description: Image URL expiration date when relevant. - name: document | type: Document | description: Document details when the attachment type is `OTHER`. - name: id | type: string | description: WixMedia GUID. - name: url | type: string | description: Document URL. - name: urlExpirationDate | type: string | description: Document URL expiration date when relevant. - name: id | type: string | description: Attachment GUID. - name: previewImage | type: Image | description: Details of the preview image reduced size when the attachment is of type `IMAGE`. - name: fileName | type: string | description: Name of the attachment file. - name: mimeType | type: string | description: Mime type of the attachment. See [supported mime types](https://dev.wix.com/docs/rest/crm/members-contacts/contacts/attachments/attachment-v4/supported-mime-types.md). - name: attachmentType | type: AttachmentType | description: Type of the attachment. - enum: - UNKNOWN: Unknown attachment type. - IMAGE: Attachment is an image file. - OTHER: Attachment is a document or any non-image file type. - name: metadata | type: PagingMetadata | description: Metadata for the paginated results. - name: count | type: integer | description: Number of items returned in the response. - name: offset | type: integer | description: Offset that was requested. - name: total | type: integer | description: Total number of items that match the query. - name: tooManyToCount | type: boolean | description: Whether the server failed to calculate the `total` field. ``` ### Examples ### ListAttachments ```curl ~~~cURL curl -X GET \ 'https://www.wixapis.com/contacts/v4/attachments' --data-binary '{ "contactId": "513c1bfc-61b6-427d-a7f8-ceeedb1eb763" }' -H 'Content-Type: application/json' -H 'Authorization: ' ~~~ ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.attachments.ContactAttachmentsServiceV4.listAttachments(contactId, options) Description: Retrieves a list of attachments associated with a specified contact. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: contactId Method parameters: param name: contactId | type: string | description: Contact GUID for the attachments to be listed. | required: true param name: options | type: ListAttachmentsOptions none - name: paging | type: Paging | description: Allow paginating, default: limit = 100 and offset = 0 - name: limit | type: integer | description: Number of items to return. Default: `100` Max: `100` - name: offset | type: integer | description: Number of items to skip in the current sort order. Return type: PROMISE - name: attachments | type: array | description: List of attachments for the specified contact. - ONE-OF: - name: image | type: string | description: Image details when the attachment type is `IMAGE`. - name: document | type: string | description: Document details when the attachment type is `OTHER`. - name: _id | type: string | description: Attachment GUID. - name: previewImage | type: string | description: Details of the preview image reduced size when the attachment is of type `IMAGE`. - name: fileName | type: string | description: Name of the attachment file. - name: mimeType | type: string | description: Mime type of the attachment. See [supported mime types](https://dev.wix.com/docs/rest/crm/members-contacts/contacts/attachments/attachment-v4/supported-mime-types.md). - name: attachmentType | type: AttachmentType | description: Type of the attachment. - enum: - UNKNOWN: Unknown attachment type. - IMAGE: Attachment is an image file. - OTHER: Attachment is a document or any non-image file type. - name: metadata | type: PagingMetadata | description: Metadata for the paginated results. - name: count | type: integer | description: Number of items returned in the response. - name: offset | type: integer | description: Offset that was requested. - name: total | type: integer | description: Total number of items that match the query. - name: tooManyToCount | type: boolean | description: Whether the server failed to calculate the `total` field. ``` ### Examples ### List contact attachments ```javascript // @description: Retrieves a list of attachments associated with a specified contact. import { attachments } from "@wix/crm"; async function listAttachmentsExample() { const contactId = "513c1bfc-61b6-427d-a7f8-ceeedb1eb763"; const response = await attachments.listAttachments(contactId); return response; } /* Promise resolves to: * { * attachments: [ * { * _id: string, * mediaItem: { document?: { id, url }, image?: { id, url, height, width } }, * fileName: string, * mimeType: string, * attachmentType: string * } * ], * metadata: { count: number, offset: number, total: number } * } */ ``` ### listAttachments (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 listAttachments(contactId,options) { const response = await myWixClient.attachments.listAttachments(contactId,options); }; ``` ---