# stensul-delete-email-module

> Removes one module (a whole section) from a draft, or checks what else would go when the user asked to remove a single element.

Source: https://stensul.com/developers/reference/stensul-delete-email-module/ · From the live server's tool list, 2026-09-28

- Scope: `emails:write`
- Access: write

Set `removing` to what the user pointed at. `module` deletes that section in one call. `element` makes the tool check first: if the element can be hidden, hide it with `stensul-update-email-content` instead; if its section holds other content, the tool lists it and waits for the user's yes (`confirmedWithUser: true`).

## Inputs

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `emailId` | string (24-char hex id) | yes | Email ID. |
| `moduleId` | string \| number | yes | Module instance id from the read (not the module key). |
| `removing` | "module" \| "element" | yes | What the user asked to remove. |
| `elementId` | string \| number | no | Required when `removing` is `element`. |
| `confirmedWithUser` | boolean | no | Only after the tool listed what would be lost and the user agreed. Never on a first call. |
| `save_version` | integer | no | The email's version as you last read or wrote it. |

## Example request

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "stensul-delete-email-module",
    "arguments": {
      "emailId": "64f0c0ffee0000000000abcd",
      "moduleId": 2817004,
      "removing": "module",
      "save_version": 8
    }
  }
}
```

## Response

Confirmation of the deletion, or a refusal that explains why (for example a locked module) or lists what else the user must agree to lose.

## Errors

| Status | Message | Cause | Fix |
| --- | --- | --- | --- |
| 401 | Authentication expired or missing | The session's authorization expired. | Sign in again when the host prompts. On a 401 or 403, the server's instructions tell the model to re-check sign-in first. |
| 403 | Insufficient OAuth scope (403): The token lacks the required scope | The API connection doesn't have the scope this tool needs. | An admin adds the scope to the API connection. Then sign in again: adding a scope revokes existing tokens. |
| 403 | API error (403): Action is unauthorized. | The signed-in user's role lacks the permission, for example `edit_campaign`. | Grant the permission to the user's role in Admin > Users & Roles. It works for other users on the same connection. |
| 409 | Version conflict | The email changed since your last read, and you passed its old `save_version`. | Read the email again and re-apply your change on the current version. Never retry by dropping `save_version`. |
| 403 | API error (403): Sent emails cannot be edited. | The email has already been sent. | Nothing to fix. Copy it and edit the copy. |
