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

# Delete Message

> Permanently delete a message and its attachments, or cancel a scheduled send.

Two destructive operations on messages, both requiring the `messages:send` scope.

## Delete a message

`DELETE /v1/messages/{id}` permanently deletes the message row. Attachment rows cascade-delete, and the stored objects — HTML body, raw archive, and every attachment — are removed from R2 when storage is bound. This cannot be undone.

<RequestExample>
  ```bash cURL theme={null}
  curl -X DELETE https://api.gork.email/v1/messages/msg_90e38dfb4a2c \
    -H "Authorization: Bearer gork_live_YOUR_API_KEY"
  ```

  ```typescript TypeScript theme={null}
  import { Gork } from "@gork/sdk"

  const gork = new Gork({ apiKey: process.env.GORK_API_KEY })

  // The SDK has no delete helper — call the endpoint directly.
  // (Cancel a scheduled send instead with gork.messages.cancelScheduled(id).)
  await fetch("https://api.gork.email/v1/messages/msg_90e38dfb4a2c", {
    method: "DELETE",
    headers: { Authorization: `Bearer ${process.env.GORK_API_KEY}` },
  })
  ```

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

  res = requests.delete(
      "https://api.gork.email/v1/messages/msg_90e38dfb4a2c",
      headers={"Authorization": f"Bearer {os.getenv('GORK_API_KEY')}"},
  )
  ```
</RequestExample>

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "data": {
      "id": "msg_90e38dfb4a2c",
      "deleted": true
    }
  }
  ```
</ResponseExample>

## Cancel a scheduled message

`DELETE /v1/messages/{id}/schedule` cancels a scheduled send before it dispatches. The record is kept for audit with status `cancelled` and can never be dispatched afterwards — the scheduler only picks up rows still marked `scheduled`. No quota is consumed by a cancelled message.

<RequestExample>
  ```bash cURL theme={null}
  curl -X DELETE https://api.gork.email/v1/messages/msg_90e38dfb4a2c/schedule \
    -H "Authorization: Bearer gork_live_YOUR_API_KEY"
  ```

  ```typescript TypeScript theme={null}
  import { Gork } from "@gork/sdk"

  const gork = new Gork({ apiKey: process.env.GORK_API_KEY })

  await gork.messages.cancelScheduled("msg_90e38dfb4a2c")
  ```

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

  res = requests.delete(
      "https://api.gork.email/v1/messages/msg_90e38dfb4a2c/schedule",
      headers={"Authorization": f"Bearer {os.getenv('GORK_API_KEY')}"},
  )
  ```
</RequestExample>

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "data": {
      "id": "msg_90e38dfb4a2c",
      "status": "cancelled"
    }
  }
  ```
</ResponseExample>

| Code                  | HTTP | Meaning                                                                                                 |
| --------------------- | ---- | ------------------------------------------------------------------------------------------------------- |
| `inbox_access_denied` | 403  | The key is bound to a different inbox than this message.                                                |
| `message_not_found`   | 404  | No message with this ID exists in your organization.                                                    |
| `not_scheduled`       | 409  | Cancel-schedule only: the message is in another status (e.g. `delivered`) — there is nothing to cancel. |
