---
title: Update Kapacitor Flux tasks
description: Use the kapacitor CLI or the Kapacitor HTTP API to update Kapacitor Flux tasks.
url: https://docs.influxdata.com/kapacitor/v1/working/flux/manage/update/
estimated_tokens: 1635
product: Kapacitor
version: v1
---

# Update Kapacitor Flux tasks

Use the **`kapacitor` CLI** or the **Kapacitor HTTP API** to update Kapacitor Flux tasks.

<!-- Tabbed content: Select one of the following options -->

**CLI:**

Use the `kapacitor flux task update` command to update Kapacitor Flux tasks. Provide the following flags:

\* Required

-   \* `-i`, `--id`: Task ID
-   `--status`: Updated tasks status (`active` or `inactive`)
-   `-f`, `--file`: Path to updated Flux script file

## Examples

-   [Update Flux task code](#update-flux-task-code)
-   [Enable or disable a Flux task](#enable-or-disable-a-flux-task)

##### Update Flux task code

```sh
kapacitor flux task update \
  --id 000x00xX0xXXx00 \
  --file /path/to/updated-task.flux
```

##### Enable or disable a Flux task

```sh
kapacitor flux task update \
  --id 000x00xX0xXXx00 \
  --status inactive
```

**API:**

Use the following request method and endpoint to update a new Kapacitor Flux task.

PATCH /kapacitor/v1/api/v2/tasks/{taskID}

Provide the following with your request (\* Required):

#### Headers

-   \* **Content-type**: application/json

#### Path parameters

-   \* **taskID**: Task ID to update

#### Request body

JSON object with the following schema:

-   **cron**: Override the `cron` Flux task option
-   **description**: New task description
-   **every**: Override the `every` Flux task option
-   **flux**: New Flux task code
-   **name**: Override the `name` Flux task option
-   **offset**: Override the `offset` Flux task option
-   **status**: New Flux task status (`active` or `inactive`)

## API Examples

*The following examples use the task ID `000x00xX0xXXx00`.*

-   [Update Flux task code](#update-flux-task-code-api)
-   [Enable or disable a Flux task](#enable-or-disable-a-flux-task-api)
-   [Override Flux task options](#override-flux-task-options-api)

##### Update Flux task code

```sh
curl --request PATCH 'http://localhost:9092/kapacitor/v1/api/v2/tasks/000x00xX0xXXx00' \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "flux": "option task = {name: \"Updated task name\", every: 1h}\n\nhost = \"http://localhost:8086\"\ntoken = \"\"\n\nfrom(bucket: \"db/rp\", host:host, token:token)\n\t|> range(start: -1h)\n\t|> filter(fn: (r) =>\n\t\t(r._measurement == \"cpu\"))\n\t|> filter(fn: (r) =>\n\t\t(r._field == \"usage_system\"))\n\t|> filter(fn: (r) =>\n\t\t(r.cpu == \"cpu-total\"))\n\t|> aggregateWindow(every: 1h, fn: max)\n\t|> to(bucket: \"cpu_usage_user_total_1h\", host:host, token:token)"
}'
```

##### Enable or disable a Flux task

```sh
curl --request PATCH 'http://localhost:9092/kapacitor/v1/api/v2/tasks/000x00xX0xXXx00' \
  --header 'Content-Type: application/json' \
  --data-raw '{"status": "inactive"}'
```

##### Override Flux task options

```sh
curl --request PATCH 'http://localhost:9092/kapacitor/v1/api/v2/tasks/000x00xX0xXXx00' \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "every": "1d",
    "name": "New task name",
    "offset": "15m"
}'
```

<!-- End tabbed content -->

#### Related

-   [kapacitor flux task update](/kapacitor/v1/reference/cli/kapacitor/flux/task/update/)
