> 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

# ListActivities

# Package: activityLog

# Namespace: Activities

# Method link: https://dev.wix.com/docs/api-reference/crm/members-contacts/contacts/activity-log/activity-v1/list-activities.md

## Permission Scopes:
Read Contacts: SCOPE.DC-CONTACTS.READ-CONTACTS

## Introduction

Retrieves a contact's activities, ordered from most recent to oldest.

`contactId` is required for the first call. When paginating with `cursorPaging` on subsequent calls, pass only `cursorPaging.cursor`. Don't pass `contactId`, `categoryId`, `fromDate`, or `toDate` together with a cursor, as the cursor already carries those values. To learn about cursor paging, see [Sorting and Paging](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-sorting-and-paging.md).

---

## REST API

### Schema

```
 Method: listActivities
 Description: Retrieves a contact's activities, ordered from most recent to oldest.  `contactId` is required for the first call. When paginating with `cursorPaging` on subsequent calls, pass only `cursorPaging.cursor`. Don't pass `contactId`, `categoryId`, `fromDate`, or `toDate` together with a cursor, as the cursor already carries those values. To learn about cursor paging, see [Sorting and Paging](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-sorting-and-paging.md).
 URL: https://www.wixapis.com/crm/contacts-activity-log/v1/activities
 Method: GET
 Method parameters:
   query param name: categoryId | type: categoryId | description: GUID of a category to filter activities by. Can't be used together with `cursorPaging`. To retrieve available category GUIDs, call [List Categories](https://dev.wix.com/docs/api-reference/crm/members-contacts/contacts/activity-log/template-v1/list-categories.md).  | validation: format GUID
   query param name: contactId | type: contactId | description: GUID of the contact whose activities to retrieve. Required if `cursorPaging` isn't provided.  | validation: format GUID
   param name: cursorPaging | type: CursorPaging    
        - name: limit | type: integer | description: Number of items to load.  | validation: minimum 0, maximum 100, format int32
        - name: cursor | type: string | description: Pointer to the next or previous page in the list of results.  You can get the relevant cursor token from the `pagingMetadata` object in the previous call's response. Not relevant for the first request.  | validation: maxLength 16000
   query param name: fromDate | type: fromDate | description: Earliest activity date to include in results, inclusive. Can't be used together with `cursorPaging`.  | validation: format date-time
   query param name: language | type: language | description: 2-letter language code in ISO 639-1 alpha-2 format. Determines the language of the `message` field for activities created by Wix from a template. Custom activity messages are always returned as provided, regardless of this parameter.  Default: Language from the request context, or `en`.  | validation: format LANGUAGE
   query param name: toDate | type: toDate | description: Latest activity date to include in results, inclusive. Can't be used together with `cursorPaging`.  | validation: format date-time
 Return type: ListActivitiesResponse
  - name: activities | type: array<Activity> | description: Retrieved activities.  
     - name: id | type: string | description: Activity GUID.  | read-only: true | validation: maxLength 300
     - name: activityDate | type: string | description: Date and time the activity occurred.  | validation: format date-time, immutable
     - name: contactId | type: string | description: GUID of the contact the activity is associated with.  | validation: format GUID, immutable
     - name: message | type: string | description: Activity message. For activities created by Wix from a template, this is generated from the template's wording and the supplied `params`, and returned in the language specified by the `language` parameter in [List Activities](https://dev.wix.com/docs/api-reference/crm/members-contacts/contacts/activity-log/activity-v1/list-activities.md). For custom activities you create with [Create Custom Activity](https://dev.wix.com/docs/api-reference/crm/members-contacts/contacts/activity-log/activity-v1/create-custom-activity.md), this is the free-text `message` you provided.  | read-only: true | validation: maxLength 2000
     - name: templateId | type: string | description: GUID of the template used to create this activity. For custom activities you create with [Create Custom Activity](https://dev.wix.com/docs/api-reference/crm/members-contacts/contacts/activity-log/activity-v1/create-custom-activity.md), this is the GUID of the Generic template.  | validation: format GUID, immutable
     - name: params | type: object | description: Parameter values used to compose the activity message, as a key-value map. For activities created by Wix from a template, keys correspond to the template's `activityParams` keys.  | read-only: true 
  - name: metadata | type: PagingMetadataV2 | description: Paging metadata, including a `next` cursor for retrieving the next page of results.  
     - name: count | type: integer | description: Number of items returned in the response.  | validation: format int32
     - name: offset | type: integer | description: Offset that was requested.  | validation: format int32
     - name: total | type: integer | description: Total number of items that match the request. Returned when offset paging is used and `tooManyToCount` is `false`.  | validation: format int32
     - name: tooManyToCount | type: boolean | description: Whether the server failed to calculate `total`. If `true`, `total` is omitted.  
     - name: cursors | type: Cursors | description: Cursors for navigating between result pages. Returned when cursor paging is used.  
        - name: next | type: string | description: Cursor for the next page of results. Pass this value in `cursorPaging.cursor` to retrieve the next page.  | validation: maxLength 16000
        - name: prev | type: string | description: Cursor for the previous page of results.  | validation: maxLength 16000

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: MISSING_CONTACT_ID | Description: `contactId` is required when no cursor is provided. Pass a contact GUID on the first call, or pass `cursorPaging.cursor` from the previous response to retrieve the next page.


```

