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

# PATCH /v1/crm/tasks/:id

> Partially update a task — advance its status, reassign it, or move its due date.

Updates a task in place. Only the fields you send are written. Completing a task is a status change, not a separate endpoint.

## Endpoint

```
PATCH https://api.keebai.com/v1/crm/tasks/{id}
```

## Required scope

`crm:tasks:write`

## Headers

| Header          | Required | Value                    |
| --------------- | -------- | ------------------------ |
| `Authorization` | Yes      | `Bearer kbai_pk_<token>` |
| `Content-Type`  | Yes      | `application/json`       |

## Path parameters

| Field | Type     | Required | Description             |
| ----- | -------- | -------- | ----------------------- |
| `id`  | `string` | Yes      | `ObjectId` of the task. |

## Body

All fields optional. Send only what changes.

| Field         | Type     | Description                               |
| ------------- | -------- | ----------------------------------------- |
| `title`       | `string` | What has to be done.                      |
| `description` | `string` | Longer detail.                            |
| `assigned_to` | `string` | `ObjectId` of the new owner.              |
| `status`      | `string` | Free-form status, e.g. `completed`.       |
| `priority`    | `string` | One of `low`, `medium`, `high`, `urgent`. |
| `due_at`      | `string` | Due date in ISO 8601.                     |

## Example request

<CodeGroup>
  ```bash curl theme={null}
  curl -X PATCH https://api.keebai.com/v1/crm/tasks/65a1f2b3c4d5e6f7a8b9c0d1 \
    -H "Authorization: Bearer kbai_pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
    -H "Content-Type: application/json" \
    -d '{ "status": "completed" }'
  ```

  ```js JavaScript theme={null}
  const response = await fetch(`https://api.keebai.com/v1/crm/tasks/${taskId}`, {
    method: "PATCH",
    headers: {
      Authorization: `Bearer ${process.env.KEEBAI_API_TOKEN}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ status: "completed" }),
  });
  const { task } = await response.json();
  ```

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

  resp = requests.patch(
      f"https://api.keebai.com/v1/crm/tasks/{task_id}",
      headers={"Authorization": f"Bearer {os.environ['KEEBAI_API_TOKEN']}"},
      json={"status": "completed"},
      timeout=10,
  )
  resp.raise_for_status()
  task = resp.json()["task"]
  ```
</CodeGroup>

## Response

### 200 OK

Returns the updated task, same shape as [`GET /v1/crm/tasks/:id`](/dev/endpoints/crm-task-get).

### 400 Bad Request

A `due_at` that is not valid ISO 8601, a `priority` outside the allowed set, or a property the endpoint does not accept.

### 401 Unauthorized

Missing, invalid, revoked, or expired token.

### 403 Forbidden

The token does not have the `crm:tasks:write` scope.

### 404 Not Found

No task with that id, or the task belongs to a different company.

## Operational notes

* **`status` is not validated against a list.** A typo like `complete` is accepted and stored, and the task then drops out of any `?status=completed` filter. Pin the exact strings your integration writes.


## OpenAPI

````yaml PATCH /v1/crm/tasks/{id}
openapi: 3.0.0
info:
  title: Keebai Public API
  description: Superficie pública REST autenticada con Personal Access Tokens (PAT).
  version: 1.0.0
  contact: {}
servers:
  - url: https://api.keebai.com
    description: Production
security: []
tags: []
paths:
  /v1/crm/tasks/{id}:
    patch:
      tags:
        - crm-tasks
      summary: Actualizar una tarea
      operationId: PublicTasksController_update
      parameters:
        - name: id
          required: true
          in: path
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PublicTaskUpdateDto'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicTaskEnvelopeDto'
      security:
        - PAT: []
components:
  schemas:
    PublicTaskUpdateDto:
      type: object
      properties:
        title:
          type: string
        assigned_to:
          type: string
        status:
          type: string
        priority:
          type: string
          enum:
            - low
            - medium
            - high
            - urgent
        due_at:
          type: string
          description: Vencimiento en ISO 8601
        description:
          type: string
    PublicTaskEnvelopeDto:
      type: object
      properties:
        task:
          $ref: '#/components/schemas/PublicTaskResponseDto'
      required:
        - task
    PublicTaskResponseDto:
      type: object
      properties:
        _id:
          type: string
          description: ObjectId de la tarea
        title:
          type: string
        description:
          type: string
        status:
          type: string
          description: >-
            Estado libre. Los valores del portal son pending, in_progress,
            completed y cancelled.
        priority:
          type: string
          enum:
            - low
            - medium
            - high
            - urgent
        assigned_to:
          type: string
          description: ObjectId del usuario asignado
        due_at:
          type: string
          format: date-time
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      required:
        - _id
        - title
        - status
        - priority
        - created_at
        - updated_at
  securitySchemes:
    PAT:
      scheme: bearer
      bearerFormat: kbai_pk_<hex>
      type: http
      description: >-
        Personal Access Token con prefijo `kbai_pk_`. Generar desde el portal
        con permiso `developer.manage_tokens`.

````