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

# Cancel a message

> Cancel a still-pending message before it is dispatched. Only messages
whose status is `scheduled` or `queued` can be canceled; anything past
that (rendered, dispatched, sent, delivered, failed, opted_out,
suppressed, blocked, canceled) is already committed to a provider or terminal.

Cancellation is race-safe: if the dispatcher advances the message while
the cancel request is in flight, the request fails with `409` and the
message's freshly observed status.




## OpenAPI

````yaml https://www.senderkit.com/openapi.yaml delete /v1/messages/{id}
openapi: 3.1.0
info:
  title: SenderKit Public API
  version: 1.0.0
  description: >
    Public REST API for SenderKit — send transactional messages (email, SMS,

    push, web push), list message history, and read/render templates.


    ## Authentication

    All endpoints require a Bearer API key:

        Authorization: Bearer sk_live_xxx

    The `sk_live_` / `sk_test_` prefix selects the environment (live vs. test).

    The prefix is only a hint for humans; the secret is the full token. Keys are

    created in the dashboard and shown once at creation.


    ## Sends are asynchronous

    `POST /v1/send` enqueues the message and returns `202` with `status:
    "queued"`.

    Delivery happens out of band; poll `GET /v1/messages` to observe progress.


    ## Rate limits

    All endpoints are rate limited per API key. Sends and reads count against

    separate budgets, so listing messages never competes with sending them.

    A `429` response includes a `Retry-After` header (seconds).
servers:
  - url: https://api.senderkit.com
    description: Production
  - url: http://localhost:3000/api
    description: Local development
security:
  - apiKey: []
tags:
  - name: Context
    description: Inspect the workspace and environment an API key operates in.
  - name: Send
    description: Dispatch messages.
  - name: Messages
    description: Read message history and cancel pending sends.
  - name: Templates
    description: Read and render stored templates.
  - name: Inbound
    description: |
      Provision addresses on your workspace's shared receiving domain and read
      mail sent to them. Requires an API key with the `inbound` scope.
paths:
  /v1/messages/{id}:
    delete:
      tags:
        - Messages
      summary: Cancel a message
      description: >
        Cancel a still-pending message before it is dispatched. Only messages

        whose status is `scheduled` or `queued` can be canceled; anything past

        that (rendered, dispatched, sent, delivered, failed, opted_out,

        suppressed, blocked, canceled) is already committed to a provider or
        terminal.


        Cancellation is race-safe: if the dispatcher advances the message while

        the cancel request is in flight, the request fails with `409` and the

        message's freshly observed status.
      operationId: cancelMessage
      parameters:
        - $ref: '#/components/parameters/MessageId'
      responses:
        '200':
          description: The message was canceled.
          content:
            application/json:
              schema:
                type: object
                required:
                  - id
                  - status
                properties:
                  id:
                    type: string
                    description: Public message ID (e.g. `msg_...`).
                    example: msg_0a1b2c3d4e5f6g7h
                  status:
                    type: string
                    const: canceled
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: No message with that id in this workspace and environment.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: |
            Not cancelable (`not_cancelable`) — the message has already been
            dispatched or is in a terminal state. The error message includes
            the message's current status.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  parameters:
    MessageId:
      name: id
      in: path
      required: true
      description: Public message ID (e.g. `msg_...`).
      schema:
        type: string
  responses:
    Unauthorized:
      description: Missing, malformed, invalid, or revoked API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    RateLimited:
      description: Rate limit exceeded.
      headers:
        Retry-After:
          description: Seconds to wait before retrying.
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              description: Stable machine-readable error code.
              example: invalid_request
            message:
              type: string
            issues:
              type: array
              description: Present on validation failures (Zod issues).
              items:
                type: object
                additionalProperties: true
            limit:
              type: integer
              description: Present on rate-limit errors.
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: API key with an `sk_live_` or `sk_test_` prefix.

````