> 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

# GetTask

# Package: crm

# Namespace: Tasks

# Method link: https://dev.wix.com/docs/api-reference/crm/crm/tasks/get-task.md

## Permission Scopes:
Read Tasks: SCOPE.DC-CRM.READ-TASKS

## Introduction

Retrieves a task by ID.

---

## REST API

### Schema

```
 Method: getTask
 Description: Retrieves a task by GUID.
 URL: https://www.wixapis.com/crm/tasks/v2/tasks/{taskId}
 Method: GET
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  taskId
 Method parameters: 
   param name: taskId | type:   none | required: true 
 Return type: GetTaskResponse
  - name: task | type: Task | description: The retrieved task.  
     - name: id | type: string | description: Task GUID.  | read-only: true | validation: format GUID
     - name: revision | type: string | description: Revision number, which increments by 1 each time the task is updated. To prevent conflicting changes, the existing `revision` must be used when updating a task.  | read-only: true | validation: format int64
     - name: title | type: string | description: Title of the task.  | validation: minLength 1, maxLength 250
     - name: description | type: string | description: Description of the task.  | validation: minLength 1, maxLength 500
     - name: createdDate | type: string | description: Date and time the task was created.  | read-only: true | validation: format date-time
     - name: updatedDate | type: string | description: Date and time the task was last updated.  | read-only: true | validation: format date-time
     - name: dueDate | type: string | description: Due date for the task.  | validation: format date-time
     - name: status | type: TaskStatus | description: Status of the task.  Default: `ACTION_NEEDED`  
         - enum:
         -     ACTION_NEEDED: Action needed.
         -     COMPLETED: Task completed.
     - name: source | type: TaskSource | description: Details about the task source.  
        - name: sourceType | type: SourceType | description: How the task was created.  | read-only: true 
             - enum:
             -     APP: Task was created by an app.
             -     USER: Task was created by a Wix user.
        - name: appId | type: string | description: App GUID, if the task was created by an app.  | read-only: true | validation: format GUID
        - name: userId | type: string | description: User GUID, if the task was created by a Wix user.  | read-only: true | validation: format GUID
     - name: contact | type: ContactInfo | description: Information about the contact associated with the task.  
        - name: id | type: string | description: GUID of the contact associated with the task.  | validation: format GUID
        - name: firstName | type: string | description: Contact's first name.  | read-only: true 
        - name: lastName | type: string | description: Contact's last name.  | read-only: true 
        - name: imageUrl | type: string | description: Contact's image URL.  | read-only: true 
        - name: email | type: string | description: Contact's primary email.  | read-only: true 
        - name: phone | type: string | description: Contact's primary phone.  | read-only: true 
        - name: imageUrlExpirationDate | type: string | description: Image URL expiration date.  | read-only: true | validation: format date-time


```

### Examples

### Get Task
Gets a Task

```curl
curl -X GET \
  'https://www.wixapis.com/crm/tasks/v2/tasks/4973f73a-40ef-11ee-be56-0242ac120002' \
  -H 'Authorization: <AUTH>'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.crm.tasks.getTask(taskId)
 Description: Retrieves a task by GUID.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  taskId
 Method parameters: 
   param name: taskId | type: string | description: GUID of the task to retrieve. | required: true | validation: format GUID
 Return type: PROMISE<Task>
  - name: _id | type: string | description: Task GUID.  | read-only: true | validation: format GUID
  - name: revision | type: string | description: Revision number, which increments by 1 each time the task is updated. To prevent conflicting changes, the existing `revision` must be used when updating a task.  | read-only: true | validation: format int64
  - name: title | type: string | description: Title of the task.  | validation: minLength 1, maxLength 250
  - name: description | type: string | description: Description of the task.  | validation: minLength 1, maxLength 500
  - name: _createdDate | type: Date | description: Date and time the task was created.  | read-only: true 
  - name: _updatedDate | type: Date | description: Date and time the task was last updated.  | read-only: true 
  - name: dueDate | type: Date | description: Due date for the task.  
  - name: status | type: TaskStatus | description: Status of the task.  Default: `ACTION_NEEDED`  
     - enum:
     -     ACTION_NEEDED: Action needed.
     -     COMPLETED: Task completed.
  - name: source | type: TaskSource | description: Details about the task source.  
     - name: sourceType | type: SourceType | description: How the task was created.  | read-only: true 
         - enum:
         -     APP: Task was created by an app.
         -     USER: Task was created by a Wix user.
     - name: appId | type: string | description: App GUID, if the task was created by an app.  | read-only: true | validation: format GUID
     - name: userId | type: string | description: User GUID, if the task was created by a Wix user.  | read-only: true | validation: format GUID
  - name: contact | type: ContactInfo | description: Information about the contact associated with the task.  
     - name: _id | type: string | description: GUID of the contact associated with the task.  | validation: format GUID
     - name: firstName | type: string | description: Contact's first name.  | read-only: true 
     - name: lastName | type: string | description: Contact's last name.  | read-only: true 
     - name: imageUrl | type: string | description: Contact's image URL.  | read-only: true 
     - name: email | type: string | description: Contact's primary email.  | read-only: true 
     - name: phone | type: string | description: Contact's primary phone.  | read-only: true 
     - name: imageUrlExpirationDate | type: Date | description: Image URL expiration date.  | read-only: true 


```

