# email_thread_modify

Modify Email Thread

## Beschreibung

Modifies a thread's state: applies / removes labels, marks
read or unread, stars / un-stars, moves to or from trash.
Changes are pushed to Gmail (so they sync to the user's
other clients) and the local mirror is updated to match.

Convenience shortcuts:

- **Archive** = `remove_labels: ["INBOX"]`
- **Mark thread read** = `read: true`
- **Star** = `starred: true` (same as adding `STARRED`)
- **Move to spam** = `add_labels: ["SPAM"]`

Label IDs accept either Gmail's system well-known IDs
(`INBOX`, `UNREAD`, `STARRED`, `IMPORTANT`, `TRASH`,
`SPAM`, `DRAFT`, `SENT`, `CHAT`) or a user label's prefix
ID (`elbl_…`) discovered via `email_account_list`.

Account binding is inferred from the thread ID — no
`from_account_id` is needed.

## Zugriff

Zugriffsprofil: `gated`. Module: `email`.
Die Freigabe im Profil ersetzt keine Account-, Workspace- oder Rollenberechtigung.

## Parameter

| Name | Typ | Pflicht | Beschreibung |
| --- | --- | --- | --- |
| `account_id` | string | Ja | Account prefix ID (acct_…). |
| `thread_id` | string | Ja | Thread prefix ID (ethr_…). |
| `add_labels` | array | Nein | Label IDs to add. System well-knowns or elbl_… IDs. |
| `remove_labels` | array | Nein | Label IDs to remove. Same format as add_labels. |
| `read` | boolean | Nein | true → remove UNREAD on every message; false → mark all unread. |
| `starred` | boolean | Nein | true → add STARRED; false → remove STARRED. |
| `trashed` | boolean | Nein | true → move to trash; false → restore from trash. |

## Eingabeschema

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "properties": {
    "account_id": {
      "type": "string",
      "description": "Account prefix ID (acct_…)."
    },
    "thread_id": {
      "type": "string",
      "description": "Thread prefix ID (ethr_…)."
    },
    "add_labels": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Label IDs to add. System well-knowns or elbl_… IDs."
    },
    "remove_labels": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Label IDs to remove. Same format as add_labels."
    },
    "read": {
      "type": "boolean",
      "description": "true → remove UNREAD on every message; false → mark all unread."
    },
    "starred": {
      "type": "boolean",
      "description": "true → add STARRED; false → remove STARRED."
    },
    "trashed": {
      "type": "boolean",
      "description": "true → move to trash; false → restore from trash."
    }
  },
  "required": [
    "account_id",
    "thread_id"
  ],
  "type": "object"
}
```

## Ausgabeschema

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "properties": {
    "ok": {
      "type": "boolean"
    },
    "thread": {
      "type": "object",
      "description": "MINIMAL-format thread state after the mutation (no per-message bodies/attachments).",
      "properties": {
        "id": {
          "type": "string"
        },
        "account_id": {
          "type": "string"
        },
        "subject": {
          "type": [
            "string",
            "null"
          ]
        },
        "snippet": {
          "type": [
            "string",
            "null"
          ]
        },
        "message_count": {
          "type": "integer"
        },
        "last_message_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "is_unread": {
          "type": "boolean"
        },
        "is_starred": {
          "type": "boolean"
        },
        "has_attachments": {
          "type": "boolean"
        }
      }
    }
  },
  "required": [
    "ok",
    "thread"
  ],
  "type": "object"
}
```