### Examples

### List activities for a contact
Retrieve a contact's activities, ordered from most recent to oldest.

```curl
curl -X GET \
'https://www.wixapis.com/crm/contacts-activity-log/v1/activities?contactId=7867990e-45f0-47ee-bb7b-f01960bdda2f' \
-H 'Authorization: <AUTH>'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.contactsActivityLogActivities.contactsActivityLogActivities.listActivities(options)
 Description: Retrieves a contact's activities, ordered from most recent to oldest.  `contactId` is required for the first call. When paginating with `cursorPaging` on subsequent calls, pass only `cursorPaging.cursor`. Don't pass `contactId`, `categoryId`, `fromDate`, or `toDate` together with a cursor, as the cursor already carries those values. To learn about cursor paging, see [Sorting and Paging](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-sorting-and-paging.md).
 Method parameters:
   param name: options | type: ListActivitiesOptions  none  
        - name: cursorPaging | type: CursorPaging | description: Cursor token for retrieving subsequent pages. Pass `metadata.cursors.next` from the previous response. When providing a cursor, don't pass `contactId`, `categoryId`, `fromDate`, or `toDate`.  
           - name: limit | type: integer | description: Number of items to load.  | validation: minimum 0, maximum 100, format int32
           - name: cursor | type: string | description: Pointer to the next or previous page in the list of results.  You can get the relevant cursor token from the `pagingMetadata` object in the previous call's response. Not relevant for the first request.  | validation: maxLength 16000
        - name: contactId | type: string | description: GUID of the contact whose activities to retrieve. Required if `cursorPaging` isn't provided.  | validation: format GUID
        - name: categoryId | type: string | description: GUID of a category to filter activities by. Can't be used together with `cursorPaging`. To retrieve available category GUIDs, call [List Categories](https://dev.wix.com/docs/api-reference/crm/members-contacts/contacts/activity-log/template-v1/list-categories.md).  | validation: format GUID
        - name: fromDate | type: Date | description: Earliest activity date to include in results, inclusive. Can't be used together with `cursorPaging`.  
        - name: toDate | type: Date | description: Latest activity date to include in results, inclusive. Can't be used together with `cursorPaging`.  
        - name: language | type: string | description: 2-letter language code in ISO 639-1 alpha-2 format. Determines the language of the `message` field for activities created by Wix from a template. Custom activity messages are always returned as provided, regardless of this parameter.  Default: Language from the request context, or `en`.  | validation: format LANGUAGE
 Return type: PROMISE<ListActivitiesResponse>
  - name: activities | type: array<Activity> | description: Retrieved activities.  
     - name: _id | type: string | description: Activity GUID.  | read-only: true | validation: maxLength 300
     - name: activityDate | type: Date | description: Date and time the activity occurred.  | validation: immutable
     - name: contactId | type: string | description: GUID of the contact the activity is associated with.  | validation: format GUID, immutable
     - name: message | type: string | description: Activity message. For activities created by Wix from a template, this is generated from the template's wording and the supplied `params`, and returned in the language specified by the `language` parameter in [List Activities](https://dev.wix.com/docs/api-reference/crm/members-contacts/contacts/activity-log/activity-v1/list-activities.md). For custom activities you create with [Create Custom Activity](https://dev.wix.com/docs/api-reference/crm/members-contacts/contacts/activity-log/activity-v1/create-custom-activity.md), this is the free-text `message` you provided.  | read-only: true | validation: maxLength 2000
     - name: templateId | type: string | description: GUID of the template used to create this activity. For custom activities you create with [Create Custom Activity](https://dev.wix.com/docs/api-reference/crm/members-contacts/contacts/activity-log/activity-v1/create-custom-activity.md), this is the GUID of the Generic template.  | validation: format GUID, immutable
     - name: params | type: object | description: Parameter values used to compose the activity message, as a key-value map. For activities created by Wix from a template, keys correspond to the template's `activityParams` keys.  | read-only: true 
  - name: metadata | type: PagingMetadataV2 | description: Paging metadata, including a `next` cursor for retrieving the next page of results.  
     - name: count | type: integer | description: Number of items returned in the response.  | validation: format int32
     - name: offset | type: integer | description: Offset that was requested.  | validation: format int32
     - name: total | type: integer | description: Total number of items that match the request. Returned when offset paging is used and `tooManyToCount` is `false`.  | validation: format int32
     - name: tooManyToCount | type: boolean | description: Whether the server failed to calculate `total`. If `true`, `total` is omitted.  
     - name: cursors | type: Cursors | description: Cursors for navigating between result pages. Returned when cursor paging is used.  
        - name: next | type: string | description: Cursor for the next page of results. Pass this value in `cursorPaging.cursor` to retrieve the next page.  | validation: maxLength 16000
        - name: prev | type: string | description: Cursor for the previous page of results.  | validation: maxLength 16000

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: MISSING_CONTACT_ID | Description: `contactId` is required when no cursor is provided. Pass a contact GUID on the first call, or pass `cursorPaging.cursor` from the previous response to retrieve the next page.


```