### Examples

### Get a task (with elevated permissions)
```javascript
import { tasks } from '@wix/crm';
import { auth } from '@wix/essentials';

/* Sample taskId value:
* '3194f3f2-945f-4810-8905-d02b24f9e790'
*/

const elevatedGetTask = auth.elevate(tasks.getTask);

export async function myGetTaskFunction(taskId) {
    
  try {
    const task = await elevatedGetTask(taskId);
      
    return task;
  } catch(error){
    console.log(error);
    // Handle the error
  }
}

/* Promise resolves to:
 * { 
 *   "revision": "1",
 *   "title": "Follow up",
 *   "description": "Send a follow up email",
 *   "status": "ACTION_NEEDED",
 *   "source": {
 *     "sourceType": "APP",
 *     "appId": "151e476a-715e-ec33-db9a-a7ff4d51f70a"
 *   },
 *   "contact": {
 *     "firstName": "Sally",
 *     "lastName": "Smith",
 *     "email": "sally.smith@example.com",
 *     "phone": "+1 524-624-2486",
 *     "_id": "5518ee7f-270e-40c4-b756-dad56e8f0ffc"
 *   },
 *   "_id": "3194f3f2-945f-4810-8905-d02b24f9e790",
 *   "_createdDate": "2024-01-18T11:35:29.092Z",
 *   "_updatedDate": "2024-01-18T11:35:29.092Z"
 * }
 */
```

### Get a task
```javascript

import { tasks } from '@wix/crm';

/* Sample taskId value:
 * '3194f3f2-945f-4810-8905-d02b24f9e790'
 */

export async function myGetTaskFunction(taskId) {
    
  try {
    const task = await tasks.getTask(taskId);
      
    return task;
  } catch(error){
    console.log(error);
    // Handle the error
  }
}

/* Promise resolves to:
 * { 
 *   "revision": "1",
 *   "title": "Follow up",
 *   "description": "Send a follow up email",
 *   "status": "ACTION_NEEDED",
 *   "source": {
 *     "sourceType": "APP",
 *     "appId": "151e476a-715e-ec33-db9a-a7ff4d51f70a"
 *   },
 *   "contact": {
 *     "firstName": "Sally",
 *     "lastName": "Smith",
 *     "email": "sally.smith@example.com",
 *     "phone": "+1 524-624-2486",
 *     "_id": "5518ee7f-270e-40c4-b756-dad56e8f0ffc"
 *   },
 *   "_id": "3194f3f2-945f-4810-8905-d02b24f9e790",
 *   "_createdDate": "2024-01-18T11:35:29.092Z",
 *   "_updatedDate": "2024-01-18T11:35:29.092Z"
 * }
 */

```

### getTask (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 { tasks } from '@wix/crm';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

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


async function getTask(taskId) {
  const response = await myWixClient.tasks.getTask(taskId);
};
```

---