> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lyzr.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Task

Endpoint: `POST /v2/task/`

This endpoint allows users to create a new chat task. This task enables the agent to handle more complex, ongoing interactions or tasks that require multiple steps or extended processing time. The request includes details such as the user ID, agent ID, session ID, and the message. Once the task is created, a unique task ID is returned to track the progress of the task.

#### Parameters

<ParamField path="user_id " type="string" required>
  The unique identifier of the user initiating the task.
</ParamField>

<ParamField path="agent_id " type="string" required>
  The unique identifier of the agent assigned to the task.
</ParamField>

<ParamField path="session_id " type="string" required>
  The session ID to maintain task context across multiple queries.
</ParamField>

<ParamField path="message " type="string" required>
  The user's message or request that defines the task.
</ParamField>

<CodeGroup>
  <RequestExample>
    ```bash Curl theme={null}
    curl -X POST "https://agent.api.lyzr.app/v2/task/" \
     -H "accept: application/json"\
     -H "content-type: application/json"\
     -H "x-api-key: your_Lyzr_API_Key_Here" \
     -d '{
               "user_id": "user123",
               "agent_id": "60d0fe4f531xxxxxx",
               "session_id": "session123",
               "message": "Initiate a complex task for me."
             }'
    ```

    ```python Python theme={null}
    import requests

    url = "https://agent.api.lyzr.app/v2/task/"

    data = {
        "user_id": "user123",  # Replace with actual user ID
        "agent_id": "60d0fe4f531xxxxxx",  # Replace with actual agent ID
        "session_id": "session123",  # Replace with actual session ID
        "message": "Initiate a complex task for me."  # Replace with actual task message
    }

    headers = {
        "Content-Type": "application/json",
        "x-api-key": "your_Lyzr_API_Key_Here"
    }

    response = requests.post(url, headers=headers, json=data)
    ```
  </RequestExample>
</CodeGroup>

<ResponseExample>
  ```json 200 theme={null}
  {
    "task_id": "91b97d32-0e60-4e75-8xxxxxx"
  }
  ```
</ResponseExample>

#### Response Parameters

<ParamField path="task_id" type="string">
  The unique identifier for the created task.
</ParamField>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.