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

# Update Task

> Cancels an existing task in the provider's EHR.

Address the task by its EHR id: the `emr_task_id` returned in the `tasks` array of [POST /patients/fetch](https://docs.usecobalt.com/api-reference/patients/fetch.md) with `include: ["tasks"]`.

### Request Parameters

* **status** (string, required): `"cancelled"` cancels the task in the EHR.

### Example Request

```bash theme={null}
curl -X PATCH https://api.usecobalt.com/v1/tasks/ehr/38771 \
-H 'Content-Type: application/json' \
-H 'client_id: ci_live_198908HJDKJSH98789OHKJL' \
-H 'client_secret: cs_live_9827hofdsklOYYHJLJh' \
-H 'access_token: 493JKLHIU98789hLKH9HHJH' \
-d '{
    "status": "cancelled"
}'
```

### Example Response

```json theme={null}
{
  "success": true,
  "message": "Task update processing. A webhook event will be sent upon completion.",
  "emr_task_id": "38771",
  "job_id": 12345
}
```

### Webhook Events

You'll receive a `task.updated` webhook when the task is cancelled, or `task.update_failed` if it can't be. See [Operation Events](https://docs.usecobalt.com/docs/webhooks/operation-events.md).

```json theme={null}
{
  "id": "evt_abc123",
  "object": "event",
  "type": "task.updated",
  "created": "2026-11-17T22:05:00.000Z",
  "job_id": "12345",
  "access_token_reference_id": "user_123",
  "data": {
    "emr_task_id": "38771",
    "status": "cancelled"
  }
}
```


## OpenAPI

````yaml PATCH /tasks/ehr/{emr_task_id}
openapi: 3.1.0
info:
  title: Cobalt API
  version: 1.0.1
  description: API for interacting with Cobalt's EHR integration services
servers:
  - url: https://api.usecobalt.com/v1
    description: Production
security:
  - ClientCredentials: []
    ClientSecret: []
    AccessToken: []
paths:
  /tasks/ehr/{emr_task_id}:
    patch:
      tags:
        - Tasks
      summary: Update a task
      description: >-
        Queues a status change (cancel) for an existing EMR task, addressed by
        its EMR id.
      operationId: updateTaskByEhrId
      parameters:
        - name: emr_task_id
          in: path
          description: >-
            EMR ID of the task. Obtain it from the tasks[] array returned by
            POST /v1/patients/fetch with include: ["tasks"].
          schema:
            type: string
            example: task-emr-123
          required: true
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - status
              properties:
                status:
                  type: string
                  enum:
                    - cancelled
                  x-supported-emrs:
                    - eClinicalWorks
                  description: Set to "cancelled" to cancel the task in the EHR.
                  example: cancelled
                  x-required-for-emrs:
                    - eClinicalWorks
                callback_urls:
                  type: array
                  items:
                    type: string
                  x-supported-emrs:
                    - eClinicalWorks
                  description: >-
                    URLs to receive the completion webhook for this update, in
                    addition to the account webhook.
                  example:
                    - https://example.com/webhooks/cobalt
                expires_at:
                  type:
                    - string
                    - 'null'
                  format: date-time
                  x-supported-emrs:
                    - eClinicalWorks
                  description: >-
                    Optional ISO 8601 timestamp with an explicit timezone
                    offset, in the future when submitted. Cobalt starts no new
                    operation attempt after this deadline and reports
                    reasons[].code EXPIRED. An attempt already in progress,
                    including write reconciliation, may finish after it.
                  example: '2027-06-15T14:30:00Z'
      responses:
        '200':
          description: Task update queued
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  message:
                    type: string
                    example: >-
                      Task update processing. A webhook event will be sent upon
                      completion.
                  emr_task_id:
                    type: string
                    example: task-emr-123
                  job_id:
                    type: integer
                    example: 1
                required:
                  - success
                  - message
                  - emr_task_id
                  - job_id
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  responses:
    BadRequest:
      description: Bad request — missing or invalid parameters
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                enum:
                  - false
                example: false
              message:
                type: string
                example: Request could not be completed.
            required:
              - success
              - message
          example:
            success: false
            message: Bad request — missing or invalid parameters
    Unauthorized:
      description: Unauthorized — missing or invalid credentials
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                enum:
                  - false
                example: false
              message:
                type: string
                example: Request could not be completed.
            required:
              - success
              - message
          example:
            success: false
            message: Unauthorized — missing or invalid credentials
    InternalServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                enum:
                  - false
                example: false
              message:
                type: string
                example: Request could not be completed.
            required:
              - success
              - message
          example:
            success: false
            message: Internal server error
  securitySchemes:
    ClientCredentials:
      type: apiKey
      in: header
      name: client_id
    ClientSecret:
      type: apiKey
      in: header
      name: client_secret
    AccessToken:
      type: apiKey
      in: header
      name: access_token

````

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