# email_share_to_chat

Share Email to Chat

## Beschreibung

Posts an email into a chat channel or DM so the workspace can see
it without leaving chat, and links the two for traceability.

Pass exactly one of `message_id` (`emsg_…`) or `thread_id`
(`ethr_…`); for a thread the latest message is shared. Pass
exactly one target: `channel_id` (`chan_…` from
chat_list_channels) or `dm_with_user` (a `@handle` / user
prefix — starts-or-finds the 1:1 DM).

The posted message is authored by you: an optional `comment`
on top, then a quote block (sender / subject / snippet) unless
`include_quote` is false, and the email's attachments unless
`include_attachments` is false (default true for both).

You must have post access to the target channel (membership,
or admin/employer reach). Idempotent per (email, channel): if
the email is already shared into that channel the existing
chat message is returned with `created: false` — a retry won't
double-post.

## 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_…). |
| `message_id` | string | Nein | Source message (emsg_…). Provide this OR thread_id. |
| `thread_id` | string | Nein | Source thread (ethr_…); its latest message is shared. Provide this OR message_id. |
| `channel_id` | string | Nein | Target channel (chan_…). Provide this OR dm_with_user. |
| `dm_with_user` | string | Nein | Target DM partner: @handle or user prefix ID. Starts-or-finds the 1:1 DM. Provide this OR channel_id. |
| `comment` | string | Nein | Optional note posted above the email quote. |
| `include_attachments` | boolean | Nein | Re-attach the email's files to the chat message. Default true. |
| `include_quote` | boolean | Nein | Include the From / Subject / snippet quote block. Default true. |

## Eingabeschema

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "properties": {
    "account_id": {
      "type": "string",
      "description": "Account prefix ID (acct_…)."
    },
    "message_id": {
      "type": "string",
      "description": "Source message (emsg_…). Provide this OR thread_id."
    },
    "thread_id": {
      "type": "string",
      "description": "Source thread (ethr_…); its latest message is shared. Provide this OR message_id."
    },
    "channel_id": {
      "type": "string",
      "description": "Target channel (chan_…). Provide this OR dm_with_user."
    },
    "dm_with_user": {
      "type": "string",
      "description": "Target DM partner: @handle or user prefix ID. Starts-or-finds the 1:1 DM. Provide this OR channel_id."
    },
    "comment": {
      "type": "string",
      "description": "Optional note posted above the email quote."
    },
    "include_attachments": {
      "type": "boolean",
      "description": "Re-attach the email's files to the chat message. Default true."
    },
    "include_quote": {
      "type": "boolean",
      "description": "Include the From / Subject / snippet quote block. Default true."
    }
  },
  "required": [
    "account_id"
  ],
  "type": "object"
}
```

## Ausgabeschema

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "properties": {
    "chat_message": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "url": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "url"
      ]
    },
    "share_link_id": {
      "type": "string",
      "description": "The EmailChatShare prefix ID (ecsh_…)."
    },
    "created": {
      "type": "boolean",
      "description": "false when an existing share was returned (idempotent re-share)."
    }
  },
  "required": [
    "chat_message",
    "share_link_id",
    "created"
  ],
  "type": "object"
}
```
