> 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

# CreateCustomActivity

# Package: activityLog

# Namespace: Activities

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

## Permission Scopes:
Manage Contacts: SCOPE.DC-CONTACTS.MANAGE-CONTACTS

## Introduction

Records a custom activity for a contact with a free-text message.

---

## REST API

### Schema

```
 Method: createCustomActivity
 Description: Records a custom activity for a contact with a free-text message.
 URL: https://www.wixapis.com/crm/contacts-activity-log/v1/activities/custom
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  activityDate, contactId, message
 Method parameters: 
   param name: activityDate | type: activityDate | description: Date and time the activity occurred. | required: true | validation: format date-time
   param name: contactId | type: contactId | description: GUID of the contact to record the activity for. | required: true | validation: format GUID
   param name: message | type: message | description: Free-text description of the activity. | required: true | validation: maxLength 2000
 Return type: CreateCustomActivityResponse
  - name: activity | type: Activity | description: Created activity.  
     - 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 

 Possible Errors:
   HTTP Code: 401 | Status Code: UNAUTHENTICATED | Application Code: MISSING_METASITE_IN_CONTEXT | Description: The request is missing a site context. Make sure you're calling this method in the context of a site.


```

### Examples

### Create a custom activity
Record a free-text activity for a contact. The `message` field in the response is empty; the text is stored in `params.MessageContent` and populated into `message` when the activity is retrieved via List Activities.

```curl
curl -X POST \
'https://www.wixapis.com/crm/contacts-activity-log/v1/activities/custom' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
  "activityDate": "2024-06-15T14:00:00.000Z",
  "contactId": "7867990e-45f0-47ee-bb7b-f01960bdda2f",
  "message": "Spoke with John about his upcoming renewal. He confirmed he wants to stay on the premium plan."
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.contactsActivityLogActivities.contactsActivityLogActivities.createCustomActivity(activityDate, options)
 Description: Records a custom activity for a contact with a free-text message.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  activityDate, options.contactId, options.message, options
 Method parameters: 
   param name: activityDate | type: string | description: Date and time the activity occurred. | required: true | validation: format date-time
   param name: options | type: CreateCustomActivityOptions  none | required: true 
        - name: contactId | type: string | description: GUID of the contact to record the activity for. | required: true | validation: format GUID
        - name: message | type: string | description: Free-text description of the activity. | required: true | validation: maxLength 2000
 Return type: PROMISE<CreateCustomActivityResponse>
  - name: activity | type: Activity | description: Created activity.  
     - 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 

 Possible Errors:
   HTTP Code: 401 | Status Code: UNAUTHENTICATED | Application Code: MISSING_METASITE_IN_CONTEXT | Description: The request is missing a site context. Make sure you're calling this method in the context of a site.


```

### Examples

### Create a custom activity
Record a free-text activity for a contact.

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

async function createCustomActivity() {
  const response = await wixCrmContactsActivityLogV1Activity.createCustomActivity(
    new Date("2024-06-15T09:30:00.000Z"),
    {
      contactId: "7867990e-45f0-47ee-bb7b-f01960bdda2f",
      message: "Called to confirm the follow-up appointment for next week.",
    },
  );
}

```

### createCustomActivity (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 createCustomActivity(activityDate,options) {
  const response = await myWixClient.contactsActivityLogActivities.createCustomActivity(activityDate,options);
};
```

---