### Examples

### List a contact's activities
Retrieve activities for a contact, most recent first. Pass metadata.cursors.next in cursorPaging.cursor to retrieve additional pages.

```javascript
import { wixCrmContactsActivityLogV1Activity } from "@wix/dev";

async function listActivities() {
  const response = await wixCrmContactsActivityLogV1Activity.listActivities(
    {
      contactId: "7867990e-45f0-47ee-bb7b-f01960bdda2f",
    },
  );
}

/* Promise resolves to:
 * {
 *   "activities": [
 *     {
 *       "_id": "1718460000000/b8f3a2c5-7e1d-4a9b-bc35-8f7c4d2e1a6b",
 *       "activityDate": "2024-06-15T14:00:00.000Z",
 *       "contactId": "7867990e-45f0-47ee-bb7b-f01960bdda2f",
 *       "message": "Submitted the form 'Contact Us'.",
 *       "templateId": "25c2a6cc-40c2-4883-ab09-6e7fcd7d0342",
 *       "params": {
 *         "FormName": "Contact Us",
 *         "FormURL": "https://example.com/contact"
 *       }
 *     },
 *     {
 *       "_id": "1718443800000/e5a7c3b1-2d4f-4890-a6c8-7f3e2b1d9a0c",
 *       "activityDate": "2024-06-15T09:30:00.000Z",
 *       "contactId": "7867990e-45f0-47ee-bb7b-f01960bdda2f",
 *       "message": "Called to confirm the follow-up appointment for next week.",
 *       "templateId": "e1c5a6ad-c926-450b-99e0-49057d7e46f4",
 *       "params": {
 *         "MessageContent": "Called to confirm the follow-up appointment for next week."
 *       }
 *     }
 *   ],
 *   "metadata": {
 *     "count": 2,
 *     "cursors": {}
 *   }
 * }
 */

```

### listActivities (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 { contactsActivityLogActivities } from '@wix/contacts-activity-log-activities';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

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


async function listActivities(options) {
  const response = await myWixClient.contactsActivityLogActivities.listActivities(options);
};
```

---