Skip to main content
import { createClient } from "@mailsai/sdk";

const client = createClient(); // reads MAILS_API_KEY

const result = await client.messages.cancel(
  "msg_01JZX8K3M9Q4P7VN2YB6RTDC0E",
);
console.log(result);
{
  "id": "msg_01JZX8K3M9Q4P7VN2YB6RTDC0E",
  "status": "canceled",
  "canceled_at": "2026-10-04T12:00:00.000Z"
}

Cancel a scheduled message

Cancels a send that is still scheduled, so it is never sent.
POST/v1/messages/{id}/cancelscope · manage
import { createClient } from "@mailsai/sdk";

const client = createClient(); // reads MAILS_API_KEY

const result = await client.messages.cancel(
  "msg_01JZX8K3M9Q4P7VN2YB6RTDC0E",
);
console.log(result);
{
  "id": "msg_01JZX8K3M9Q4P7VN2YB6RTDC0E",
  "status": "canceled",
  "canceled_at": "2026-10-04T12:00:00.000Z"
}

Path Parameters

idstringrequired

Sent message id with status scheduled.

Once the send starts going out it can no longer be canceled: the cancel changes nothing and answers 409 duplicate_resource, also when the send started while the cancel was running. A test key cannot cancel a send a live key scheduled (403 live_mode_required).

Response

idstring

Id of the canceled message (msg_…): the id in the path.

statusstring

Always canceled: the message will not be sent. Only a scheduled message can be canceled.

One of: canceled

canceled_atstring

When the send was canceled: the time of this request, also kept as the message's canceled_at.

Was this page helpful?