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

# Update Workflow

> Edit fields on an existing workflow, or enable / disable it

## Request

### Path Parameters

<ParamField path="id" type="string" required>
  Workflow UUID.
</ParamField>

### Headers

```
Authorization: Bearer wbk_your_api_key_here
Content-Type: application/json
```

<ParamField header="Idempotency-Key" type="string">
  Optional UUID for retry deduplication.
</ParamField>

### Body Parameters

All fields are optional; include only those you want to change. At least one field is required.

<ParamField body="name" type="string">
  Updated name.
</ParamField>

<ParamField body="enabled" type="boolean">
  `true` to enable, `false` to disable.
</ParamField>

<ParamField body="condition_entity" type="string">
  Updated condition entity.
</ParamField>

<ParamField body="condition_field" type="string">
  Updated condition field.
</ParamField>

<ParamField body="condition_operator" type="string">
  Updated operator.
</ParamField>

<ParamField body="condition_value" type="string">
  Updated value.
</ParamField>

<ParamField body="action_type" type="string">
  Updated action type.
</ParamField>

<ParamField body="action_config" type="object">
  Updated action configuration. Replaces the existing config entirely; there is no deep-merge.
</ParamField>

<ParamField body="max_triggers_per_day" type="integer">
  Updated daily cap.
</ParamField>

## Response

<ResponseField name="data" type="object">
  The updated workflow record (same shape as `GET /v1/workflows/{id}`).
</ResponseField>

Responses include `X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset`, and `X-Request-ID`.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PATCH \
    https://data.leadlex.com/functions/v1/api-gateway/v1/workflows/wf_01HY1 \
    -H "Authorization: Bearer wbk_your_api_key_here" \
    -H "Content-Type: application/json" \
    -d '{"enabled": false}'
  ```

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

  API_KEY = "wbk_your_api_key_here"
  wf_id = "wf_01HY1"

  r = requests.patch(
      f"https://data.leadlex.com/functions/v1/api-gateway/v1/workflows/{wf_id}",
      headers={
          "Authorization": f"Bearer {API_KEY}",
          "Content-Type": "application/json",
      },
      json={"max_triggers_per_day": 200},
  )
  print(r.json()["data"])
  ```

  ```javascript JavaScript theme={null}
  const id = 'wf_01HY1';
  const res = await fetch(
    `https://data.leadlex.com/functions/v1/api-gateway/v1/workflows/${id}`,
    {
      method: 'PATCH',
      headers: {
        'Authorization': 'Bearer wbk_your_api_key_here',
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({ enabled: false }),
    }
  );
  const { data } = await res.json();
  console.log(data);
  ```
</CodeGroup>

### Example Response

```json theme={null}
{
  "data": {
    "id": "wf_01HY1",
    "name": "Notify owner on lost deals",
    "enabled": false,
    "condition_entity": "deal",
    "condition_field": "status",
    "condition_operator": "changed_to",
    "condition_value": "lost",
    "action_type": "send_channel_message",
    "action_config": {
      "channel": "slack",
      "recipient": "{{deal.owner.slack_id}}",
      "message": "Deal {{deal.name}} was marked lost."
    },
    "max_triggers_per_day": 200,
    "triggers_today": 3,
    "last_triggered_at": "2026-04-17T09:31:00Z",
    "auto_disabled_reason": null,
    "created_at": "2026-03-01T08:00:00Z",
    "updated_at": "2026-04-17T11:10:00Z"
  }
}
```

## Errors

| Status | Code                       | Description                                                       |
| ------ | -------------------------- | ----------------------------------------------------------------- |
| 400    | `validation_error`         | No updatable fields provided or unsupported operator/action combo |
| 401    | `invalid_key`              | Invalid or expired API key                                        |
| 403    | `insufficient_permissions` | Missing `write:workflows` permission                              |
| 404    | `not_found`                | Workflow not found                                                |
| 429    | `rate_limited`             | Rate limit exceeded                                               |
