# Update an AI label rule

Source: https://docs.maylee.app/api-reference/ai-label-rules/update-ai-label-rule

`PATCH https://api.maylee.app/api/v1/ai-label-rules/{ruleId}`

Scope: `write`. Also requires `allowOutboundSend when autoReplyEnabled is true` (the Send emails permission of the key).

Renames the label, changes the condition, or configures auto-draft and auto-reply. Setting `autoReplyEnabled: true` requires `allowOutboundSend` on the key.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `ruleId` | path | string | yes |  |

## Request body

`application/json`, required.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `autoDraftEnabled` | boolean | no | Auto-draft: Maylee prepares a reply draft for matching emails, for a person to review. Requires a subscription (`402 PLAN_REQUIRED` otherwise). |
| `autoReplyConfidenceThreshold` | integer | no | The reply is sent only when Maylee's confidence reaches this value (0 to 100); otherwise it stays in Drafts for review. From 0 to 100. |
| `autoReplyDelayMinutes` | integer | no | Minutes to wait before sending (0 to 15), so that the user can cancel. From 0 to 15. |
| `autoReplyEnabled` | boolean | no | Auto-reply: Maylee sends the draft prepared by auto-draft without review, so it only works together with `autoDraftEnabled`. Requires a subscription and the Send emails permission on the key. |
| `autoReplyNotifyOnSend` | boolean | no | Stored with the rule. It has no effect today. |
| `color` | string | no | Color name. The Maylee app renders `Pink`, `Blue`, `Red`, `Yellow`, `Green`, `Purple` and `Orange`; any other value is stored but shown without color. |
| `condition` | string | no | Plain-language condition that Maylee checks on every new incoming email, for example "Invoices, receipts or payment reminders from suppliers". 0 to 500 characters. |
| `hideFromInbox` | boolean | no | Emails that receive this label leave the main inbox. They stay in INBOX, listable with `GET /emails?filtered=only`. |
| `name` | string | no | Name of the AI label, unique among all labels of the workspace (manual and AI). 1 to 50 characters. |

## Example request

```bash
curl -X PATCH "https://api.maylee.app/api/v1/ai-label-rules/<ruleId>" \
  -H "Authorization: Bearer $MAYLEE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "autoDraftEnabled": true
}'
```

## Responses

### 200

The updated rule.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `rule` | AiLabelRule | yes | An AI label and the natural-language condition that applies it. Auto-draft and auto-reply are configured here. |
| `rule.autoDraftEnabled` | boolean | yes |  |
| `rule.autoReplyConfidenceThreshold` | integer | yes | From 0 to 100. |
| `rule.autoReplyDelayMinutes` | integer | yes | From 0 to 15. |
| `rule.autoReplyEnabled` | boolean | yes | When true, Maylee sends replies on your behalf. Setting it requires `allowOutboundSend` on the key. |
| `rule.autoReplyNotifyOnSend` | boolean | yes |  |
| `rule.condition` | string | yes | Natural-language condition, up to 500 characters. |
| `rule.createdAt` | string (date-time) | yes |  |
| `rule.hideFromInbox` | boolean | yes | When true, emails that receive this label leave the main inbox. They stay in INBOX, listable with `GET /emails?filtered=only`, and remain visible in any view whose criteria match them. |
| `rule.id` | string | yes |  |
| `rule.label` | LabelRef | yes | A label as it appears on an email or on a rule. |
| `rule.updatedAt` | string (date-time) | yes |  |

```json
{
  "rule": {
    "autoDraftEnabled": true,
    "autoReplyConfidenceThreshold": 85,
    "autoReplyDelayMinutes": 0,
    "autoReplyEnabled": false,
    "autoReplyNotifyOnSend": true,
    "condition": "The sender asks about pricing, a quote or a demo of our product.",
    "createdAt": "2026-06-03T08:00:00.000Z",
    "hideFromInbox": false,
    "id": "cmrl1a2b3c4d5e6f7g8h9i0j",
    "label": {
      "color": "Blue",
      "id": "cmtgai1b2c3d4e5f6g7h8i9j",
      "isAiLabel": true,
      "name": "Sales"
    },
    "updatedAt": "2026-08-20T16:40:00.000Z"
  }
}
```

### 400

Invalid or empty payload.

### 401

Missing, malformed, revoked or expired API key.

### 403

Key lacks the required scope, or outbound sending is not enabled on it.

### 404

Not found, or belongs to another workspace.

### 409

`DUPLICATE_RULE`: an AI label with this name already exists.

### 429

Per-minute rate limit (`RATE_LIMIT_EXCEEDED`) or monthly quota (`QUOTA_EXCEEDED`) exhausted.

Errors use the format `{ "code", "error", "details" }`: see [Errors](/errors.md).
